I trained the constitutional network using the transfer of training from the ResNet50 to keras, as follows.
base_model = applications.ResNet50(weights='imagenet', include_top=False, input_shape=(333, 333, 3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(1024, activation='relu')(x)
x = Dense(256, activation='relu')(x)
predictions = Dense(y_train.shape[1], activation='softmax')(x)
model = Model(input=base_model.input, output=predictions)
model.compile(loss='categorical_crossentropy', optimizer=optimizers.SGD(lr=1e-4, momentum=0.9),
metrics=['accuracy'])
model.summary()
After learning the model below, I want to save the model.
history = model.fit_generator(
train_datagen.flow(x_train, y_train, batch_size=batch_size),
steps_per_epoch=600,
epochs=epochs,
callbacks=callbacks_list
)
I cannot use the save_model () function from keras models, since the model is of type Model here. To save the model, I used the save () function. But later, when I downloaded the model and checked the model, it behaved like an unprepared model. I think the weights were not saved. What happened.? How to save this model.?
source
share