0

环境信息

操作系统: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

一切正常。

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

4

0 回答 0