【发布时间】:2021-05-18 22:31:07
【问题描述】:
这是我的代码
model = keras.Sequential([
keras.layers.Flatten(input_shape=(1,11)),
keras.layers.Dense(4, activation='relu'),
keras.layers.Dense(10, activation='softmax')
]
)
我的数据是 1000 行,11 列(模型的 11 个输入)。因此,为了使我使用的 NN 的输入层变平。这给了我错误:
WARNING:tensorflow:Model was constructed with shape (None, 1, 11) for input KerasTensor(type_spec=TensorSpec(shape=(None, 1, 11), dtype=tf.float32, name='flatten_1_input'), name='flatten_1_input', description="created by layer 'flatten_1_input'"), but it was called on an input with incompatible shape (None, 11).
【问题讨论】:
-
解决更多代码(尤其是输入部分)需要的问题。此外,这看起来像错误点的维度,因此打印输入的形状以确保它是您认为的。
-
使用
Keras.layers.Input()而不是Keras.layers.Flatten()。 -
我试过 keras.layers.Input(input_shape=(1,11)) 但它给了我一个错误!
标签: python tensorflow machine-learning keras neural-network