Collaborative Deep Learning for Recommender Systems : Practice
source : https://github.com/js05212/CDL.git
paper : Collaborative Deep Learning for Recommender Systems
example/cdl_main.m이 시작점.
첫파일부터 모르는 함수(feature)등장해서 보니 undocumented라고 함.[3] 핵심 알고리즘과는 전혀무관.
MXNet for CDL
https://github.com/js05212/MXNet-for-CDL.git
노트북(collaborative-dl.ipynb)실행.
cdl.py도 내용이 동일하다
MXNet
mxnet[4] implementation, so pip install mxnet
실행에 필요한 파일(PGM-CDL.png 이런거)은 https://github.com/dmlc/web-data/tree/master/mxnet/cdl 여기 있다. mxnet의 일부. 다운따로 받을필요는 없고.
계산
Loss는 다음과 같다
$$\begin{align}
\mathscr{L}=&-\frac{\lambda_u}{2}\sum_i \|u_i\|_2^2-\frac{\lambda_w}{2}\sum_l(\|W_l\|_F^2+\|b_l\|_2^2) \nonumber \\
&-\frac{\lambda_v}{2}\sum_j\|v_j-f_e(X_{0,j*},W^+)^T\|_2^2 \nonumber \\
&-\frac{\lambda_n}{2}\sum_j\|f_r(X_{0,j*},W^+)-X_{c,j*}\|_2^2 \nonumber \\
&-\sum_{i,j}\frac{C_{ij}}{2}(R_{ij}-u_i^Tv_j)^2,\nonumber \\
\end{align}$$
여기서 hyper parameter를 모두 2로 두고, 알아보기 쉽게 \(f_e, f_r\)도 간략히 하고(\(f_e\)는 dimension이 작은 중간결과, \(f_r\)은 dimension동일한 최종결과), confidence parameter(\(C_{ij}\))를 1 or 0으로 두면,
$$\begin{align}
\mathscr{L}=&-\sum_i \|u_i\|_2^2-\sum_l(\|W_l\|_F^2+\|b_l\|_2^2) \nonumber \\
&-\sum_j\|v_j-f_e^T\|_2^2 \nonumber \\
&-\sum_j\|f_r-X_{c,j*}\|_2^2 \nonumber \\
&-\sum_{i,j}\frac{C_{ij}}{2}(R_{ij}-u_i^Tv_j)^2,\nonumber \\
\end{align}$$
마지막 term이 좀 특이하다. weighted matrix factorization[1]에서는 \(C_{ij}\)붙일 때 \(R_{ij}\)를 0 아니면 1로 바꾸는데 여기는 그냥 씀. 이렇게 써놔도 뭔가 손에 잡히는 insight가 없네...
기타
- solver.py의 다음부분이 if nd때문에 계속 에러나서, if nd is not None으로 바꿈.
update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_arrays) if nd}
- BCD_one.py, cal_precision.py, collaborative-dl.py, mf.py, show_recommendation.py의 .A1을 .ravel()로 수정.
numpy.linalg.pinv(a, rcond=1e-15)
- Compute the Moore–Penrose pseudoinverse of a matrix.
- Calculate the generalized inverse of a matrix using its singular-value decomposition (SVD) and including all large singular values.
Q
- BCD(http://www.math.ucla.edu/~wotaoyin/papers/bcu/) for MF
- U is the user latent matrix, V is the item latent matrix.
- latent matrix : https://www.slideshare.net/sscdotopen/latent-factor-models-for-collaborative-filtering (cont.)
- latent matrix : https://www.slideshare.net/sscdotopen/latent-factor-models-for-collaborative-filtering (cont.)