首页 > 解决方案 > ValueError logits 和标签必须具有相同的形状 (?, 10) vs (2,2,?,10)

问题描述

我想使用 2 个 LSTM 单元更新一个简单的神经网络。旧架构(有效):输入 => RNN => 输出 新架构(有值错误):输入 => LSTM => LSTM => 输出

layers = 2
units = 10
outputs = 10
X = tf.placeholder (tf.float32,[None,nr_steps, nr_inputs])
y = tf.placeholder (tf.float32,[None,outputs])
cells = [tf.nn.rnn_cell.BasicLSTMCell (num_units = units)
        for _ in range(layers)]
neurons = tf.nn.rnn_cell.MultiRNNCell(cells)
rnn_outputs, rnn_states = tf.nn.dynamic_rnn (neurons, X, dtype = tf.float32)

代码工作,BasicRNNCell但是,在这个转换之后,我收到了错误

ValueError Shapes (?, 10) and (2,2,?,10) must have the same rank
ValueError Shapes (?, 10) and (2,2,?,10) are not compatible
ValueError logits and labels must have the same shape Shapes (?, 10) vs (2,2,?,10) 

谁能帮我?我认为( 2 ,2,?,10) 的前2个来自 LSTM 单元(但为什么?),来自 (2, 2 , ?,10) 的第二个2来自网络的两层(但为什么?)我该如何处理这个错误?

标签: pythontensorflowdeep-learninglstmvalueerror

解决方案


推荐阅读