I would like to use the imagnet weights as initialization to retrain the complete model in new data. Is there an easy way to do this?
model = ResNet50(include_top=True, weights=None)
model.compile(loss='categorical_crossentropy', optimizer='SGD', metrics=['accuracy'])
checkpointer = ModelCheckpoint(filepath='best_VGG_all_dataset_spatial_features', verbose=1, save_best_only=True)
model.fit(train_data, train_labels, nb_epoch=50, batch_size=32,
verbose=1, shuffle=True, validation_data=(validation_data, validation_labels), callbacks=[checkpointer])
But doesn't seem to work. I get the following error:
Exception: Error when checking model target: expected fc1000 to have shape (None, 1000) but got array with shape (240, 1)
I need a way to easily add an fc(nb_classes) layer at the end of the model.