lstm.py 文件源码

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

项目:DeepLearning 作者: gokererdogan 项目源码 文件源码
def forward_pass(self):
        def recurrence(x_t, h_tm1, c_tm1):
            i = T.nnet.sigmoid(T.dot(x_t, self.wi) + T.dot(h_tm1, self.wih) + self.bi)  # input gate
            c_proposed = T.tanh(T.dot(x_t, self.wc) + T.dot(h_tm1, self.wch) + self.bc)  # proposed memory cell content
            f = T.nnet.sigmoid(T.dot(x_t, self.wf) + T.dot(h_tm1, self.wfh) + self.bf)  # forget gate
            c_t = (T.tile(i, self.memory_size) * c_proposed) + (T.tile(f, self.memory_size) * c_tm1)  # new memory cell content
            o = T.nnet.sigmoid(T.dot(x_t, self.wo) + T.dot(h_tm1, self.woh) + self.bo)  # output gate
            h_t = T.tile(o, self.memory_size) * T.tanh(c_t)
            return [h_t, c_t]

        [h, c], _ = theano.scan(fn=recurrence, sequences=self.input,
                                outputs_info=[self.h0, self.c0], n_steps=self.input.shape[0])

        return h, c
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号