layers.py 文件源码

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

项目:Relation-Network 作者: subercui 项目源码 文件源码
def apply(self, sentences, init_hid=None):
        """
        Parameters
        ----------
        sentences: (length, batch, featuresdim)

        Returns
        -------
        hs: (n_blocks, batch, hid_size)
        """
        if sentences.ndim == 3:
            batch_size = sentences.shape[1]
            n_steps = sentences.shape[0]
        else:
            raise NotImplementedError

        if init_hid is None:
            init_hid = T.unbroadcast(T.alloc(numpy.float32(0.), batch_size, self.hid_size))
        rval, updates = theano.scan(self._step_forward,
                                    sequences=[sentences],
                                    outputs_info=[init_hid],
                                    n_steps=n_steps
                                    )
        self.hs = rval
        return self.hs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号