我正在尝试构建CNN + RNN模型,我收到以下错误.任何帮助将不胜感激.
fc2有形状(?,4096)
cell = tf.contrib.rnn.BasicLSTMCell(self.rnn_hidden_units)
stack = tf.contrib.rnn.MultiRNNCell([cell]*self.rnn_layers)
initial_state = cell.zero_state(self.batch_size, tf.float32)
initial_state = tf.identity(initial_state, name='initial_state')
outputs, _ = tf.nn.dynamic_rnn(stack, fc2,dtype=tf.float32)
Run Code Online (Sandbox Code Playgroud)
文件"rcnn.py",第182行,在模型输出中,_ = tf.nn.dynamic_rnn(stack,[fc2],dtype = tf.float32)
文件"/usr/local/lib/python2.7/dist-packages /tensorflow/python/ops/rnn.py",第574行,在dynamic_rnn dtype = dtype中)
文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py",行637,在_dynamic_rnn_loop中为input_ in flat_input)
文件"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py",第637行,in为input_ in flat_input)
文件"/ usr /local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_shape.py",第649行,with_rank_at_least引发ValueError("Shape%s必须至少有排名%d"%(自我,排名) )ValueError:Shape(4096,?)的等级必须至少为3
从他的评论中复制@jdehesa的答案以获得更好的可见性:
错误似乎相当清楚,tf.nn.dynamic_rnn期望三维张量作为输入(即等级3),但fc2只有两个维度.形状fc2
应该是(<batch_size>, <max_time>, <num_features>)
(或(<max_time>, <batch_size>, <num_features>)
如果你通过time_major=True
)
归档时间: |
|
查看次数: |
7523 次 |
最近记录: |