Hello there,
First off, love the course!
I’ve been having trouble with running .fit or .predict on my model for the State Farm competition. I’m just using the simplest model from the lesson to demonstrate the error, but when I have:
model = Sequential([
BatchNormalization(axis=1, input_shape=(3,224,224)),
Flatten(),
Dense(10, activation=‘softmax’)
])
I am able to successfully run:
model.compile(Adam(lr=0.0001), loss=‘categorical_crossentropy’, metrics=[‘accuracy’])
model.fit_generator(batches, batches.nb_sample, nb_epoch=1, validation_data=val_batches,
nb_val_samples=val_batches.nb_sample)
model_train_feat = model.predict_generator(batches, batches.nb_sample)
model_val_feat = model.predict_generator(val_batches, val_batches.nb_sample)
However, when I run:
model.fit(model_train_feat, trn_labels, batch_size=batch_size, nb_epoch=1,
validation_data=(model_val_feat, val_labels))
I get:
Error when checking model input: expected batchnormalization_input_8 to have 4 dimensions, but got array with shape (1500, 10)
I have run model.summary and first layer is this:
Layer (type) Output Shape Param # Connected to
batchnormalization_28 (BatchNorm (None, 3, 224, 224) 896 batchnormalization_input_8[0][0]
I don’t understand why it is expecting 4 dimensions, or how to change this. I have spent several hours reading forums and documentation but can’t seem to figure it out. Any advice would be much appreciated!
Thank you!