[英]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.