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

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

 

 

输出结果

 

 

False:    input_1
False:    block1_conv1
False:    block1_conv2
False:    block1_pool
False:    block2_conv1
False:    block2_conv2
False:    block2_pool
False:    block3_conv1
False:    block3_conv2
False:    block3_conv3
False:    block3_pool
True:    block4_conv1
True:    block4_conv2
True:    block4_conv3
True:    block4_pool
True:    block5_conv1
True:    block5_conv2
True:    block5_conv3
True:    block5_pool


Epoch 1/20
100/100 [==============================] - 814s 8s/step - loss: 0.4626 - categorical_accuracy: 0.8095 - val_loss: 0.5332 - val_categorical_accuracy: 0.7717
Epoch 2/20
100/100 [==============================] - 823s 8s/step - loss: 0.4662 - categorical_accuracy: 0.8150 - val_loss: 0.5236 - val_categorical_accuracy: 0.7755
Epoch 3/20
100/100 [==============================] - 824s 8s/step - loss: 0.4506 - categorical_accuracy: 0.8140 - val_loss: 0.5153 - val_categorical_accuracy: 0.7830
Epoch 4/20
100/100 [==============================] - 821s 8s/step - loss: 0.4491 - categorical_accuracy: 0.8170 - val_loss: 0.5236 - val_categorical_accuracy: 0.7717
Epoch 5/20
100/100 [==============================] - 820s 8s/step - loss: 0.4612 - categorical_accuracy: 0.8150 - val_loss: 0.5244 - val_categorical_accuracy: 0.7698
Epoch 6/20
100/100 [==============================] - 824s 8s/step - loss: 0.4440 - categorical_accuracy: 0.8215 - val_loss: 0.5078 - val_categorical_accuracy: 0.7849
Epoch 7/20
100/100 [==============================] - 824s 8s/step - loss: 0.4339 - categorical_accuracy: 0.8200 - val_loss: 0.5070 - val_categorical_accuracy: 0.7906
Epoch 8/20
100/100 [==============================] - 820s 8s/step - loss: 0.4188 - categorical_accuracy: 0.8335 - val_loss: 0.5068 - val_categorical_accuracy: 0.7887
Epoch 9/20
100/100 [==============================] - 823s 8s/step - loss: 0.4307 - categorical_accuracy: 0.8345 - val_loss: 0.5192 - val_categorical_accuracy: 0.7792
Epoch 10/20
100/100 [==============================] - 820s 8s/step - loss: 0.4432 - categorical_accuracy: 0.8180 - val_loss: 0.4945 - val_categorical_accuracy: 0.7887
Epoch 11/20
100/100 [==============================] - 824s 8s/step - loss: 0.4171 - categorical_accuracy: 0.8295 - val_loss: 0.5012 - val_categorical_accuracy: 0.7887
Epoch 12/20
100/100 [==============================] - 820s 8s/step - loss: 0.4071 - categorical_accuracy: 0.8335 - val_loss: 0.5064 - val_categorical_accuracy: 0.7830
Epoch 13/20
100/100 [==============================] - 824s 8s/step - loss: 0.4164 - categorical_accuracy: 0.8200 - val_loss: 0.5065 - val_categorical_accuracy: 0.7811
Epoch 14/20
100/100 [==============================] - 825s 8s/step - loss: 0.4060 - categorical_accuracy: 0.8350 - val_loss: 0.5021 - val_categorical_accuracy: 0.7830
Epoch 15/20
100/100 [==============================] - 821s 8s/step - loss: 0.3948 - categorical_accuracy: 0.8390 - val_loss: 0.4985 - val_categorical_accuracy: 0.7925
Epoch 16/20
100/100 [==============================] - 824s 8s/step - loss: 0.3724 - categorical_accuracy: 0.8570 - val_loss: 0.4909 - val_categorical_accuracy: 0.7981
Epoch 17/20
100/100 [==============================] - 821s 8s/step - loss: 0.4084 - categorical_accuracy: 0.8305 - val_loss: 0.4888 - val_categorical_accuracy: 0.8000
Epoch 18/20
100/100 [==============================] - 824s 8s/step - loss: 0.3975 - categorical_accuracy: 0.8400 - val_loss: 0.4907 - val_categorical_accuracy: 0.8019
Epoch 19/20
100/100 [==============================] - 822s 8s/step - loss: 0.4093 - categorical_accuracy: 0.8430 - val_loss: 0.5156 - val_categorical_accuracy: 0.7792
Epoch 20/20
100/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 = trainable
print_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()  

 

 

 

 

 

 

发布了1646 篇原创文章 · 获赞 7295 · 访问量 1321万+

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 代码科技 设计师: Amelia_0503

分享到微信朋友圈

×

扫一扫,手机浏览