未能拟合 CNN 模型

时间:2021-07-10 12:11:58

标签: tensorflow keras jupyter-notebook

我有这列火车,测试形状:

enter image description here

我的模型是:

model = Sequential()
#add model layers
model.add(Conv1D(64, kernel_size=3, activation='relu', input_shape=(X_train.shape[1],1)))  # X_train.shape[1] = No. of Columns
model.add(Conv1D(32, kernel_size=3, activation='relu'))
model.add(Flatten())
model.add(Dense(10, activation='softmax'))

#compile model using accuracy to measure model performance
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

然后我尝试:

#train the model
model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=3)

我收到此错误:

ValueError: Error when checking input: expected conv1d_7_input to have 3 dimensions, but got array with shape (25000, 500)

拜托了,我在这个问题上困扰了好几个小时,无法解决。有人可以帮助我吗?

0 个答案:

没有答案
相关问题