尝试运行时,抛出以下异常(ValueError)
ValueError: Shape () must have rank at least 2
Run Code Online (Sandbox Code Playgroud)
这是针对以下行抛出的:
states_series, current_state = tf.contrib.rnn.static_rnn(cell, inputs_series, init_state)
Run Code Online (Sandbox Code Playgroud)
这里cell定义的地方:
cell = tf.contrib.rnn.BasicLSTMCell(state_size, state_is_tuple=True)
Run Code Online (Sandbox Code Playgroud)
查看RNN和Tesor_shape的规则,我可以看到这是某种张量维度形状问题。据我所知,它没有被BasicLSTMCell视为一个秩为 2 的矩阵?
完整错误:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/glennhealy/PycharmProjects/firstRNNTest/LSTM-RNN.py
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
return f(*args, **kwds)
Traceback (most recent call last):
File "/Users/glennhealy/PycharmProjects/firstRNNTest/LSTM-RNN.py", line 42, in <module>
states_series, current_state = tf.contrib.rnn.static_rnn(cell, inputs_series, init_state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 1181, in static_rnn
input_shape = first_input.get_shape().with_rank_at_least(2)
File …Run Code Online (Sandbox Code Playgroud) python neural-network lstm tensorflow recurrent-neural-network