简体   繁体   English

tensorflow:Model 是用形状 (None, None, 6) 构造的,但它是在形状不兼容的输入上调用的

[英]tensorflow:Model was constructed with shape (None, None, 6), but it was called on an input with incompatible shape

The complete error is完整的错误是

WARNING:tensorflow:Model was constructed with shape (None, None, 6) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, 6), dtype=tf.float32, name='dense_input'), name='dense_input', description="created by layer 'dense_input'"), but it was called on an input with incompatible shape (None, 6).
2021-02-10 17:56:08.288146: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-02-10 17:56:08.544550: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
WARNING:tensorflow:Model was constructed with shape (None, None, 6) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, 6), dtype=tf.float32, name='dense_4_input'), name='dense_4_input', description="created by layer 'dense_4_input'"), but it was called on an input with incompatible shape (None, 6).
WARNING:tensorflow:Model was constructed with shape (None, None, 6) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, 6), dtype=tf.float32, name='dense_input'), name='dense_input', description="created by layer 'dense_input'"), but it was called on an input with incompatible shape (20, 6).
WARNING:tensorflow:Model was constructed with shape (None, None, 6) for input KerasTensor(type_spec=TensorSpec(shape=(None, None, 6), dtype=tf.float32, name='dense_input'), name='dense_input', description="created by layer 'dense_input'"), but it was called on an input with incompatible shape (20, 6).

I am sure this is an input shape error, this is the relevant code:我确定这是输入形状错误,这是相关代码:

def create_model(self):
    model = tf.keras.models.Sequential()  # a basic feed-forward model
    model.add(tf.keras.layers.Dense(6, activation=tf.nn.relu, input_shape=env.OBSERVATION_SPACE_VALUES))  # a simple fully-connected layer, 6 units, relu activation
    model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))  # a simple fully-connected layer, 128 units, relu activation
    model.add(tf.keras.layers.Dense(64, activation=tf.nn.relu))  # a simple fully-connected layer, 64 units, relu activation
    model.add(tf.keras.layers.Dense(27, activation=tf.nn.softmax))  # our output layer. 27 units for 27 actions 
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])


    return model

The env.OBSERVATION_SPACE_VALUES is (N0NE, 6) the input is basically a 1 dimensional array with 6 values env.OBSERVATION_SPACE_VALUES 是 (N0NE, 6) 输入基本上是一个具有 6 个值的一维数组

You should not specify the batch dimension in the input_shape argument of the Layer constructor.您不应在 Layer 构造函数的input_shape参数中指定批量维度。

env.OBSERVATION_SPACE_VALUES = (6,)

The documentation of the Input layer states ( emphasis is mine): 输入层状态的文档重点是我的):

input_shape: Shape tuple (not including the batch axis) , or TensorShape instance (not including the batch axis) . input_shape:形状元组(不包括批处理轴) ,或 TensorShape 实例(不包括批处理轴)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:警告:tensorflow:Model 是用形状(无,150)构造的,但它是在形状不兼容的输入上调用的(无,1) - WARNING: WARNING:tensorflow:Model was constructed with shape (None, 150) , but it was called on an input with incompatible shape (None, 1) Tensorflow:Model 是用形状 (None, 28, 28) 构造的,但它是在形状不兼容的输入上调用的 (None, 28) - Tensorflow:Model was constructed with shape (None, 28, 28) , but it was called on an input with incompatible shape (None, 28) WARNING:tensorflow:Model 是用形状 (None, 188) 构造的输入,但它是在形状不兼容的输入上调用的 (188,) - WARNING:tensorflow:Model was constructed with shape (None, 188) for input, but it was called on an input with incompatible shape (188,) Model 是用形状(无,65536)构造的,但它是在形状不兼容的输入上调用的(无,65536,无) - Model was constructed with shape (None, 65536) but it was called on an input with incompatible shape (None, 65536, None) 模型是用形状 (None, 180, 180, 3) 构建的用于输入,但它在形状不兼容的输入 (None, 180, 3) 上被调用? - Model was constructed with shape (None, 180, 180, 3) for input, but it was called on an input with incompatible shape (None, 180, 3)? python 中的神经网络:警告:tensorflow:Model 是用形状(无,7)构建的 - Neural Network in python: WARNING:tensorflow:Model was constructed with shape (None, 7) for input 警告:tensorflow:Model 是用形状构造的(无,...) - WARNING:tensorflow:Model was constructed with shape (None, …) Tensorflow: ValueError: Input 0 is incompatible with layer model: expected shape=(None, 99), found shape=(None, 3) - Tensorflow: ValueError: Input 0 is incompatible with layer model: expected shape=(None, 99), found shape=(None, 3) Tensorflow 模型是用输入 Tensor 的形状构建的,但它在形状不兼容的输入(神经网络)上被调用 - Tensorflow model was constructed with shape for input Tensor but it was called on an input with incompatible shape (Neural Network) 警告:tensorflow:Model 是用输入 Tensor() 的形状构建的。 但它是在形状不兼容的输入上调用的 - WARNING:tensorflow:Model was constructed with shape for input Tensor(). but it was called on an input with incompatible shape
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM