encoder.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:sgnmt 作者: ucam-smt 项目源码 文件源码
def apply(self, source_sentence, source_sentence_mask):
        """Creates bidirectional RNN source annotations.

        Args:
            source_sentence (Variable): Source sentence with words in
                                        vector representation.
            source_sentence_mask (Variable): Source mask

        Returns:
            Variable. source annotations
        """
        # Time as first dimension
        source_sentence = source_sentence.T
        source_sentence_mask = source_sentence_mask.T

        representation = self.bidir.apply(
            merge(self.fwd_fork.apply(source_sentence, as_dict=True),
                  {'mask': source_sentence_mask}),
            merge(self.back_fork.apply(source_sentence, as_dict=True),
                  {'mask': source_sentence_mask})
        )
        return representation, source_sentence_mask
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号