プリンキピア

第21章推薦システム

21.9.5. Train the Model21.9.5 モデルを訓練する

Afterwards, we train the model. The learning rate is set to 0.02 and the embedding size is set to 20 by default. The Adam optimizer and the SigmoidBinaryCrossEntropyLoss loss are used for model training.
英語のヒント
その後、モデルを訓練する。既定では、学習率は0.02、埋め込みの大きさは20に設定する。モデルの訓練には、最適化手法Adamと損失SigmoidBinaryCrossEntropyLossを使う。
devices = d2l.try_all_gpus()
net = FM(train_data.field_dims, num_factors=20)
net.initialize(init.Xavier(), ctx=devices)
lr, num_epochs, optimizer = 0.02, 30, 'adam'
trainer = gluon.Trainer(net.collect_params(), optimizer,
                        {'learning_rate': lr})
loss = gluon.loss.SigmoidBinaryCrossEntropyLoss()
d2l.train_ch13(net, train_iter, test_iter, loss, trainer, num_epochs, devices)
loss 0.504, train acc 0.283, test acc 0.277
44217.6 examples/sec on [gpu(0), gpu(1)]