私はここにある論文に従っており、論文に記載されている確率的勾配降下法 (SGD) の代わりにバッチ勾配降下法 (BGD) を実行しようとしています。
SGDの場合、私が収集するのは、これを行うことです(疑似コード):
for each user's actual rating {
1. calculate the difference between the actual rating
and the rating calculated from the dot product
of the two factor matrices (user vector and item vector).
2. multiply answer from 1. by the item vector
corresponding to that rating.
3. alter the initial user vector by the figure
calculated in 2. x by lambda e.g.:
userVector = userVector + lambda x answer from 2.
}
Repeat for every user
Do the same for every Item, except in 2. multiply by the user vector instead of the item vector
Go back to start and repeat until some breakpoint
BGDの場合、私がしたことは次のとおりです。
for each user {
1. sum up all their prediction errors e.g.
real rating - (user vector . item vector) x item vector
2. alter the user vector by the figure calculated in 1. x by lambda.
}
Then repeat for the Items exchanging item vector in 2. for user vector
これは理にかなっているように思えますが、さらに読むと、BGD について混乱してしまいました。1 つの変更を行うためだけに、BGD はデータセット全体で反復する必要があると書かれています。これは、私が行ったことのように、その特定のユーザーに関連するデータセット全体を意味しますか、それとも文字通りデータセット全体を意味しますか?
データセット全体を通過する実装を作成し、すべての予測エラーを合計し、その数値を使用してすべてのユーザー ベクトルを更新します (したがって、すべてのユーザー ベクトルは同じ量だけ更新されます! )。ただし、ラムダ レートが 0.002 の場合でも、最小値には近づかず、急速に変動します。平均誤差 12,500 から 1.2、さらに -539 などになる可能性があります。最終的には、数値が無限大に近づき、プログラムが失敗します。
この背後にある数学に関するヘルプは素晴らしいでしょう。