【发布时间】:2020-10-23 08:06:20
【问题描述】:
我正确地遵循了教程,所以我不知道我做错了什么。 这是我的代码:
model = Sequential([
Conv2D(32, (3,3), padding='same', activation='relu', input_shape=(28,28,1)),
MaxPooling2D((2,2)),
Conv2D(64,(3,3), activation='relu'),
MaxPooling2D((2,2)),
Flatten(),
Dense(128, activation='relu'),
Dense(10)
])
#Compile the model
model.compile(optimizer='adam', loss=tf.keras.losses.SparseCategoricalCrossentropy(), metrics=['accuracy'])
#Train the model
history = model.fit(train_images, train_labels, epochs=10, validation_data=(test_images, test_labels))
ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [32, 28, 28]
【问题讨论】:
标签: tensorflow keras google-colaboratory conv-neural-network