Tensorflow:尝试使用未初始化的值RNN / GRUCell / Gates / Linear / Bias

时间:2016-03-04 08:01:23

标签: tensorflow deep-learning lstm

环境信息

操作系统: Rocks OS(Centos 6.5)

我是从源码安装的,这是我的版本: https://github.com/shiyemin/tensorflow/ 没有什么改变,只是为了让它在我们的服务器上成功编译。

错误

我使用caffe-tensorflow将caffe模型转换为tensorflow,并选择GoogLeNet来构建我们的网络。

我将LSTM图层添加到此代码中,如下所示:

@layer
def lstm(self, input, lstm_type, n_steps, initial_state, num_units, name):
    #  with tf.variable_scope(name) as scope:
    input_shape = input.get_shape()
    dim = 1
    for d in input_shape[1:].as_list():
        dim *= d
    input = tf.reshape(input, [input_shape[0].value, -1])

    # select LSTM type, Define a lstm cell with tensorflow
    if lstm_type == 'basic':
        lstm_cell = rnn_cell.BasicLSTMCell(num_units, input_size=dim)
    elif lstm_type == 'lstm':
        lstm_cell = rnn_cell.LSTMCell(num_units, input_size=dim)
    elif lstm_type == 'GRU':
        lstm_cell = rnn_cell.GRUCell(num_units, input_size=dim)
    else:
        raise ValueError("LSTM type %s error."%lstm_type)

    # Split data because rnn cell needs a list of inputs for the RNN inner loop
    input = tf.split(0, n_steps, input) # n_steps * (batch_size, n_hidden)

    # Get lstm cell output
    outputs, states = rnn.rnn(lstm_cell, input, initial_state=initial_state) # , scope=scope)
    outputs = tf.concat(0, outputs)
    return outputs #, states

当我将此LSTM图层添加到GoogLeNet时,会发生以下错误。

Failed precondition: Attempting to use uninitialized value  RNN/GRUCell/Gates/Linear/Bias

但是当我使用以下代码时:

https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3%20-%20Neural%20Networks/recurrent_network.py

一切顺利。

有谁知道发生了什么?我不知道如何调试此错误。

0 个答案:

没有答案