Skip to content

[ch04]各epochごとにすべての訓練データを見るようにする #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sno-windy
Copy link

概要

4.5 学習アルゴリズムの実装 における
ニューラルネットワークのミニバッチ学習ループを iters_num から epoch, iter_per_epoch に変更し、
毎epochで全訓練データを一度ずつ使用するようにしました。

変更点

  • np.random.choicenp.random.permutationslice を用いた非復元抽出に変更
  • iters_num ベース → epoch ベースのループに書き換え
  • iter_per_epoch = max(train_size / batch_size, 1) の結果が小数点以下を含むと正しくコードが動かないので修正

背景

従来の choice によるサンプリングでは、同一データの重複使用や未使用のままのデータが発生し、
全体の損失最小化や収束性に悪影響を及ぼす可能性がありました。

動作確認

ローカルでの動作確認を行いました。

 ❯ python train_neuralnet.py
train acc, test acc | 0.7893833333333333, 0.7959
train acc, test acc | 0.8759833333333333, 0.8793
train acc, test acc | 0.89965, 0.9029
train acc, test acc | 0.9085166666666666, 0.9105
train acc, test acc | 0.9157333333333333, 0.9169
train acc, test acc | 0.9207666666666666, 0.9214
train acc, test acc | 0.9244666666666667, 0.9257
train acc, test acc | 0.9285333333333333, 0.9276
train acc, test acc | 0.9321666666666667, 0.9311
train acc, test acc | 0.9351833333333334, 0.9341
train acc, test acc | 0.9375666666666667, 0.9367
train acc, test acc | 0.9402666666666667, 0.9395
train acc, test acc | 0.9425166666666667, 0.9409
train acc, test acc | 0.9444, 0.9423
train acc, test acc | 0.9466666666666667, 0.9454
train acc, test acc | 0.9480833333333333, 0.9455
train acc, test acc | 0.9496666666666667, 0.9473
train acc, test acc | 0.95175, 0.9479
train acc, test acc | 0.9527333333333333, 0.9489
train acc, test acc | 0.9542166666666667, 0.9498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant