DL之VGG16:基于VGG16(Keras)利用Knifey-Spoony数据集对网络架构FineTuning

DL之VGG16:基于VGG16(Keras)利用Knifey-Spoony数据集对网络架构FineTuning输出结果

False: input_1False: block1_conv1False: block1_conv2False: block1_poolFalse: block2_conv1False: block2_conv2False: block2_poolFalse: block3_conv1False: block3_conv2False: block3_conv3False: block3_poolTrue: block4_conv1True: block4_conv2True: block4_conv3True: block4_poolTrue: block5_conv1True: block5_conv2True: block5_conv3True: block5_poolEpoch 1/20100/100 [==============================] - 814s 8s/step - loss: 0.4626 - categorical_accuracy: 0.8095 - val_loss: 0.5332 - val_categorical_accuracy: 0.7717Epoch 2/20100/100 [==============================] - 823s 8s/step - loss: 0.4662 - categorical_accuracy: 0.8150 - val_loss: 0.5236 - val_categorical_accuracy: 0.7755Epoch 3/20100/100 [==============================] - 824s 8s/step - loss: 0.4506 - categorical_accuracy: 0.8140 - val_loss: 0.5153 - val_categorical_accuracy: 0.7830Epoch 4/20100/100 [==============================] - 821s 8s/step - loss: 0.4491 - categorical_accuracy: 0.8170 - val_loss: 0.5236 - val_categorical_accuracy: 0.7717Epoch 5/20100/100 [==============================] - 820s 8s/step - loss: 0.4612 - categorical_accuracy: 0.8150 - val_loss: 0.5244 - val_categorical_accuracy: 0.7698Epoch 6/20100/100 [==============================] - 824s 8s/step - loss: 0.4440 - categorical_accuracy: 0.8215 - val_loss: 0.5078 - val_categorical_accuracy: 0.7849Epoch 7/20100/100 [==============================] - 824s 8s/step - loss: 0.4339 - categorical_accuracy: 0.8200 - val_loss: 0.5070 - val_categorical_accuracy: 0.7906Epoch 8/20100/100 [==============================] - 820s 8s/step - loss: 0.4188 - categorical_accuracy: 0.8335 - val_loss: 0.5068 - val_categorical_accuracy: 0.7887Epoch 9/20100/100 [==============================] - 823s 8s/step - loss: 0.4307 - categorical_accuracy: 0.8345 - val_loss: 0.5192 - val_categorical_accuracy: 0.7792Epoch 10/20100/100 [==============================] - 820s 8s/step - loss: 0.4432 - categorical_accuracy: 0.8180 - val_loss: 0.4945 - val_categorical_accuracy: 0.7887Epoch 11/20100/100 [==============================] - 824s 8s/step - loss: 0.4171 - categorical_accuracy: 0.8295 - val_loss: 0.5012 - val_categorical_accuracy: 0.7887Epoch 12/20100/100 [==============================] - 820s 8s/step - loss: 0.4071 - categorical_accuracy: 0.8335 - val_loss: 0.5064 - val_categorical_accuracy: 0.7830Epoch 13/20100/100 [==============================] - 824s 8s/step - loss: 0.4164 - categorical_accuracy: 0.8200 - val_loss: 0.5065 - val_categorical_accuracy: 0.7811Epoch 14/20100/100 [==============================] - 825s 8s/step - loss: 0.4060 - categorical_accuracy: 0.8350 - val_loss: 0.5021 - val_categorical_accuracy: 0.7830Epoch 15/20100/100 [==============================] - 821s 8s/step - loss: 0.3948 - categorical_accuracy: 0.8390 - val_loss: 0.4985 - val_categorical_accuracy: 0.7925Epoch 16/20100/100 [==============================] - 824s 8s/step - loss: 0.3724 - categorical_accuracy: 0.8570 - val_loss: 0.4909 - val_categorical_accuracy: 0.7981Epoch 17/20100/100 [==============================] - 821s 8s/step - loss: 0.4084 - categorical_accuracy: 0.8305 - val_loss: 0.4888 - val_categorical_accuracy: 0.8000Epoch 18/20100/100 [==============================] - 824s 8s/step - loss: 0.3975 - categorical_accuracy: 0.8400 - val_loss: 0.4907 - val_categorical_accuracy: 0.8019Epoch 19/20100/100 [==============================] - 822s 8s/step - loss: 0.4093 - categorical_accuracy: 0.8430 - val_loss: 0.5156 - val_categorical_accuracy: 0.7792Epoch 20/20100/100 [==============================] - 824s 8s/step - loss: 0.4007 - categorical_accuracy: 0.8270 - val_loss: 0.4917 - val_categorical_accuracy: 0.7962 设计思路

核心代码conv_model.trainable = True for layer in conv_model.layers: # Boolean whether this layer is trainable. trainable = ('block5' in layer.name or 'block4' in layer.name) # Set the layer's bool. layer.trainable = trainableprint_layer_trainable() optimizer_fine = Adam(lr=1e-7)FT_history = VGG16_TL_model.fit_generator(generator=generator_train, epochs=epochs, steps_per_epoch=steps_per_epoch, class_weight=class_weight, validation_data=generator_test, validation_steps=steps_test)print(FT_history)plot_training_history(FT_history) #VGG16_FT_model_result = VGG16_TL_model.evaluate_generator(generator_test, steps=steps_test)print("Test-set classification accuracy: {0:.2%}".format(VGG16_FT_model_result[1])) example_errors()

(0)

相关推荐