jeeModels.py 文件源码

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

项目:jointEE-NN 作者: anoperson 项目源码 文件源码
def rnn_ff(inps, dim, hidden, batSize, prefix, params, names):
    Wx  = theano.shared(randomMatrix(dim, hidden))
    Wh  = theano.shared(randomMatrix(hidden, hidden))
    bh  = theano.shared(numpy.zeros(hidden, dtype=theano.config.floatX))
    #model.container['bi_h0']  = theano.shared(numpy.zeros(model.container['nh'], dtype=theano.config.floatX))

    # bundle
    params += [ Wx, Wh, bh ] #, model.container['bi_h0']
    names += [ prefix + '_Wx', prefix + '_Wh', prefix + '_bh' ] #, 'bi_h0'

    def recurrence(x_t, h_tm1):
        h_t = T.nnet.sigmoid(T.dot(x_t, Wx) + T.dot(h_tm1, Wh) + bh)
        return h_t

    h, _  = theano.scan(fn=recurrence, \
            sequences=inps, outputs_info=[T.alloc(0., batSize, hidden)], n_steps=inps.shape[0])

    return h
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号