プリンキピア

第14章コンピュータビジョン

14.13.6. Training and Validating the Model14.13.6 モデルを訓練し検証する

Now, we can train and validate the model. All the following hyperparameters can be tuned. For example, we can increase the number of epochs. When lr_period and lr_decay are set to 4 and 0.9, respectively, the learning rate of the optimization algorithm will be multiplied by 0.9 after every 4 epochs. Just for ease of demonstration, we only train 20 epochs here.
英語のヒント
これで、モデルを訓練し検証できる。次のハイパーパラメータはすべて調整できる。たとえば、エポック数を増やせる。lr_periodとlr_decayをそれぞれ4と0.9に設定すると、最適化アルゴリズムの学習率は4エポックごとに0.9倍される。説明しやすくするため、ここでは20エポックだけ訓練する。
devices, num_epochs, lr, wd = d2l.try_all_gpus(), 20, 2e-4, 5e-4
lr_period, lr_decay, net = 4, 0.9, get_net()
net(next(iter(train_iter))[0])
train(net, train_iter, valid_iter, num_epochs, lr, wd, devices, lr_period,
      lr_decay)
train loss 0.654, train acc 0.789, valid acc 0.438
958.1 examples/sec on [device(type='cuda', index=0), device(type='cuda', index=1)]