> For the complete documentation index, see [llms.txt](https://statduck.gitbook.io/statduck/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://statduck.gitbook.io/statduck/recommender-system/lightgcn.md).

# LightGCN

Summarizing of [the paper](https://arxiv.org/pdf/2002.02126.pdf)

Head - LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation.

**Algorithms:**

$$
\mathbf{e}^{k+1}*u=\sum*{i\in N\_u}\dfrac{1}{\sqrt{|N\_u|}\sqrt{|N\_i|}}\mathbf{e}^{(k)}\_i \ \mathbf{e}^{k+1}*i=\sum*{u\in N\_i}\dfrac{1}{\sqrt{|N\_i|}\sqrt{|N\_u|}}\mathbf{e}^{(k)}\_u
$$

The final representation is the form of combined layer embeddings.$$\mathbf{e}*u=\sum^K*{k=0}\alpha\_k \mathbf{e}\_u^{(k)}; ;; \mathbf{e}*i=\sum^K*{k=0}\alpha\_k\mathbf{e}^{(k)}\_i$$&#x20;

The model prediction is defined as the inner product of user and item final representations: $$\hat{y}\_{ui}=\mathbf{e}^T\_u\mathbf{e}\_i$$ . It implies the similarity between the user and item.

Matrix Form:

$$
\mathbf{A}=\begin{bmatrix} \mathbf{0} ;;; ;\mathbf{R} \ \mathbf{R}^T ;; \mathbf{0} \end{bmatrix} , ;; \mathbf{E}^{(k+1)}=(\mathbf{D}^{-1/2}\mathbf{A}\mathbf{D}^{-1/2})\mathbf{E}^{(k)}
$$

* $$\mathbf{R}$$ is a $$M \times N$$ user-item interaction matrix. Each entries 1 if $$u$$ is connected to $$i$$
* $$\mathbf{D}$$is a $$(M+N)\times(M+N)$$ diagonal matrix, in which each entry $$D\_{ii}$$ denotes the number of nonzero entries in the $$i\_{th}$$row vector of $$\mathbf{A}$$
* $$\mathbf{E}$$ is a $$(M+N)\times T$$matrix where $$T$$ is the embedding size.

We easily make this as a code using torch\_geomtric.utils ([reference](https://pytorch-geometric.readthedocs.io/en/latest/_modules/torch_geometric/utils/get_laplacian.html))
