プリンキピア

第4章分類のための線形ニューラルネットワーク

4.4.4. Training4.4.4 訓練

We reuse the fit method defined in Section 3.4 to train the model with 10 epochs. Note that the number of epochs (max_epochs), the minibatch size (batch_size), and learning rate (lr) are adjustable hyperparameters. That means that while these values are not learned during our primary training loop, they still influence the performance of our model, both vis-à-vis training and generalization performance. In practice you will want to choose these values based on the validation split of the data and then, ultimately, to evaluate your final model on the test split. As discussed in Section 3.6.3, we will regard the test data of Fashion-MNIST as the validation set, thus reporting validation loss and validation accuracy on this split.
英語のヒント
3.4節で定義したfitメソッドを使い回して、モデルを10エポック訓練する。エポック数(max_epochs)、ミニバッチの大きさ(batch_size)、学習率(lr)は、調整できるハイパーパラメータであることに注意してほしい。つまり、これらの値は主たる訓練ループのなかでは学習されないが、それでも訓練と汎化の両方の性能について、モデルの性能に影響を与える。実際には、これらの値はデータの検証用の分割にもとづいて選び、最後に、最終的なモデルをテスト用の分割で評価することになる。3.6.3節で論じたように、Fashion-MNISTのテストデータを検証集合とみなし、この分割で検証損失と検証の正解率を報告する。
data = d2l.FashionMNIST(batch_size=256)
model = SoftmaxRegressionScratch(num_inputs=784, num_outputs=10, lr=0.1)
trainer = d2l.Trainer(max_epochs=10)
trainer.fit(model, data)