プリンキピア

第21章推薦システム

21.7.1. Model Architectures21.7.1 モデルの構造

In sequence-aware recommendation system, each user is associated with a sequence of some items from the item set. Let Su=(S1u,...S|Su|u) denotes the ordered sequence. The goal of Caser is to recommend item by considering user general tastes as well as short-term intention. Suppose we take the previous L items into consideration, an embedding matrix that represents the former interactions for time step t can be constructed:
英語のヒント
系列を考慮した推薦システムでは、各利用者は、アイテムの集合から選ばれたいくつかのアイテムの系列と結びついている。Su=(S1u,...S|Su|u)を、順に並べた系列とする。Caserの目標は、利用者の一般的な好みと短期的な意図の両方を考えてアイテムを推薦することである。直前のL個のアイテムを考慮に入れるとすると、時間ステップtでの以前のやりとりを表す埋め込み行列を作れる。
𝐄(u,t)=[𝐪St−Lu,...,𝐪St−2u,𝐪St−1u]⊤,(21.7.1)
where 𝐐∈ℝn×k represents item embeddings and 𝐪i denotes the ith row. 𝐄(u,t)∈ℝL×k can be used to infer the transient interest of user u at time-step t. We can view the input matrix 𝐄(u,t) as an image which is the input of the subsequent two convolutional components.
英語のヒント
ここで𝐐∈ℝn×kはアイテムの埋め込みを表し、𝐪iはそのithの行を表す。𝐄(u,t)∈ℝL×kは、時間ステップtでの利用者uの一時的な関心を推測するのに使える。入力行列𝐄(u,t)は、後に続く二つの畳み込みの構成要素の入力となる画像とみなせる。
The horizontal convolutional layer has d horizontal filters 𝐅j∈ℝh×k,1≤j≤d,h={1,...,L}, and the vertical convolutional layer has d′ vertical filters 𝐆j∈ℝL×1,1≤j≤d′. After a series of convolutional and pool operations, we get the two outputs:
英語のヒント
水平の畳み込み層はd個の水平フィルタ𝐅j∈ℝh×k,1≤j≤d,h={1,...,L}をもち、垂直の畳み込み層はd′個の垂直フィルタ𝐆j∈ℝL×1,1≤j≤d′をもつ。一連の畳み込みとプーリングの演算の後、二つの出力が得られる。
𝐨=HConv(𝐄(u,t),𝐅)𝐨′=VConv(𝐄(u,t),𝐆),(21.7.2)
where 𝐨∈ℝd is the output of horizontal convolutional network and 𝐨′∈ℝkd′ is the output of vertical convolutional network. For simplicity, we omit the details of convolution and pool operations. They are concatenated and fed into a fully connected neural network layer to get more high-level representations.
英語のヒント
ここで𝐨∈ℝdは水平の畳み込みネットワークの出力、𝐨′∈ℝkd′は垂直の畳み込みネットワークの出力である。簡単にするため、畳み込みとプーリングの演算の詳細は省く。これらは連結され、全結合のニューラルネットワークの層に入力されて、より高レベルの表現が得られる。
𝐳=ϕ(𝐖[𝐨,𝐨′]⊤+𝐛),(21.7.3)
where 𝐖∈ℝk×(d+kd′) is the weight matrix and 𝐛∈ℝk is the bias. The learned vector 𝐳∈ℝk is the representation of user’s short-term intent.
英語のヒント
ここで𝐖∈ℝk×(d+kd′)は重み行列、𝐛∈ℝkはバイアスである。学習されたベクトル𝐳∈ℝkは、利用者の短期的な意図の表現である。
At last, the prediction function combines users’ short-term and general taste together, which is defined as:
英語のヒント
最後に、予測関数は利用者の短期的な好みと一般的な好みを組み合わせる。これは次のように定義される。
yˆuit=𝐯i⋅[𝐳,𝐩u]⊤+𝐛i′,(21.7.4)
where 𝐕∈ℝn×2k is another item embedding matrix. 𝐛′∈ℝn is the item specific bias. 𝐏∈ℝm×k is the user embedding matrix for users’ general tastes. 𝐩u∈ℝk is the uth row of P and 𝐯i∈ℝ2k is the ith row of 𝐕.
英語のヒント
ここで𝐕∈ℝn×2kはもう一つのアイテム埋め込み行列である。𝐛′∈ℝnはアイテムに固有のバイアスである。𝐏∈ℝm×kは、利用者の一般的な好みのための利用者埋め込み行列である。𝐩u∈ℝkはPのuthの行であり、𝐯i∈ℝ2kは𝐕のithの行である。
The model can be learned with BPR or Hinge loss. The architecture of Caser is shown below:
英語のヒント
このモデルは、BPRやヒンジ損失で学習できる。Caserの構造を以下に示す。
Fig. 21.7.1図21.7.1
Illustration of the Caser Model
英語のヒント
Caserのモデルの図解
We first import the required libraries.
英語のヒント
まず、必要なライブラリをインポートする。
import random
import mxnet as mx
from mxnet import gluon, np, npx
from mxnet.gluon import nn
from d2l import mxnet as d2l

npx.set_np()