【发布时间】:2021-05-31 22:03:46
【问题描述】:
model = keras.models.Sequential([
keras.layers.Dense(30, activation = "relu", input_shape=[8]),
keras.layers.Dense(100, activation = "relu"),
keras.layers.Dense(1)])
model.compile(loss="mse", optimizer=keras.optimizers.SGD(lr=1e-3))
checkpoint_cb = keras.callbacks.ModelCheckpoint("Model-{epoch:02d}.h5")
history = model.fit(X_train, y_train, epochs=10,
validation_data=(X_valid,y_valid),
callbacks=[checkpoint_cb])
我正在尝试使用回调来拟合模型,但出现以下错误:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 8 but received input with shape [None, 28, 28]
可能的错误是什么?
【问题讨论】:
标签: tensorflow keras neural-network callback artificial-intelligence