我对numpy还不熟悉,希望有人能帮我。你知道吗
代码是:
x = tf.placeholder(tf.float32 , [1 , 36])
# L is a list from a list of lists.
sess.run(rnn_model , {x : L})
错误是:
ValueError: Cannot feed value of shape (36,) for Tensor 'Placeholder:0', which has shape '(1, 36)'
我认为这是因为L是2D列表中的一个列表,python认为L必须是一个列列表。你知道吗
如何解决错误?你知道吗
您可以使用
numpy
来重塑list L
,然后使用tf.convert_to_tensor()
。你知道吗示例
输出:
您可以通过在所需位置使用None来使用花式索引来添加尺寸为1的额外维度。你知道吗
或者
如果我不是一个疯子。你知道吗
可以使用np.expand_dims()将列表转换为列向量,如下所示:
相关问题 更多 >
编程相关推荐