第21章推薦システム
21.9.2. An Efficient Optimization Criterion21.9.2 効率のよい最適化の基準
Optimizing the factorization machines in a straight forward method leads to a complexity of as all pairwise interactions require to be computed. To solve this inefficiency problem, we can reorganize the third term of FM which could greatly reduce the computation cost, leading to a linear time complexity (). The reformulation of the pairwise interaction term is as follows:
英語のヒント
因子分解機を素直な方法で最適化すると、すべてのペアごとの相互作用を計算する必要があるので、計算量はになる。この非効率の問題を解くため、FMの三番目の項を組み直せる。これにより計算コストが大きく減り、線形の時間計算量()になる。ペアごとの相互作用の項は、次のように定式化し直せる。
(21.9.2)
With this reformulation, the model complexity are decreased greatly. Moreover, for sparse features, only non-zero elements needs to be computed so that the overall complexity is linear to the number of non-zero features.
英語のヒント
このように定式化し直すことで、モデルの計算量は大きく減る。さらに、疎な特徴については、0でない要素だけを計算すればよいので、全体の計算量は0でない特徴の数に対して線形になる。
To learn the FM model, we can use the MSE loss for regression task, the cross-entropy loss for classification tasks, and the BPR loss for ranking task. Standard optimizers such as stochastic gradient descent and Adam are viable for optimization.
英語のヒント
FMのモデルを学習するには、回帰のタスクにはMSE損失、分類のタスクには交差エントロピー損失、ランキングのタスクにはBPR損失を使える。最適化には、確率的勾配降下法やAdamのような標準的な最適化手法が使える。
import os
from mxnet import gluon, init, np, npx
from mxnet.gluon import nn
from d2l import mxnet as d2l
npx.set_np()