親愛的讀者,您好:

*下載本書檔案: 請點我
1. 本書的範例程式
2. 加入會員可獲得以下 BONUS:
    1-2-4 節 Bonus 決策樹與隨機森林 Decision Tree & Random Forest
    2-4-4 節 Bonus 反向傳播 Backpropagation

* 歡迎到旗標【從做中學 AI 】粉絲團一起學習討論:
https://www.facebook.com/flaglearningbydoing


初版 1、2 刷更新說明

頁次 刊登日期與更新說明
5-45 2018/6/12 (範例檔 F9379.zip 已更新)
程式 5.23 的執行結果因為 Keras 版本而可能與圖 5.17 有差距, 在此提供 2 種解法:

1. 將 conv_base.trainable = False 註解掉。
2. 餵給 VGG16 的圖片像素值不要壓到 0-1 之間, 將 rescale=1./255 都註解掉。

請在程式 5.23 中做以下的修改:

from keras.applications.imagenet_utils import preprocess_input # 新增這行

train_gen = ImageDataGenerator(
    # rescale=1.0/255, # 註解這行
    preprocessing_function=preprocess_input, # 新增這行
    height_shift_range=0.2,
    width_shift_range=0.2,
    zoom_range=0.2,
    shear_range=0.2,
    rotation_range=40,
    horizontal_flip=True,
    fill_mode='nearest'
    )

#test_datagen = ImageDataGenerator(1./255) # 註解這行
test_datagen = ImageDataGenerator(preprocessing_function=preprocess_input) # 新增這行


top