プリンキピア

第21章推薦システム

21.7.5. Train the Model21.7.5 モデルを訓練する

Now, let’s train the model. We use the same setting as NeuMF, including learning rate, optimizer, and k, in the last section so that the results are comparable.
英語のヒント
では、モデルを訓練しよう。結果を比べられるように、学習率、最適化手法、kを含め、前の節のNeuMFと同じ設定を使う。
devices = d2l.try_all_gpus()
net = Caser(10, num_users, num_items, L)
net.initialize(ctx=devices, force_reinit=True, init=mx.init.Normal(0.01))
lr, num_epochs, wd, optimizer = 0.04, 8, 1e-5, 'adam'
loss = d2l.BPRLoss()
trainer = gluon.Trainer(net.collect_params(), optimizer,
                        {"learning_rate": lr, 'wd': wd})

# Running takes > 1h (pending fix from MXNet)
# d2l.train_ranking(net, train_iter, test_iter, loss, trainer, test_seq_iter, num_users, num_items, num_epochs, devices, d2l.evaluate_ranking, candidates, eval_step=1)
[22:04:02] ../src/storage/storage.cc:196: Using Pooled (Naive) StorageManager for GPU
[22:04:02] ../src/storage/storage.cc:196: Using Pooled (Naive) StorageManager for GPU