2024-09-23 04:20:08 发布
网友
我用TensorFlow尝试了一些东西,但出现了以下错误:
ValueError: Input 0 of layer gru is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 3)
我怎样才能修好它
我可以用示例代码重现您的问题tf.keras.layers.GRU需要输入一个三维张量,形状为[batch, timesteps, feature]
tf.keras.layers.GRU
[batch, timesteps, feature]
复制代码
import tensorflow as tf inputs = tf.random.normal([32, 8]) gru = tf.keras.layers.GRU(4) output = gru(inputs) print(output.shape)
输出
ValueError: Input 0 of layer gru_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (32, 8)
工作样本代码
import tensorflow as tf inputs = tf.random.normal([32, 10, 8]) gru = tf.keras.layers.GRU(4) output = gru(inputs) print(output.shape)
(32, 4)
我可以用示例代码重现您的问题
tf.keras.layers.GRU
需要输入一个三维张量,形状为[batch, timesteps, feature]
复制代码
输出
工作样本代码
输出
相关问题 更多 >
编程相关推荐