【发布时间】:2019-05-20 18:18:56
【问题描述】:
我正在尝试 Merku 分子活动挑战,并创建了训练和测试数据集。
数据的形状如下:
x_train.shape=(1452, 4306)
y_train.shape=(1452, 1)
x_test.shape=(363, 4306)
y_test.shape=(363, 1)
我使用Dense层来定义模型如下:
model = Sequential()
model.add(Dense(100, activation="relu", input_shape=(4306,)))
model.add(Dense(50, activation="relu"))
model.add(Dense(25, activation="relu"))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(1))
# Compile the model
model.compile(
loss='categorical_crossentropy',
optimizer="adam",
)
model.summary()
# Train the model
model.fit(
x_train,
y_train,
batch_size=300,
epochs=900,
validation_data=(x_test, y_test),
shuffle=True
)
在尝试上述代码时,出现以下错误:
ValueError: Input 0 is incompatible with layer flatten_23: expected min_ndim=3, found ndim=2
我该如何解决这个错误?
【问题讨论】:
-
Like this-model.add(Dense(100, activation = "relu", input_shape=(4306,), batch_size=300, input_size=6252312))
标签: python keras neural-network keras-layer