完全错误是
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).我确信这是输入形状错误,这是相关代码:
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 modelenv.OBSERVATION_SPACE_VALUES是(N0NE,6)输入基本上是一个具有6个值的一维数组。
发布于 2021-02-10 17:10:31
不应在层构造函数的input_shape参数中指定批处理维度。
env.OBSERVATION_SPACE_VALUES = (6,)输入层的文档状态(是我的):
input_shape: Shape tuple (不包括批处理轴),或TensorShape实例(不包括批处理轴)。
https://stackoverflow.com/questions/66141562
复制相似问题