From ec27c8eb10269fb038176cff3faae3647b02df47 Mon Sep 17 00:00:00 2001 From: hutuxian Date: Tue, 28 May 2019 11:30:11 +0800 Subject: [PATCH] Recommender system show formula with picture (#727) * add formula pic * Add some notes and formula pictures * update README.cn.md --- 05.recommender_system/README.cn.md | 20 +++++++++++++++++--- 05.recommender_system/image/formula1.png | Bin 0 -> 9747 bytes 05.recommender_system/image/formula2.png | Bin 0 -> 8303 bytes 05.recommender_system/image/formula3.png | Bin 0 -> 5851 bytes 05.recommender_system/index.cn.html | 20 +++++++++++++++++--- 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 05.recommender_system/image/formula1.png create mode 100644 05.recommender_system/image/formula2.png create mode 100644 05.recommender_system/image/formula3.png diff --git a/05.recommender_system/README.cn.md b/05.recommender_system/README.cn.md index 372e47d..239cc9b 100644 --- a/05.recommender_system/README.cn.md +++ b/05.recommender_system/README.cn.md @@ -2,6 +2,14 @@ 本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/05.recommender_system),初次使用请您参考[Book文档使用说明](https://github.com/PaddlePaddle/book/blob/develop/README.cn.md#运行这本书)。 +### 说明: ### +1. 硬件环境要求: +本文可支持在CPU、GPU下运行 +2. Docker镜像支持的CUDA/cuDNN版本: +如果使用了Docker运行Book,请注意:这里所提供的默认镜像的GPU环境为 CUDA 8/cuDNN 5,对于NVIDIA Tesla V100等要求CUDA 9的 GPU,使用该镜像可能会运行失败。 +3. 文档和脚本中代码的一致性问题: +请注意:为使本文更加易读易用,我们拆分、调整了train.py的代码并放入本文。本文中代码与train.py的运行结果一致,可直接运行[train.py](https://github.com/PaddlePaddle/book/blob/develop/05.recommender_system/train.py)进行验证。 + ## 背景介绍 在网络技术不断发展和电子商务规模不断扩大的背景下,商品数量和种类快速增长,用户需要花费大量时间才能找到自己想买的商品,这就是信息超载问题。为了解决这个难题,个性化推荐系统(Recommender System)应运而生。 @@ -54,7 +62,9 @@ YouTube是世界上最大的视频上传、分享和发现网站,YouTube个性 对于一个用户$U$,预测此刻用户要观看的视频$\omega$为视频$i$的概率公式为: -$$P(\omega=i|u)=\frac{e^{v_{i}u}}{\sum_{j \in V}e^{v_{j}u}}$$ +

+
+

其中$u$为用户$U$的特征表示,$V$为视频库集合,$v_i$为视频库中第$i$个视频的特征表示。$u$和$v_i$为长度相等的向量,两者点积可以通过全连接层实现。 @@ -83,11 +93,15 @@ $$P(\omega=i|u)=\frac{e^{v_{i}u}}{\sum_{j \in V}e^{v_{j}u}}$$ 其次,进行卷积操作:把卷积核(kernel)$w\in\mathbb{R}^{hk}$应用于包含$h$个词的窗口$x_{i:i+h-1}$,得到特征$c_i=f(w\cdot x_{i:i+h-1}+b)$,其中$b\in\mathbb{R}$为偏置项(bias),$f$为非线性激活函数,如$sigmoid$。将卷积核应用于句子中所有的词窗口${x_{1:h},x_{2:h+1},\ldots,x_{n-h+1:n}}$,产生一个特征图(feature map): -$$c=[c_1,c_2,\ldots,c_{n-h+1}], c \in \mathbb{R}^{n-h+1}$$ +

+
+

接下来,对特征图采用时间维度上的最大池化(max pooling over time)操作得到此卷积核对应的整句话的特征$\hat c$,它是特征图中所有元素的最大值: -$$\hat c=max(c)$$ +

+
+

#### 融合推荐模型概览 diff --git a/05.recommender_system/image/formula1.png b/05.recommender_system/image/formula1.png new file mode 100644 index 0000000000000000000000000000000000000000..e3923ba2ec0080f0b4733f2781fff946ce076655 GIT binary patch literal 9747 zcmZX3WmsHI(l!hPCpZLWkl-F%0u1iX;K75t26va>1a}!U!QI`0JHaJDaEEX5?7q8u zUEld}PD@F5pRVfayCReorO;7`P+(wS&}F2>RbgOY#i3$hAHMP4y50Fg0e(U3*^L&KW@ z)}j*dcoM1Qn>sMssK(trl#4a2LzKCYs5it6XMnhx$MxIw$Mxn7Q{UU2v2@PF^s`4q zm=U-Xk$8krnD~iF+|Y+6&U_PN!aGAB>;_^n=t;%Hm~lF4&*VCC$Yoo zRerB8of%AFjK**@cm9-WPi#rBWSFT~rM>D!hxM`IhRIq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7fIe|jAW z^{4Nv6SXGQB7*JFP*!D7R@seOnBfj-fP#$UovJ^%@t(TMvbY@2^1;s_*U_94 zbf19(kEn(P;J*QWNnyn=zLjb;fH_bT!J<`;5X+y^@8#*fY#kOg=DNFS^FYMw_B6}Y z_h2f|ZX}6*9Y{I1PjVR8Ts*KP>UOfycS{h ze;?o8o<`g`wTyuPMU(QrTdZi;@_~j8j@x>!}U3ruK%9j&;Fd&gpoz}O#orM)T z_7noc3eJQ8=7i}X8^cv zqo|&&^K<^qDdf6A(Ri@HS#r!QG?g$C4c%iLa5ihifKZVW3Mf+Tw$4ag2F+F^5km72 zW(bQdJkWf@vM3Z~KWWqAR{aY&b3(Hcqi8j*_E3bgJ_ssc*|XZF5UNVq9Gas@A^dc_ r4i#;M2o+F&X|N=X4%Iq_^h6Gcy$VVlu%Gyw6O)lp6t5Ed6!`xD3NT|L literal 0 HcmV?d00001 diff --git a/05.recommender_system/image/formula2.png b/05.recommender_system/image/formula2.png new file mode 100644 index 0000000000000000000000000000000000000000..595205bf7af6e86ae02baca4f97c3439283a57f9 GIT binary patch literal 8303 zcmch5Wmr`2*7txk(hAZr2#Cbc-HoJ5clS^d1JaE&NT(p(-3`*+A>GZ;{f>XnbI!T0 z_xb$n5Bs`f^S0bpn-1K(FvR@2lW9ni$f8K-=DxomftU5FW)aWtQdP@6KagFrRnEznlcABCd=U)lm72#hF>_`O^>ZK_IG>zM zP&~8$j)D6WL%V0ogZGw4qxdcAXtBuxN;-cuMR?8r^HRh!c+X;eo~L?TQU?DnP~r0P zeSG7RUgv|qgh&lV! z_c2Evx=+aDRv4vyn0N3t0ju7nSZkxV@zzMI5JbR))s8z-9Uw{#DRVfD5#Mz9hWRtO zx-k5NH|BS5Ubn!P-l&>s7fwGR0)jANhPOsto_YWgqT0eIL5Yn1QB{k~IRNE5IIGEnmM5kh_8 zGnL*UeG7`A5PTarBTW25H2=+eKTMIDvC%QYU7#cBz7Lt`;~2^X{vA9OGh%L+WjUEO z(qe~Axey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FqRFI*(k70p?J|+QYb21Og^!)i}+bW8xIX3>7zg?1DCn_;oB0uxnmfaZSnk3WY zg0+@z0aKYC3vf?OW_6_rY2+xJ2E6RV!dCL@*zCKT(*h{={P;8<^B zEL+83f3=2m7^rj(?PL|Z>=r}F2*B5T=hh?QML>NmwN5P9ME2`wpWn&6C!U98Q^`Zehi#cQgu@08O-4t?WTo zDnDdu(@BoVu^k>c3@@WvI3hm_Nr++e8^s&+cfgFWR`w>-`cm@@KqNbBSmmjeN$f&o zB*t|Ue>Jlmdh-6k8+nt?@6OeNSbNgGZvjtyi7(&Qx znl=@yh!@ov7TOp@nFL+Ebu@tvA9Z&_FIAvjxY@%{sA$^RriW^lv?fmn4cc9AP=98+ zcvBb<`i=?|R}5kuc)rVTst##R$MPpAvbQ4xYZ}&beDB7CPwDG`Oi{!#;4Yv~4CbF%(^I8{(k3$9}gbAC7VmjB;fxW?li0^nD`j?#hmv1l#+bRy`=_g>G zE6m6r`f0I|h2;U8?Mf3@l!;|<#YsS&=(08Q5H2^~NUKb_T5~U%w+Dw3P9_?f^tvE^ z5wS|0)4Pr(-jJou7_|y=rn7EBg_i9NL5$PsXwFS;)Orq2{DSZ+1h{Fw`*nA6T zRVFY!sBy~eaIo}*VNP9RA-@fCLzB5Tmd3*>mT{qxF~N+Viu)~Hb54JT)wTBv%wW5! z#uPBM3)kep`(Iv|L>D{P1PP zk|`43aJQrcCr{V9E(1c%#Y`q(|A3w423_n18F^LOxj*$8SjY7*YOoSDqKQw@+TOksW6Dq6FZa%v3lyfk>Tyc7j4wTbFi^5#==k{ zLLzzET!%4^i0v`D%UthCcLoRUW^nR}d_5 z%tU#9r@AdE!hf_ndf^DR2{1?N@ uCxT&2Dv{oGCx3CPF;1Am|62omo&lc<*pF_RSEl~ptuhh{;-#YczW)z|O1tm? literal 0 HcmV?d00001 diff --git a/05.recommender_system/image/formula3.png b/05.recommender_system/image/formula3.png new file mode 100644 index 0000000000000000000000000000000000000000..0443b979354d02881a10b332399a18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2wLw^rXc-{|3x{tY6*82c=aaf>ZdG^uZ=TcK#A z-qo5a`Wm&~_aLkNWNVlyJ_=pfBOm#!O_%w_{qLLM(18T@ZfgA{NUM+PcV3ld* zD%+Q4G2HpxmH29!^h}~2v?CC^c9s+YXv|Z+Qe(YwS36oNyzt328M?#bh+!@_Z;iy` z6SZ}QN}-D}#CKaXfFNQIA%OfY0%Lz?jR)BO)Znq(jCy zQj{=1>d4KJEcv*}S|<~ymJgZK7&qiYG+#)$gyixy(yJv@@o#(a)VYa_3I_M^6WLy| zl&rU9NGCqp=S(RO>#SEZDl(JK2n?DtZSbid2ksp@dLxCj-uvF_Sc7&mFH9Y;H@$KjHs)m%Jms-!S(Bckd%|40(INrBJx$y!LD z51!W>BCRK)+a@+l*;G+XdAZ1&wjZS8%F3s(BHzI>tD})tOGpRdGHV_M9OP z8Rr3!nF=QD#CV7oV?*R(VKH>vI}coxj9&x{!+|lB(5PT$Z^BToZ6k&>@^3)*ny#S`LCVE>sA=p#OG*m?hyrU%GVaO9Doa%XW%eEJx z`|@y@!K~gzHa3DL8#Z+bMYkFhSfAoue~+(ub85_^Wuetdj2=9!*Dm}8N9`-q9Tce@ zHuStwo}V2KJkgI29pD8GveObXEII|5Z+RTf#*5^=23{+BT)~ktBkj}=+}C(Zk5FK zedrL@1~i6@NM4L10hozpI6nGCdG}2-<2b*%1|68_lCaYqzd{a};ghT|t@i-wOjSy^ zzxImD-DaSNhLux(B~w2b2Q(`YFPc_)>k*=TAKZda-&33AVAl`z^?)%~qTr&UZk3+1Kz*q5AVF}i3D94txR^B#fV zdF(&_dJ-}8wasTWr8;n(#UD*LHX6BR9-6vGKMObp{0xR9{WK6oH(h+3e;jcY`0ABY0YlLIEqJ8SY21Ls iQ0unHoKpgyZm+7Sp-?7g5%hm=f&zU2 literal 0 HcmV?d00001 diff --git a/05.recommender_system/index.cn.html b/05.recommender_system/index.cn.html index ea41aaa..186443b 100644 --- a/05.recommender_system/index.cn.html +++ b/05.recommender_system/index.cn.html @@ -44,6 +44,14 @@ 本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/05.recommender_system),初次使用请您参考[Book文档使用说明](https://github.com/PaddlePaddle/book/blob/develop/README.cn.md#运行这本书)。 +### 说明: ### +1. 硬件环境要求: +本文可支持在CPU、GPU下运行 +2. Docker镜像支持的CUDA/cuDNN版本: +如果使用了Docker运行Book,请注意:这里所提供的默认镜像的GPU环境为 CUDA 8/cuDNN 5,对于NVIDIA Tesla V100等要求CUDA 9的 GPU,使用该镜像可能会运行失败。 +3. 文档和脚本中代码的一致性问题: +请注意:为使本文更加易读易用,我们拆分、调整了train.py的代码并放入本文。本文中代码与train.py的运行结果一致,可直接运行[train.py](https://github.com/PaddlePaddle/book/blob/develop/05.recommender_system/train.py)进行验证。 + ## 背景介绍 在网络技术不断发展和电子商务规模不断扩大的背景下,商品数量和种类快速增长,用户需要花费大量时间才能找到自己想买的商品,这就是信息超载问题。为了解决这个难题,个性化推荐系统(Recommender System)应运而生。 @@ -96,7 +104,9 @@ YouTube是世界上最大的视频上传、分享和发现网站,YouTube个性 对于一个用户$U$,预测此刻用户要观看的视频$\omega$为视频$i$的概率公式为: -$$P(\omega=i|u)=\frac{e^{v_{i}u}}{\sum_{j \in V}e^{v_{j}u}}$$ +

+
+

其中$u$为用户$U$的特征表示,$V$为视频库集合,$v_i$为视频库中第$i$个视频的特征表示。$u$和$v_i$为长度相等的向量,两者点积可以通过全连接层实现。 @@ -125,11 +135,15 @@ $$P(\omega=i|u)=\frac{e^{v_{i}u}}{\sum_{j \in V}e^{v_{j}u}}$$ 其次,进行卷积操作:把卷积核(kernel)$w\in\mathbb{R}^{hk}$应用于包含$h$个词的窗口$x_{i:i+h-1}$,得到特征$c_i=f(w\cdot x_{i:i+h-1}+b)$,其中$b\in\mathbb{R}$为偏置项(bias),$f$为非线性激活函数,如$sigmoid$。将卷积核应用于句子中所有的词窗口${x_{1:h},x_{2:h+1},\ldots,x_{n-h+1:n}}$,产生一个特征图(feature map): -$$c=[c_1,c_2,\ldots,c_{n-h+1}], c \in \mathbb{R}^{n-h+1}$$ +

+
+

接下来,对特征图采用时间维度上的最大池化(max pooling over time)操作得到此卷积核对应的整句话的特征$\hat c$,它是特征图中所有元素的最大值: -$$\hat c=max(c)$$ +

+
+

#### 融合推荐模型概览 -- GitLab