【问题标题】:LSTM implementation using theano使用 theano 的 LSTM 实现
【发布时间】:2015-01-22 06:08:20
【问题描述】:

我正在使用 theano 扫描函数来实现 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,
                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,
                )

而step_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

任何人都知道为什么我不断收到这种错误。

【问题讨论】:

    标签: neural-network theano deep-learning lstm


    【解决方案1】:

    outputs_info 需要 step_fprop 函数的 return 中传递的每个变量的值。您的代码似乎只返回隐藏状态 hhouputs_info 需要两个值,其初始状态由 p_cp_hidden_inputs 定义

    看来您需要在 step_fprop 函数中 return [_whatever_previous_lstm_state, hh]

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      • 1970-01-01
      • 2015-05-20
      • 2019-06-29
      • 2018-04-26
      • 2017-07-18
      相关资源
      最近更新 更多