Neural network 使用theano实现LSTM
我正在使用无扫描函数来实现LSTM(长-短期内存),但我遇到了如下错误Neural network 使用theano实现LSTM,neural-network,theano,deep-learning,lstm,Neural Network,Theano,Deep Learning,Lstm,我正在使用无扫描函数来实现LSTM(长-短期内存),但我遇到了如下错误 ValueError: Please provide None as outputs_info for any output that does not feed back into scan (i.e. it behaves like a map) 我以前是这样扫描的 p_c = T.matrix() p_hidden_inputs = T.matrix() out, updates = scan(step_fprop
ValueError: Please provide None as outputs_info for any output that does not feed back into scan (i.e. it behaves like a map)
我以前是这样扫描的
p_c = T.matrix()
p_hidden_inputs = T.matrix()
out, updates = scan(step_fprop,
sequences=model_inputs,
outputs_info= [p_c, p_hidden_inputs],
non_sequences=
[
Wxi, Whi, Wci, bi,
Wxf, Whf, Wcf, bf,
Wxc, Whc, bc,
Wxo, Who, Wco, bo
],
n_steps=n_steps,
)
步骤fprop的定义如下:
def step_fprop(inputs, p_c, p_hidden_inputs,
Wxi, Whi, Wci, bi,
Wxf, Whf, Wcf, bf,
Wxc, Whc, bc,
Wxo, Who, Wco, bo
):
"""
Construct the forward propagation
:return:
:rtype:
"""
# input gate
ig = T.nnet.sigmoid(T.dot(inputs, Wxi) +
T.dot(p_hidden_inputs, Whi) +
T.dot(p_c, Wci) +
bi)
# forget gate
fg = T.nnet.sigmoid(T.dot(inputs, Wxf) +
T.dot(p_hidden_inputs, Whf) +
T.dot(p_c, Wcf) +
bf)
# cell
cc= fg * p_c + ig * T.tanh(T.dot(inputs, Wxc) +
T.dot(p_hidden_inputs, Whc ) +
bc)
#output gate
og = T.nnet.sigmoid(T.dot(inputs, Wxo) +
T.dot(p_hidden_inputs,Who) +
T.dot(p_c, Wco) +
bo)
#hidden state
hh = og * T.tanh(cc)
return hh
任何人都知道我为什么一直出现这种错误。
输出信息
期望在步骤fprop
函数的返回
中传递的每个变量的值。您的代码似乎只返回隐藏状态hh
,但outputs\u info
需要两个值,其初始状态由p\u c
和p\u hidden\u输入定义
看起来您需要在step\u fprop函数中返回[\u whatever\u previous\lstm\u state,hh]