0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ファインチューニングでBatch Normalizationを学習させる実験(Batch Normalizationの効果)

Last updated at Posted at 2019-07-21

Batch Normalizationだけをファインチューニングで学習させる

githubでBatch Normalizationレイヤー+全結合層だけを学習しているコードを見たので意味があるんだろうか?検証してみた。

お題は、ファッションサーチファンネル(ファッション画像検索エンジン)を運用するために使っている「男物?女物?」を判定するモデルです。

モデル構築のコード。

    base_model = InceptionV3(
        include_top=False,
        weights="imagenet",
        input_shape=None
    )

    # 全結合層の新規構築
    x = base_model.output
    x = GlobalAveragePooling2D()(x)
    x = Dense(1024, activation='relu')(x)
    predictions = Dense(ccount, activation='softmax')(x)

    # ネットワーク定義
    model = Model(inputs=base_model.input, outputs=predictions)
    
    
    for layer in model.layers[:249]:
        layer.trainable = False

        #ここ
        if layer.name.startswith('batch_normalization'):
            layer.trainable = True
    
    # 250層以降、学習させる
    for layer in model.layers[249:]:
        layer.trainable = True

コードの内容としては・・・
InceptionV3を読み込んで、全結合層をお題に合わせて作り、trainableをFalseにしたりTrueにしたりしている
(249までフリーズするがbatch_normalizationは学習する)

教師データは
男物1173枚、女物1436枚
validation画像は10%にした。

Batch NormalizationレイヤーのtrainableをTrue

上記のコードで学習

mnist-tutorial.png

val loss 0.070が一番小さい値だった。

Batch NormalizationレイヤーのtrainableをFalse

実験内容として「#ここ」とある部分を削除しているだけ

mnist-tutorial.png

val_lossは0.160が一番小さい値だった

結果

trainableをTrueにすると精度が上がる

Batch Normalizationレイヤーの・・ val loss
trainableをTrueにすると 0.070
trainableをFalseにすると 0.160
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?