def create_model(n_classes,train_data,val_data,target_dims,batch_size,epochs,optimizer="adam"):
conv_base=MobileNetV2(weights="imagenet",include_top=False,input_shape=target_dims)
model=Sequential()
model.add(conv_base)
model.add(Flatten())
model.add(Dense(256,activation="relu"))
model.add(Dense(64,activation="relu"))
model.add(Dense(n_classes,activation="softmax"))
for layer in conv_base.layers:
layer.trainable=False
model.compile(loss="categorical_crossentropy",optimizer=optimizer,metrics=['acc'])
print("training the model without fine tuning.... \n ")
es=EarlyStopping(monitor='val_loss')
model.fit_generator(train_data,epochs=epochs,
validation_data=val_data,
callbacks=[es])
for layers in conv_base.layers[:150]:
layers.trainable=True
model.compile(loss="categorical_crossentropy",optimizer=optimizer,metrics=['acc'])
print("training the model after fine tuning.... \n ")
model.fit_generator(train_data,epochs=epochs,
validation_data=val_data,
callbacks=[es])
**我的精度在微调后正在降低** enter image description here