model.py 文件源码

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

项目:python-utils 作者: zhijian-liu 项目源码 文件源码
def forward(self, inputs):
        # set up batch size
        batch_size = inputs.size(0)

        # compute hidden and cell
        hidden = Variable(torch.zeros(self.num_layers * 2, batch_size, self.hidden_size).cuda())
        cell = Variable(torch.zeros(self.num_layers * 2, batch_size, self.hidden_size).cuda())
        hidden_cell = (hidden, cell)

        # recurrent neural networks
        outputs, _ = self.rnn.forward(inputs, hidden_cell)
        outputs = outputs[:, -1, :].contiguous()

        # compute features by outputs
        features = self.feature.forward(outputs)
        return features
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号