lang_model.py 文件源码

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

项目:multitask_sentiment_analysis 作者: polaroidz 项目源码 文件源码
def forward(self, x):
        arr = list()

        for sentence in x:
            # Sentence embedding
            sent_emb = list()

            for word in sentence:
                word = np.array(word)
                word = torch.from_numpy(word)
                word = Variable(word)

                # Gets the embedding for each character in
                # the word
                char_emb = self.embedding(word)

                # Computes the mean between all character level
                # embeddings. MxN -> 1xN
                char_emb = torch.mean(char_emb, 0)

                sent_emb.append(char_emb)

            arr.append(sent_emb)

        return arr
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号