# Recognize Digits
-The source code for this tutorial is under [book/recognize_digits](https://github.com/PaddlePaddle/book/tree/develop/recognize_digits). First-time readers, please refer to PaddlePaddle [installation instructions](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html).
+The source code for this tutorial is under [book/recognize_digits](https://github.com/PaddlePaddle/book/tree/develop/recognize_digits). First-time readers, please refer to PaddlePaddle [installation instructions](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
## Introduction
When we learn a new programming language, the first task is usually to write a program that prints "Hello World." In Machine Learning or Deep Learning, the equivalent task is to train a model to perform handwritten digit recognition with [MNIST](http://yann.lecun.com/exdb/mnist/) dataset. Handwriting recognition is a typical image classification problem. The problem is relatively easy, and MNIST is a complete dataset. As a simple Computer Vision dataset, MNIST contains images of handwritten digits and their corresponding labels (Fig. 1). The input image is a 28x28 matrix, and the label is one of the digits from 0 to 9. Each image is normalized in size and centered.
diff --git a/recognize_digits/index.html b/recognize_digits/index.html
index 2a3a63ba0484312724d52361e08db67c332e657a..9f56a91a72964c8d952f7974431c7806669098b0 100644
--- a/recognize_digits/index.html
+++ b/recognize_digits/index.html
@@ -42,7 +42,7 @@
# 识别数字
-本教程源代码目录在[book/recognize_digits](https://github.com/PaddlePaddle/book/tree/develop/recognize_digits), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/recognize_digits](https://github.com/PaddlePaddle/book/tree/develop/recognize_digits), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
当我们学习编程的时候,编写的第一个程序一般是实现打印"Hello World"。而机器学习(或深度学习)的入门教程,一般都是 [MNIST](http://yann.lecun.com/exdb/mnist/) 数据库上的手写识别问题。原因是手写识别属于典型的图像分类问题,比较简单,同时MNIST数据集也很完备。MNIST数据集作为一个简单的计算机视觉数据集,包含一系列如图1所示的手写数字图片和对应的标签。图片是28x28的像素矩阵,标签则对应着0~9的10个数字。每张图片都经过了大小归一化和居中处理。
diff --git a/recommender_system/README.en.ipynb b/recommender_system/README.en.ipynb
new file mode 100644
index 0000000000000000000000000000000000000000..8c9addf7c8dcedc37f018f8621c98077e59fb3ff
--- /dev/null
+++ b/recommender_system/README.en.ipynb
@@ -0,0 +1,740 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Personalized Recommendation\n",
+ "\n",
+ "The source code of this tutorial is in [book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system).\n",
+ "\n",
+ "For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).\n",
+ "\n",
+ "\n",
+ "## Background\n",
+ "\n",
+ "With the fast growth of e-commerce, online videos, and online reading business, users have to rely on recommender systems to avoid manually browsing tremendous volume of choices. Recommender systems understand users' interest by mining user behavior and other properties of users and products.\n",
+ "\n",
+ "Some well know approaches include:\n",
+ "\n",
+ "- User behavior-based approach. A well-known method is collaborative filtering. The underlying assumption is that if a person A has the same opinion as a person B on an issue, A is more likely to have B's opinion on a different issue than that of a randomly chosen person.\n",
+ "\n",
+ "- Content-based recommendation[[1](#reference)]. This approach infers feature vectors that represent products from their descriptions. It also infers feature vectors that represent users' interests. Then it measures the relevance of users and products by some distances between these feature vectors.\n",
+ "\n",
+ "- Hybrid approach[[2](#reference)]: This approach uses the content-based information to help address the cold start problem[[6](#reference)] in behavior-based approach.\n",
+ "\n",
+ "Among these options, collaborative filtering might be the most studied one. Some of its variants include user-based[[3](#reference)], item-based [[4](#reference)], social network based[[5](#reference)], and model-based.\n",
+ "\n",
+ "This tutorial explains a deep learning based approach and how to implement it using PaddlePaddle. We will train a model using a dataset that includes user information, movie information, and ratings. Once we train the model, we will be able to get a predicted rating given a pair of user and movie IDs.\n",
+ "\n",
+ "\n",
+ "## Model Overview\n",
+ "\n",
+ "To know more about deep learning based recommendation, let us start from going over the Youtube recommender system[[7](#参考文献)] before introducing our hybrid model.\n",
+ "\n",
+ "\n",
+ "### YouTube's Deep Learning Recommendation Model\n",
+ "\n",
+ "YouTube is a video-sharing Web site with one of the largest user base in the world. Its recommender system serves more than a billion users. This system is composed of two major parts: candidate generation and ranking. The former selects few hundreds of candidates from millions of videos, and the latter ranks and outputs the top 10.\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\u003cimg src=\"image/YouTube_Overview.en.png\" width=\"70%\" \u003e\u003cbr/\u003e\n",
+ "Figure 1. YouTube recommender system overview.\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "#### Candidate Generation Network\n",
+ "\n",
+ "Youtube models candidate generation as a multiclass classification problem with a huge number of classes equal to the number of videos. The architecture of the model is as follows:\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\u003cimg src=\"image/Deep_candidate_generation_model_architecture.en.png\" width=\"70%\" \u003e\u003cbr/\u003e\n",
+ "Figure. Deep candidate geeration model.\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "The first stage of this model maps watching history and search queries into fixed-length representative features. Then, an MLP (multi-layer perceptron, as described in the [Recognize Digits](https://github.com/PaddlePaddle/book/blob/develop/recognize_digits/README.md) tutorial) takes the concatenation of all representative vectors. The output of the MLP represents the user' *intrinsic interests*. At training time, it is used together with a softmax output layer for minimizing the classification error. At serving time, it is used to compute the relevance of the user with all movies.\n",
+ "\n",
+ "For a user $U$, the predicted watching probability of video $i$ is\n",
+ "\n",
+ "$$P(\\omega=i|u)=\\frac{e^{v_{i}u}}{\\sum_{j \\in V}e^{v_{j}u}}$$\n",
+ "\n",
+ "where $u$ is the representative vector of user $U$, $V$ is the corpus of all videos, $v_i$ is the representative vector of the $i$-th video. $u$ and $v_i$ are vectors of the same length, so we can compute their dot product using a fully connected layer.\n",
+ "\n",
+ "This model could have a performance issue as the softmax output covers millions of classification labels. To optimize performance, at the training time, the authors down-sample negative samples, so the actual number of classes is reduced to thousands. At serving time, the authors ignore the normalization of the softmax outputs, because the results are just for ranking.\n",
+ "\n",
+ "\n",
+ "#### Ranking Network\n",
+ "\n",
+ "The architecture of the ranking network is similar to that of the candidate generation network. Similar to ranking models widely used in online advertising, it uses rich features like video ID, last watching time, etc. The output layer of the ranking network is a weighted logistic regression, which rates all candidate videos.\n",
+ "\n",
+ "\n",
+ "### Hybrid Model\n",
+ "\n",
+ "In the section, let us introduce our movie recommendation system.\n",
+ "\n",
+ "In our network, the input includes features of users and movies. The user feature includes four properties: user ID, gender, occupation, and age. Movie features include their IDs, genres, and titles.\n",
+ "\n",
+ "We use fully-connected layers to map user features into representative feature vectors and concatenate them. The process of movie features is similar, except that for movie titles -- we feed titles into a text convolution network as described in the [sentiment analysis tutorial](https://github.com/PaddlePaddle/book/blob/develop/understand_sentiment/README.md))to get a fixed-length representative feature vector.\n",
+ "\n",
+ "Given the feature vectors of users and movies, we compute the relevance using cosine similarity. We minimize the squared error at training time.\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\n",
+ "\u003cimg src=\"image/rec_regression_network_en.png\" width=\"90%\" \u003e\u003cbr/\u003e\n",
+ "Figure 3. A hybrid recommendation model.\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "## Dataset\n",
+ "\n",
+ "We use the [MovieLens ml-1m](http://files.grouplens.org/datasets/movielens/ml-1m.zip) to train our model. This dataset includes 10,000 ratings of 4,000 movies from 6,000 users to 4,000 movies. Each rate is in the range of 1~5. Thanks to GroupLens Research for collecting, processing and publishing the dataset.\n",
+ "\n",
+ "`paddle.v2.datasets` package encapsulates multiple public datasets, including `cifar`, `imdb`, `mnist`, `moivelens` and `wmt14`, etc. There's no need for us to manually download and preprocess `MovieLens` dataset.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "# Run this block to show dataset's documentation\n",
+ "help(paddle.v2.dataset.movielens)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "The raw `MoiveLens` contains movie ratings, relevant features from both movies and users.\n",
+ "For instance, one movie's feature could be:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "movie_info = paddle.dataset.movielens.movie_info()\n",
+ "print movie_info.values()[0]\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "```text\n",
+ "\u003cMovieInfo id(1), title(Toy Story), categories(['Animation', \"Children's\", 'Comedy'])\u003e\n",
+ "```\n",
+ "\n",
+ "One user's feature could be:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "user_info = paddle.dataset.movielens.user_info()\n",
+ "print user_info.values()[0]\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "```text\n",
+ "\u003cUserInfo id(1), gender(F), age(1), job(10)\u003e\n",
+ "```\n",
+ "\n",
+ "In this dateset, the distribution of age is shown as follows:\n",
+ "\n",
+ "```text\n",
+ "1: \"Under 18\"\n",
+ "18: \"18-24\"\n",
+ "25: \"25-34\"\n",
+ "35: \"35-44\"\n",
+ "45: \"45-49\"\n",
+ "50: \"50-55\"\n",
+ "56: \"56+\"\n",
+ "```\n",
+ "\n",
+ "User's occupation is selected from the following options:\n",
+ "\n",
+ "```text\n",
+ "0: \"other\" or not specified\n",
+ "1: \"academic/educator\"\n",
+ "2: \"artist\"\n",
+ "3: \"clerical/admin\"\n",
+ "4: \"college/grad student\"\n",
+ "5: \"customer service\"\n",
+ "6: \"doctor/health care\"\n",
+ "7: \"executive/managerial\"\n",
+ "8: \"farmer\"\n",
+ "9: \"homemaker\"\n",
+ "10: \"K-12 student\"\n",
+ "11: \"lawyer\"\n",
+ "12: \"programmer\"\n",
+ "13: \"retired\"\n",
+ "14: \"sales/marketing\"\n",
+ "15: \"scientist\"\n",
+ "16: \"self-employed\"\n",
+ "17: \"technician/engineer\"\n",
+ "18: \"tradesman/craftsman\"\n",
+ "19: \"unemployed\"\n",
+ "20: \"writer\"\n",
+ "```\n",
+ "\n",
+ "Each record consists of three main components: user features, movie features and movie ratings.\n",
+ "Likewise, as a simple example, consider the following:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "train_set_creator = paddle.dataset.movielens.train()\n",
+ "train_sample = next(train_set_creator())\n",
+ "uid = train_sample[0]\n",
+ "mov_id = train_sample[len(user_info[uid].value())]\n",
+ "print \"User %s rates Movie %s with Score %s\"%(user_info[uid], movie_info[mov_id], train_sample[-1])\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "```text\n",
+ "User \u003cUserInfo id(1), gender(F), age(1), job(10)\u003e rates Movie \u003cMovieInfo id(1193), title(One Flew Over the Cuckoo's Nest), categories(['Drama'])\u003e with Score [5.0]\n",
+ "```\n",
+ "\n",
+ "The output shows that user 1 gave movie `1193` a rating of 5.\n",
+ "\n",
+ "After issuing a command `python train.py`, training will start immediately. The details will be unpacked by the following sessions to see how it works.\n",
+ "\n",
+ "## Model Architecture\n",
+ "\n",
+ "### Initialize PaddlePaddle\n",
+ "\n",
+ "First, we must import and initialize PaddlePaddle (enable/disable GPU, set the number of trainers, etc).\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "%matplotlib inline\n",
+ "\n",
+ "import matplotlib.pyplot as plt\n",
+ "from IPython import display\n",
+ "import cPickle\n",
+ "\n",
+ "import paddle.v2 as paddle\n",
+ "\n",
+ "paddle.init(use_gpu=False)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "### Model Configuration\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "uid = paddle.layer.data(\n",
+ " name='user_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " paddle.dataset.movielens.max_user_id() + 1))\n",
+ "usr_emb = paddle.layer.embedding(input=uid, size=32)\n",
+ "\n",
+ "usr_gender_id = paddle.layer.data(\n",
+ " name='gender_id', type=paddle.data_type.integer_value(2))\n",
+ "usr_gender_emb = paddle.layer.embedding(input=usr_gender_id, size=16)\n",
+ "\n",
+ "usr_age_id = paddle.layer.data(\n",
+ " name='age_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " len(paddle.dataset.movielens.age_table)))\n",
+ "usr_age_emb = paddle.layer.embedding(input=usr_age_id, size=16)\n",
+ "\n",
+ "usr_job_id = paddle.layer.data(\n",
+ " name='job_id',\n",
+ " type=paddle.data_type.integer_value(paddle.dataset.movielens.max_job_id(\n",
+ " ) + 1))\n",
+ "usr_job_emb = paddle.layer.embedding(input=usr_job_id, size=16)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "As shown in the above code, the input is four dimension integers for each user, that is, `user_id`,`gender_id`, `age_id` and `job_id`. In order to deal with these features conveniently, we use the language model in NLP to transform these discrete values into embedding vaules `usr_emb`, `usr_gender_emb`, `usr_age_emb` and `usr_job_emb`.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "usr_combined_features = paddle.layer.fc(\n",
+ " input=[usr_emb, usr_gender_emb, usr_age_emb, usr_job_emb],\n",
+ " size=200,\n",
+ " act=paddle.activation.Tanh())\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "Then, employing user features as input, directly connecting to a fully-connected layer, which is used to reduce dimension to 200.\n",
+ "\n",
+ "Furthermore, we do a similar transformation for each movie feature. The model configuration is:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "mov_id = paddle.layer.data(\n",
+ " name='movie_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " paddle.dataset.movielens.max_movie_id() + 1))\n",
+ "mov_emb = paddle.layer.embedding(input=mov_id, size=32)\n",
+ "\n",
+ "mov_categories = paddle.layer.data(\n",
+ " name='category_id',\n",
+ " type=paddle.data_type.sparse_binary_vector(\n",
+ " len(paddle.dataset.movielens.movie_categories())))\n",
+ "\n",
+ "mov_categories_hidden = paddle.layer.fc(input=mov_categories, size=32)\n",
+ "\n",
+ "\n",
+ "movie_title_dict = paddle.dataset.movielens.get_movie_title_dict()\n",
+ "mov_title_id = paddle.layer.data(\n",
+ " name='movie_title',\n",
+ " type=paddle.data_type.integer_value_sequence(len(movie_title_dict)))\n",
+ "mov_title_emb = paddle.layer.embedding(input=mov_title_id, size=32)\n",
+ "mov_title_conv = paddle.networks.sequence_conv_pool(\n",
+ " input=mov_title_emb, hidden_size=32, context_len=3)\n",
+ "\n",
+ "mov_combined_features = paddle.layer.fc(\n",
+ " input=[mov_emb, mov_categories_hidden, mov_title_conv],\n",
+ " size=200,\n",
+ " act=paddle.activation.Tanh())\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "Movie title, a sequence of words represented by an integer word index sequence, will be feed into a `sequence_conv_pool` layer, which will apply convolution and pooling on time dimension. Because pooling is done on time dimension, the output will be a fixed-length vector regardless the length of the input sequence.\n",
+ "\n",
+ "Finally, we can use cosine similarity to calculate the similarity between user characteristics and movie features.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5)\n",
+ "cost = paddle.layer.regression_cost(\n",
+ " input=inference,\n",
+ " label=paddle.layer.data(\n",
+ " name='score', type=paddle.data_type.dense_vector(1)))\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "## Model Training\n",
+ "\n",
+ "### Define Parameters\n",
+ "\n",
+ "First, we define the model parameters according to the previous model configuration `cost`.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "# Create parameters\n",
+ "parameters = paddle.parameters.create(cost)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "### Create Trainer\n",
+ "\n",
+ "Before jumping into creating a training module, algorithm setting is also necessary. Here we specified Adam optimization algorithm via `paddle.optimizer`.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,\n",
+ " update_equation=paddle.optimizer.Adam(learning_rate=1e-4))\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "```text\n",
+ "[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
+ "[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__]\n",
+ "```\n",
+ "\n",
+ "### Training\n",
+ "\n",
+ "`paddle.dataset.movielens.train` will yield records during each pass, after shuffling, a batch input is generated for training.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "reader=paddle.reader.batch(\n",
+ " paddle.reader.shuffle(\n",
+ " paddle.dataset.movielens.trai(), buf_size=8192),\n",
+ " batch_size=256)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "`feeding` is devoted to specifying the correspondence between each yield record and `paddle.layer.data`. For instance, the first column of data generated by `movielens.train` corresponds to `user_id` feature.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "feeding = {\n",
+ " 'user_id': 0,\n",
+ " 'gender_id': 1,\n",
+ " 'age_id': 2,\n",
+ " 'job_id': 3,\n",
+ " 'movie_id': 4,\n",
+ " 'category_id': 5,\n",
+ " 'movie_title': 6,\n",
+ " 'score': 7\n",
+ "}\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "Callback function `event_handler` will be called during training when a pre-defined event happens.\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "step=0\n",
+ "\n",
+ "train_costs=[],[]\n",
+ "test_costs=[],[]\n",
+ "\n",
+ "def event_handler(event):\n",
+ " global step\n",
+ " global train_costs\n",
+ " global test_costs\n",
+ " if isinstance(event, paddle.event.EndIteration):\n",
+ " need_plot = False\n",
+ " if step % 10 == 0: # every 10 batches, record a train cost\n",
+ " train_costs[0].append(step)\n",
+ " train_costs[1].append(event.cost)\n",
+ "\n",
+ " if step % 1000 == 0: # every 1000 batches, record a test cost\n",
+ " result = trainer.test(reader=paddle.batch(\n",
+ " paddle.dataset.movielens.test(), batch_size=256))\n",
+ " test_costs[0].append(step)\n",
+ " test_costs[1].append(result.cost)\n",
+ "\n",
+ " if step % 100 == 0: # every 100 batches, update cost plot\n",
+ " plt.plot(*train_costs)\n",
+ " plt.plot(*test_costs)\n",
+ " plt.legend(['Train Cost', 'Test Cost'], loc='upper left')\n",
+ " display.clear_output(wait=True)\n",
+ " display.display(plt.gcf())\n",
+ " plt.gcf().clear()\n",
+ " step += 1\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "Finally, we can invoke `trainer.train` to start training:\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "trainer.train(\n",
+ " reader=reader,\n",
+ " event_handler=event_handler,\n",
+ " feeding=feeding,\n",
+ " num_passes=200)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "## Conclusion\n",
+ "\n",
+ "This tutorial goes over traditional approaches in recommender system and a deep learning based approach. We also show that how to train and use the model with PaddlePaddle. Deep learning has been well used in computer vision and NLP, we look forward to its new successes in recommender systems.\n",
+ "\n",
+ "## Reference\n",
+ "\n",
+ "1. [Peter Brusilovsky](https://en.wikipedia.org/wiki/Peter_Brusilovsky) (2007). *The Adaptive Web*. p. 325.\n",
+ "2. Robin Burke , [Hybrid Web Recommender Systems](http://www.dcs.warwick.ac.uk/~acristea/courses/CS411/2010/Book%20-%20The%20Adaptive%20Web/HybridWebRecommenderSystems.pdf), pp. 377-408, The Adaptive Web, Peter Brusilovsky, Alfred Kobsa, Wolfgang Nejdl (Ed.), Lecture Notes in Computer Science, Springer-Verlag, Berlin, Germany, Lecture Notes in Computer Science, Vol. 4321, May 2007, 978-3-540-72078-2.\n",
+ "3. P. Resnick, N. Iacovou, etc. “[GroupLens: An Open Architecture for Collaborative Filtering of Netnews](http://ccs.mit.edu/papers/CCSWP165.html)”, Proceedings of ACM Conference on Computer Supported Cooperative Work, CSCW 1994. pp.175-186.\n",
+ "4. Sarwar, Badrul, et al. \"[Item-based collaborative filtering recommendation algorithms.](http://files.grouplens.org/papers/www10_sarwar.pdf)\" *Proceedings of the 10th International Conference on World Wide Web*. ACM, 2001.\n",
+ "5. Kautz, Henry, Bart Selman, and Mehul Shah. \"[Referral Web: Combining Social networks and collaborative filtering.](http://www.cs.cornell.edu/selman/papers/pdf/97.cacm.refweb.pdf)\" Communications of the ACM 40.3 (1997): 63-65. APA\n",
+ "6. Yuan, Jianbo, et al. [\"Solving Cold-Start Problem in Large-scale Recommendation Engines: A Deep Learning Approach.\"](https://arxiv.org/pdf/1611.05480v1.pdf) *arXiv preprint arXiv:1611.05480* (2016).\n",
+ "7. Covington P, Adams J, Sargin E. [Deep neural networks for youtube recommendations](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/45530.pdf)[C]//Proceedings of the 10th ACM Conference on Recommender Systems. ACM, 2016: 191-198.\n",
+ "\n",
+ "\u003cbr/\u003e\n",
+ "This tutorial is contributed by \u003ca xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://book.paddlepaddle.org\" property=\"cc:attributionName\" rel=\"cc:attributionURL\"\u003ePaddlePaddle\u003c/a\u003e, and licensed under a \u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003eCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License\u003c/a\u003e.\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/recommender_system/README.en.md b/recommender_system/README.en.md
index 5782235e2871de0bb977e4dfc65d956cfed4b49b..d9b925193c7935087ca649abf190595754dd7d47 100644
--- a/recommender_system/README.en.md
+++ b/recommender_system/README.en.md
@@ -2,6 +2,9 @@
The source code of this tutorial is in [book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system).
+For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
+
+
## Background
With the fast growth of e-commerce, online videos, and online reading business, users have to rely on recommender systems to avoid manually browsing tremendous volume of choices. Recommender systems understand users' interest by mining user behavior and other properties of users and products.
diff --git a/recommender_system/README.ipynb b/recommender_system/README.ipynb
index 084e587b9aa20c6284cdd9aaf25c72cd556232c9..24833340333d7bf2415cc229e8a86a3383b60d1d 100644
--- a/recommender_system/README.ipynb
+++ b/recommender_system/README.ipynb
@@ -1,797 +1,795 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
- },
- "source": [
- "# 个性化推荐\n",
- "\n",
- "本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。\n",
- "\n",
- "## 背景介绍\n",
- "\n",
- "在网络技术不断发展和电子商务规模不断扩大的背景下,商品数量和种类快速增长,用户需要花费大量时间才能找到自己想买的商品,这就是信息超载问题。为了解决这个难题,推荐系统(Recommender System)应运而生。\n",
- "\n",
- "个性化推荐系统是信息过滤系统(Information Filtering System)的子集,它可以用在很多领域,如电影、音乐、电商和 Feed 流推荐等。推荐系统通过分析、挖掘用户行为,发现用户的个性化需求与兴趣特点,将用户可能感兴趣的信息或商品推荐给用户。与搜索引擎不同,推荐系统不需要用户准确地描述出自己的需求,而是根据分析历史行为建模,主动提供满足用户兴趣和需求的信息。\n",
- "\n",
- "传统的推荐系统方法主要有:\n",
- "\n",
- "- 协同过滤推荐(Collaborative Filtering Recommendation):该方法收集分析用户历史行为、活动、偏好,计算一个用户与其他用户的相似度,利用目标用户的相似用户对商品评价的加权评价值,来预测目标用户对特定商品的喜好程度。优点是可以给用户推荐未浏览过的新产品;缺点是对于没有任何行为的新用户存在冷启动的问题,同时也存在用户与商品之间的交互数据不够多造成的稀疏问题,会导致模型难以找到相近用户。\n",
- "- 基于内容过滤推荐[[1](#参考文献)](Content-based Filtering Recommendation):该方法利用商品的内容描述,抽象出有意义的特征,通过计算用户的兴趣和商品描述之间的相似度,来给用户做推荐。优点是简单直接,不需要依据其他用户对商品的评价,而是通过商品属性进行商品相似度度量,从而推荐给用户所感兴趣商品的相似商品;缺点是对于没有任何行为的新用户同样存在冷启动的问题。\n",
- "- 组合推荐[[2](#参考文献)](Hybrid Recommendation):运用不同的输入和技术共同进行推荐,以弥补各自推荐技术的缺点。\n",
- "\n",
- "其中协同过滤是应用最广泛的技术之一,它又可以分为多个子类:基于用户 (User-Based)的推荐[[3](#参考文献)] 、基于物品(Item-Based)的推荐[[4](#参考文献)]、基于社交网络关系(Social-Based)的推荐[[5](#参考文献)]、基于模型(Model-based)的推荐等。1994年明尼苏达大学推出的GroupLens系统[[3](#参考文献)]一般被认为是推荐系统成为一个相对独立的研究方向的标志。该系统首次提出了基于协同过滤来完成推荐任务的思想,此后,基于该模型的协同过滤推荐引领了推荐系统十几年的发展方向。\n",
- "\n",
- "深度学习具有优秀的自动提取特征的能力,能够学习多层次的抽象特征表示,并对异质或跨域的内容信息进行学习,可以一定程度上处理推荐系统冷启动问题[[6](#参考文献)]。本教程主要介绍个性化推荐的深度学习模型,以及如何使用PaddlePaddle实现模型。\n",
- "\n",
- "## 效果展示\n",
- "\n",
- "我们使用包含用户信息、电影信息与电影评分的数据集作为个性化推荐的应用场景。当我们训练好模型后,只需要输入对应的用户ID和电影ID,就可以得出一个匹配的分数(范围[1,5],分数越高视为兴趣越大),然后根据所有电影的推荐得分排序,推荐给用户可能感兴趣的电影。\n",
- "\n",
- "```\n",
- "Input movie_id: 1962\n",
- "Input user_id: 1\n",
- "Prediction Score is 4.25\n",
- "```\n",
- "\n",
- "## 模型概览\n",
- "\n",
- "本章中,我们首先介绍YouTube的视频推荐系统[[7](#参考文献)],然后介绍我们实现的融合推荐模型。\n",
- "\n",
- "### YouTube的深度神经网络推荐系统\n",
- "\n",
- "YouTube是世界上最大的视频上传、分享和发现网站,YouTube推荐系统为超过10亿用户从不断增长的视频库中推荐个性化的内容。整个系统由两个神经网络组成:候选生成网络和排序网络。候选生成网络从百万量级的视频库中生成上百个候选,排序网络对候选进行打分排序,输出排名最高的数十个结果。系统结构如图1所示:\n",
- "\n",
- "
\n",
- "
\n",
- "图1. YouTube 推荐系统结构\n",
- "
\n",
- "\n",
- "#### 候选生成网络(Candidate Generation Network)\n",
- "\n",
- "候选生成网络将推荐问题建模为一个类别数极大的多类分类问题:对于一个Youtube用户,使用其观看历史(视频ID)、搜索词记录(search tokens)、人口学信息(如地理位置、用户登录设备)、二值特征(如性别,是否登录)和连续特征(如用户年龄)等,对视频库中所有视频进行多分类,得到每一类别的分类结果(即每一个视频的推荐概率),最终输出概率较高的几百个视频。\n",
- "\n",
- "首先,将观看历史及搜索词记录这类历史信息,映射为向量后取平均值得到定长表示;同时,输入人口学特征以优化新用户的推荐效果,并将二值特征和连续特征归一化处理到[0, 1]范围。接下来,将所有特征表示拼接为一个向量,并输入给非线形多层感知器(MLP,详见[识别数字](https://github.com/PaddlePaddle/book/blob/develop/recognize_digits/README.md)教程)处理。最后,训练时将MLP的输出给softmax做分类,预测时计算用户的综合特征(MLP的输出)与所有视频的相似度,取得分最高的$k$个作为候选生成网络的筛选结果。图2显示了候选生成网络结构。\n",
- "\n",
- "
\n",
- "
\n",
- "图2. 候选生成网络结构\n",
- "
\n",
- "\n",
- "对于一个用户$U$,预测此刻用户要观看的视频$\\omega$为视频$i$的概率公式为:\n",
- "\n",
- "$$P(\\omega=i|u)=\\frac{e^{v_{i}u}}{\\sum_{j \\in V}e^{v_{j}u}}$$\n",
- "\n",
- "其中$u$为用户$U$的特征表示,$V$为视频库集合,$v_i$为视频库中第$i$个视频的特征表示。$u$和$v_i$为长度相等的向量,两者点积可以通过全连接层实现。\n",
- "\n",
- "考虑到softmax分类的类别数非常多,为了保证一定的计算效率:1)训练阶段,使用负样本类别采样将实际计算的类别数缩小至数千;2)推荐(预测)阶段,忽略softmax的归一化计算(不影响结果),将类别打分问题简化为点积(dot product)空间中的最近邻(nearest neighbor)搜索问题,取与$u$最近的$k$个视频作为生成的候选。\n",
- "\n",
- "#### 排序网络(Ranking Network)\n",
- "排序网络的结构类似于候选生成网络,但是它的目标是对候选进行更细致的打分排序。和传统广告排序中的特征抽取方法类似,这里也构造了大量的用于视频排序的相关特征(如视频 ID、上次观看时间等)。这些特征的处理方式和候选生成网络类似,不同之处是排序网络的顶部是一个加权逻辑回归(weighted logistic regression),它对所有候选视频进行打分,从高到底排序后将分数较高的一些视频返回给用户。\n",
- "\n",
- "### 融合推荐模型\n",
- "\n",
- "在下文的电影推荐系统中:\n",
- "\n",
- "1. 首先,使用用户特征和电影特征作为神经网络的输入,其中:\n",
- "\n",
- " - 用户特征融合了四个属性信息,分别是用户ID、性别、职业和年龄。\n",
- "\n",
- " - 电影特征融合了三个属性信息,分别是电影ID、电影类型ID和电影名称。\n",
- "\n",
- "2. 对用户特征,将用户ID映射为维度大小为256的向量表示,输入全连接层,并对其他三个属性也做类似的处理。然后将四个属性的特征表示分别全连接并相加。\n",
- "\n",
- "3. 对电影特征,将电影ID以类似用户ID的方式进行处理,电影类型ID以向量的形式直接输入全连接层,电影名称用文本卷积神经网络(详见[第5章](https://github.com/PaddlePaddle/book/blob/develop/understand_sentiment/README.md))得到其定长向量表示。然后将三个属性的特征表示分别全连接并相加。\n",
- "\n",
- "4. 得到用户和电影的向量表示后,计算二者的余弦相似度作为推荐系统的打分。最后,用该相似度打分和用户真实打分的差异的平方作为该回归模型的损失函数。\n",
- "\n",
- "
\n",
- "\n",
- "
\n",
- "图3. 融合推荐模型 \n",
- "
"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## 数据准备\n",
- "\n",
- "### 数据介绍与下载\n",
- "\n",
- "我们以 [MovieLens 百万数据集(ml-1m)](http://files.grouplens.org/datasets/movielens/ml-1m.zip)为例进行介绍。ml-1m 数据集包含了 6,000 位用户对 4,000 部电影的 1,000,000 条评价(评分范围 1~5 分,均为整数),由 GroupLens Research 实验室搜集整理。\n",
- "\n",
- "Paddle在API中提供了自动加载数据的模块。数据模块为 `paddle.dataset.movielens`"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "import paddle.v2 as paddle\n",
- "paddle.init(use_gpu=False)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "# Run this block to show dataset's documentation\n",
- "# help(paddle.dataset.movielens)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "在原始数据中包含电影的特征数据,用户的特征数据,和用户对电影的评分。\n",
- "\n",
- "例如,其中某一个电影特征为:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cells": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "
\n"
- ]
- }
- ],
- "source": [
- "movie_info = paddle.dataset.movielens.movie_info()\n",
- "print movie_info.values()[0]"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "这表示,电影的id是1,标题是《Toy Story》,该电影被分为到三个类别中。这三个类别是动画,儿童,喜剧。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 个性化推荐\n",
+ "\n",
+ "本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。\n",
+ "\n",
+ "## 背景介绍\n",
+ "\n",
+ "在网络技术不断发展和电子商务规模不断扩大的背景下,商品数量和种类快速增长,用户需要花费大量时间才能找到自己想买的商品,这就是信息超载问题。为了解决这个难题,推荐系统(Recommender System)应运而生。\n",
+ "\n",
+ "个性化推荐系统是信息过滤系统(Information Filtering System)的子集,它可以用在很多领域,如电影、音乐、电商和 Feed 流推荐等。推荐系统通过分析、挖掘用户行为,发现用户的个性化需求与兴趣特点,将用户可能感兴趣的信息或商品推荐给用户。与搜索引擎不同,推荐系统不需要用户准确地描述出自己的需求,而是根据分析历史行为建模,主动提供满足用户兴趣和需求的信息。\n",
+ "\n",
+ "传统的推荐系统方法主要有:\n",
+ "\n",
+ "- 协同过滤推荐(Collaborative Filtering Recommendation):该方法收集分析用户历史行为、活动、偏好,计算一个用户与其他用户的相似度,利用目标用户的相似用户对商品评价的加权评价值,来预测目标用户对特定商品的喜好程度。优点是可以给用户推荐未浏览过的新产品;缺点是对于没有任何行为的新用户存在冷启动的问题,同时也存在用户与商品之间的交互数据不够多造成的稀疏问题,会导致模型难以找到相近用户。\n",
+ "- 基于内容过滤推荐[[1](#参考文献)](Content-based Filtering Recommendation):该方法利用商品的内容描述,抽象出有意义的特征,通过计算用户的兴趣和商品描述之间的相似度,来给用户做推荐。优点是简单直接,不需要依据其他用户对商品的评价,而是通过商品属性进行商品相似度度量,从而推荐给用户所感兴趣商品的相似商品;缺点是对于没有任何行为的新用户同样存在冷启动的问题。\n",
+ "- 组合推荐[[2](#参考文献)](Hybrid Recommendation):运用不同的输入和技术共同进行推荐,以弥补各自推荐技术的缺点。\n",
+ "\n",
+ "其中协同过滤是应用最广泛的技术之一,它又可以分为多个子类:基于用户 (User-Based)的推荐[[3](#参考文献)] 、基于物品(Item-Based)的推荐[[4](#参考文献)]、基于社交网络关系(Social-Based)的推荐[[5](#参考文献)]、基于模型(Model-based)的推荐等。1994年明尼苏达大学推出的GroupLens系统[[3](#参考文献)]一般被认为是推荐系统成为一个相对独立的研究方向的标志。该系统首次提出了基于协同过滤来完成推荐任务的思想,此后,基于该模型的协同过滤推荐引领了推荐系统十几年的发展方向。\n",
+ "\n",
+ "深度学习具有优秀的自动提取特征的能力,能够学习多层次的抽象特征表示,并对异质或跨域的内容信息进行学习,可以一定程度上处理推荐系统冷启动问题[[6](#参考文献)]。本教程主要介绍个性化推荐的深度学习模型,以及如何使用PaddlePaddle实现模型。\n",
+ "\n",
+ "## 效果展示\n",
+ "\n",
+ "我们使用包含用户信息、电影信息与电影评分的数据集作为个性化推荐的应用场景。当我们训练好模型后,只需要输入对应的用户ID和电影ID,就可以得出一个匹配的分数(范围[1,5],分数越高视为兴趣越大),然后根据所有电影的推荐得分排序,推荐给用户可能感兴趣的电影。\n",
+ "\n",
+ "```\n",
+ "Input movie_id: 1962\n",
+ "Input user_id: 1\n",
+ "Prediction Score is 4.25\n",
+ "```\n",
+ "\n",
+ "## 模型概览\n",
+ "\n",
+ "本章中,我们首先介绍YouTube的视频推荐系统[[7](#参考文献)],然后介绍我们实现的融合推荐模型。\n",
+ "\n",
+ "### YouTube的深度神经网络推荐系统\n",
+ "\n",
+ "YouTube是世界上最大的视频上传、分享和发现网站,YouTube推荐系统为超过10亿用户从不断增长的视频库中推荐个性化的内容。整个系统由两个神经网络组成:候选生成网络和排序网络。候选生成网络从百万量级的视频库中生成上百个候选,排序网络对候选进行打分排序,输出排名最高的数十个结果。系统结构如图1所示:\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\u003cimg src=\"image/YouTube_Overview.png\" width=\"70%\" \u003e\u003cbr/\u003e\n",
+ "图1. YouTube 推荐系统结构\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "#### 候选生成网络(Candidate Generation Network)\n",
+ "\n",
+ "候选生成网络将推荐问题建模为一个类别数极大的多类分类问题:对于一个Youtube用户,使用其观看历史(视频ID)、搜索词记录(search tokens)、人口学信息(如地理位置、用户登录设备)、二值特征(如性别,是否登录)和连续特征(如用户年龄)等,对视频库中所有视频进行多分类,得到每一类别的分类结果(即每一个视频的推荐概率),最终输出概率较高的几百个视频。\n",
+ "\n",
+ "首先,将观看历史及搜索词记录这类历史信息,映射为向量后取平均值得到定长表示;同时,输入人口学特征以优化新用户的推荐效果,并将二值特征和连续特征归一化处理到[0, 1]范围。接下来,将所有特征表示拼接为一个向量,并输入给非线形多层感知器(MLP,详见[识别数字](https://github.com/PaddlePaddle/book/blob/develop/recognize_digits/README.md)教程)处理。最后,训练时将MLP的输出给softmax做分类,预测时计算用户的综合特征(MLP的输出)与所有视频的相似度,取得分最高的$k$个作为候选生成网络的筛选结果。图2显示了候选生成网络结构。\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\u003cimg src=\"image/Deep_candidate_generation_model_architecture.png\" width=\"70%\" \u003e\u003cbr/\u003e\n",
+ "图2. 候选生成网络结构\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "对于一个用户$U$,预测此刻用户要观看的视频$\\omega$为视频$i$的概率公式为:\n",
+ "\n",
+ "$$P(\\omega=i|u)=\\frac{e^{v_{i}u}}{\\sum_{j \\in V}e^{v_{j}u}}$$\n",
+ "\n",
+ "其中$u$为用户$U$的特征表示,$V$为视频库集合,$v_i$为视频库中第$i$个视频的特征表示。$u$和$v_i$为长度相等的向量,两者点积可以通过全连接层实现。\n",
+ "\n",
+ "考虑到softmax分类的类别数非常多,为了保证一定的计算效率:1)训练阶段,使用负样本类别采样将实际计算的类别数缩小至数千;2)推荐(预测)阶段,忽略softmax的归一化计算(不影响结果),将类别打分问题简化为点积(dot product)空间中的最近邻(nearest neighbor)搜索问题,取与$u$最近的$k$个视频作为生成的候选。\n",
+ "\n",
+ "#### 排序网络(Ranking Network)\n",
+ "排序网络的结构类似于候选生成网络,但是它的目标是对候选进行更细致的打分排序。和传统广告排序中的特征抽取方法类似,这里也构造了大量的用于视频排序的相关特征(如视频 ID、上次观看时间等)。这些特征的处理方式和候选生成网络类似,不同之处是排序网络的顶部是一个加权逻辑回归(weighted logistic regression),它对所有候选视频进行打分,从高到底排序后将分数较高的一些视频返回给用户。\n",
+ "\n",
+ "### 融合推荐模型\n",
+ "\n",
+ "在下文的电影推荐系统中:\n",
+ "\n",
+ "1. 首先,使用用户特征和电影特征作为神经网络的输入,其中:\n",
+ "\n",
+ " - 用户特征融合了四个属性信息,分别是用户ID、性别、职业和年龄。\n",
+ "\n",
+ " - 电影特征融合了三个属性信息,分别是电影ID、电影类型ID和电影名称。\n",
+ "\n",
+ "2. 对用户特征,将用户ID映射为维度大小为256的向量表示,输入全连接层,并对其他三个属性也做类似的处理。然后将四个属性的特征表示分别全连接并相加。\n",
+ "\n",
+ "3. 对电影特征,将电影ID以类似用户ID的方式进行处理,电影类型ID以向量的形式直接输入全连接层,电影名称用文本卷积神经网络(详见[第5章](https://github.com/PaddlePaddle/book/blob/develop/understand_sentiment/README.md))得到其定长向量表示。然后将三个属性的特征表示分别全连接并相加。\n",
+ "\n",
+ "4. 得到用户和电影的向量表示后,计算二者的余弦相似度作为推荐系统的打分。最后,用该相似度打分和用户真实打分的差异的平方作为该回归模型的损失函数。\n",
+ "\n",
+ "\u003cp align=\"center\"\u003e\n",
+ "\n",
+ "\u003cimg src=\"image/rec_regression_network.png\" width=\"90%\" \u003e\u003cbr/\u003e\n",
+ "图3. 融合推荐模型\n",
+ "\u003c/p\u003e\n",
+ "\n",
+ "## 数据准备\n",
+ "\n",
+ "### 数据介绍与下载\n",
+ "\n",
+ "我们以 [MovieLens 百万数据集(ml-1m)](http://files.grouplens.org/datasets/movielens/ml-1m.zip)为例进行介绍。ml-1m 数据集包含了 6,000 位用户对 4,000 部电影的 1,000,000 条评价(评分范围 1~5 分,均为整数),由 GroupLens Research 实验室搜集整理。\n",
+ "\n",
+ "Paddle在API中提供了自动加载数据的模块。数据模块为 `paddle.dataset.movielens`\n",
+ "\n",
+ "\n"
+ ]
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- }
- ],
- "source": [
- "user_info = paddle.dataset.movielens.user_info()\n",
- "print user_info.values()[0]"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "这表示,该用户ID是1,女性,年龄比18岁还年轻。职业ID是10。\n",
- "\n",
- "\n",
- "其中,年龄使用下列分布\n",
- "* 1: \"Under 18\"\n",
- "* 18: \"18-24\"\n",
- "* 25: \"25-34\"\n",
- "* 35: \"35-44\"\n",
- "* 45: \"45-49\"\n",
- "* 50: \"50-55\"\n",
- "* 56: \"56+\"\n",
- "\n",
- "职业是从下面几种选项里面选则得出:\n",
- "* 0: \"other\" or not specified\n",
- "* 1: \"academic/educator\"\n",
- "* 2: \"artist\"\n",
- "* 3: \"clerical/admin\"\n",
- "* 4: \"college/grad student\"\n",
- "* 5: \"customer service\"\n",
- "* 6: \"doctor/health care\"\n",
- "* 7: \"executive/managerial\"\n",
- "* 8: \"farmer\"\n",
- "* 9: \"homemaker\"\n",
- "* 10: \"K-12 student\"\n",
- "* 11: \"lawyer\"\n",
- "* 12: \"programmer\"\n",
- "* 13: \"retired\"\n",
- "* 14: \"sales/marketing\"\n",
- "* 15: \"scientist\"\n",
- "* 16: \"self-employed\"\n",
- "* 17: \"technician/engineer\"\n",
- "* 18: \"tradesman/craftsman\"\n",
- "* 19: \"unemployed\"\n",
- "* 20: \"writer\""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "而对于每一条训练/测试数据,均为 <用户特征> + <电影特征> + 评分。\n",
- "\n",
- "例如,我们获得第一条训练数据:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "import paddle.v2 as paddle\n",
+ "paddle.init(use_gpu=False)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "User rates Movie with Score [5.0]\n"
- ]
- }
- ],
- "source": [
- "train_set_creator = paddle.dataset.movielens.train()\n",
- "train_sample = next(train_set_creator())\n",
- "uid = train_sample[0]\n",
- "mov_id = train_sample[len(user_info[uid].value())]\n",
- "print \"User %s rates Movie %s with Score %s\"%(user_info[uid], movie_info[mov_id], train_sample[-1])"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "即用户1对电影1193的评价为5分。"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## 模型配置说明\n",
- "\n",
- "下面我们开始根据输入数据的形式配置模型。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "uid = paddle.layer.data(\n",
- " name='user_id',\n",
- " type=paddle.data_type.integer_value(\n",
- " paddle.dataset.movielens.max_user_id() + 1))\n",
- "usr_emb = paddle.layer.embedding(input=uid, size=32)\n",
- "\n",
- "usr_gender_id = paddle.layer.data(\n",
- " name='gender_id', type=paddle.data_type.integer_value(2))\n",
- "usr_gender_emb = paddle.layer.embedding(input=usr_gender_id, size=16)\n",
- "\n",
- "usr_age_id = paddle.layer.data(\n",
- " name='age_id',\n",
- " type=paddle.data_type.integer_value(\n",
- " len(paddle.dataset.movielens.age_table)))\n",
- "usr_age_emb = paddle.layer.embedding(input=usr_age_id, size=16)\n",
- "\n",
- "usr_job_id = paddle.layer.data(\n",
- " name='job_id',\n",
- " type=paddle.data_type.integer_value(paddle.dataset.movielens.max_job_id(\n",
- " ) + 1))\n",
- "usr_job_emb = paddle.layer.embedding(input=usr_job_id, size=16)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "如上述代码所示,对于每个用户,我们输入4维特征。其中包括`user_id`,`gender_id`,`age_id`,`job_id`。这几维特征均是简单的整数值。为了后续神经网络处理这些特征方便,我们借鉴NLP中的语言模型,将这几维离散的整数值,变换成embedding取出。分别形成`usr_emb`, `usr_gender_emb`, `usr_age_emb`, `usr_job_emb`。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "usr_combined_features = paddle.layer.fc(\n",
- " input=[usr_emb, usr_gender_emb, usr_age_emb, usr_job_emb],\n",
- " size=200,\n",
- " act=paddle.activation.Tanh())"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "然后,我们对于所有的用户特征,均输入到一个全连接层(fc)中。将所有特征融合为一个200维度的特征。"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "进而,我们对每一个电影特征做类似的变换,网络配置为:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "mov_id = paddle.layer.data(\n",
- " name='movie_id',\n",
- " type=paddle.data_type.integer_value(\n",
- " paddle.dataset.movielens.max_movie_id() + 1))\n",
- "mov_emb = paddle.layer.embedding(input=mov_id, size=32)\n",
- "\n",
- "mov_categories = paddle.layer.data(\n",
- " name='category_id',\n",
- " type=paddle.data_type.sparse_binary_vector(\n",
- " len(paddle.dataset.movielens.movie_categories())))\n",
- "\n",
- "mov_categories_hidden = paddle.layer.fc(input=mov_categories, size=32)\n",
- "\n",
- "\n",
- "movie_title_dict = paddle.dataset.movielens.get_movie_title_dict()\n",
- "mov_title_id = paddle.layer.data(\n",
- " name='movie_title',\n",
- " type=paddle.data_type.integer_value_sequence(len(movie_title_dict)))\n",
- "mov_title_emb = paddle.layer.embedding(input=mov_title_id, size=32)\n",
- "mov_title_conv = paddle.networks.sequence_conv_pool(\n",
- " input=mov_title_emb, hidden_size=32, context_len=3)\n",
- "\n",
- "mov_combined_features = paddle.layer.fc(\n",
- " input=[mov_emb, mov_categories_hidden, mov_title_conv],\n",
- " size=200,\n",
- " act=paddle.activation.Tanh())"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "电影ID和电影类型分别映射到其对应的特征隐层。对于电影标题名称(title),一个ID序列表示的词语序列,在输入卷积层后,将得到每个时间窗口的特征(序列特征),然后通过在时间维度降采样得到固定维度的特征,整个过程在text_conv_pool实现。\n",
- "\n",
- "最后再将电影的特征融合进`mov_combined_features`中。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "进而,我们使用余弦相似度计算用户特征与电影特征的相似性。并将这个相似性拟合(回归)到用户评分上。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
- },
- "outputs": [],
- "source": [
- "cost = paddle.layer.regression_cost(\n",
- " input=inference,\n",
- " label=paddle.layer.data(\n",
- " name='score', type=paddle.data_type.dense_vector(1)))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "至此,我们的优化目标就是这个网络配置中的`cost`了。"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## 训练模型\n",
- "\n",
- "### 定义参数\n",
- "神经网络的模型,我们可以简单的理解为网络拓朴结构+参数。之前一节,我们定义出了优化目标`cost`。这个`cost`即为网络模型的拓扑结构。我们开始训练模型,需要先定义出参数。定义方法为:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n"
+ ]
+ },
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
- "[INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__regression_cost_0__]\n"
- ]
- }
- ],
- "source": [
- "parameters = paddle.parameters.create(cost)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "# Run this block to show dataset's documentation\n",
+ "# help(paddle.dataset.movielens)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[u'___fc_layer_2__.wbias', u'___fc_layer_2__.w2', u'___embedding_layer_3__.w0', u'___embedding_layer_5__.w0', u'___embedding_layer_2__.w0', u'___embedding_layer_1__.w0', u'___fc_layer_1__.wbias', u'___fc_layer_0__.wbias', u'___fc_layer_1__.w0', u'___fc_layer_0__.w2', u'___fc_layer_0__.w3', u'___fc_layer_0__.w0', u'___fc_layer_0__.w1', u'___fc_layer_2__.w1', u'___fc_layer_2__.w0', u'___embedding_layer_4__.w0', u'___sequence_conv_pool_0___conv_fc.w0', u'___embedding_layer_0__.w0', u'___sequence_conv_pool_0___conv_fc.wbias']\n"
- ]
- }
- ],
- "source": [
- "print parameters.keys()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### 构造训练(trainer)\n",
- "\n",
- "下面,我们根据网络拓扑结构和模型参数来构造出一个本地训练(trainer)。在构造本地训练的时候,我们还需要指定这个训练的优化方法。这里我们使用Adam来作为优化算法。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "在原始数据中包含电影的特征数据,用户的特征数据,和用户对电影的评分。\n",
+ "\n",
+ "例如,其中某一个电影特征为:\n",
+ "\n",
+ "\n"
+ ]
+ },
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
- "[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__]\n"
- ]
- }
- ],
- "source": [
- "trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, \n",
- " update_equation=paddle.optimizer.Adam(learning_rate=1e-4))"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "### 训练\n",
- "\n",
- "下面我们开始训练过程。\n",
- "\n",
- "我们直接使用Paddle提供的数据集读取程序。`paddle.dataset.movielens.train()`和`paddle.dataset.movielens.test()`分别做训练和预测数据集。并且通过`reader_dict`来指定每一个数据和data_layer的对应关系。\n",
- "\n",
- "例如,这里的reader_dict表示的是,对于数据层 `user_id`,使用了reader中每一条数据的第0个元素。`gender_id`数据层使用了第1个元素。以此类推。\n",
- "\n",
- "训练过程是完全自动的。我们可以使用event_handler来观察训练过程,或进行测试等。这里我们在event_handler里面绘制了训练误差曲线和测试误差曲线。并且保存了模型。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "movie_info = paddle.dataset.movielens.movie_info()\n",
+ "print movie_info.values()[0]\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
{
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXd4HNX1v987s0VarbptuVvucpcLYGOaKQm2CRACKQQI\nEEpCEgL8EkIKIUC+hEBCEkIIMSWVTmgBjI0pxmCwccW9N7mrd22b3x+zMzu7Oyutula+7/P4sXbq\n3dndzz333HPOFZqmIZFIJJLUR+nuBkgkEomkY5CCLpFIJL0EKegSiUTSS5CCLpFIJL0EKegSiUTS\nS5CCLpFIJL0EKegSiUTSS5CCLpFIJL0EKegSiUTSS3B05c369OmjFRYWduUtJRKJJOVZvXp1qaZp\nfVs6rksFvbCwkFWrVnXlLSUSiSTlEULsS+Y46XKRSCSSXoIUdIlEIuklSEGXSCSSXkKX+tDt8Pv9\nlJSU0NjY2N1N6TWkpaUxePBgnE5ndzdFIpF0Id0u6CUlJWRmZlJYWIgQorubk/JomkZZWRklJSUM\nHz68u5sjkUi6kG53uTQ2NpKfny/FvIMQQpCfny9HPBLJCUi3CzogxbyDkc9TIjkx6RGC3hIVdT7K\napu6uxkSiUTSo0kJQa9q8FNe5+uUa5eVlVFcXExxcTH9+/dn0KBB5mufL7l7XnPNNWzbtq1V933z\nzTeZPn06EyZMoLi4mJ/85CetbvuaNWt4++23W32eRCLpnXT7pGgyCAGhTlrLOj8/n3Xr1gHwq1/9\nCq/Xy49+9KOoYzRNQ9M0FMW+//v73//eqnuuX7+eW265hTfffJMxY8YQDAZZsGBBq9u+Zs0aNm7c\nyPnnn9/qcyUSSe8jJSx0RQhCWicpegJ27tzJ+PHj+eY3v8mECRM4fPgwN9xwAzNmzGDChAncc889\n5rGnnXYa69atIxAIkJOTwx133MGUKVOYNWsWx44di7v2b3/7W+68807GjBkDgKqqfPe73wVgz549\nzJkzh8mTJ3PeeedRUlICwHPPPcfEiROZMmUKc+bMoaGhgXvuuYenn36a4uJiXnrppS54KhKJpCfT\noyz0u/+3ic2HquO2+wIhAqEQHlfrmzt+YBZ3fWlCm9qzdetW/vWvfzFjxgwA7r//fvLy8ggEAsyZ\nM4dLL72U8ePHR51TVVXFmWeeyf33389tt93GU089xR133BF1zMaNG/n5z39ue8+bbrqJ6667jm9+\n85ssWLCAW265hZdeeom7776bDz74gIKCAiorK0lPT+eXv/wlGzdu5I9//GOb3p9EIuldpISFjoCu\ntc91Ro4caYo5wLPPPsu0adOYNm0aW7ZsYfPmzXHnpKenM3fuXACmT5/O3r17W3XPFStW8PWvfx2A\nq666imXLlgEwe/ZsrrrqKp544glCoVAb35FEIunN9CgLPZElfbS6kaPVjUwalN2lIXkZGRnm3zt2\n7OBPf/oTK1euJCcnhyuuuMI21tvlcpl/q6pKIBCIO2bChAmsXr2aCROSHzk8/vjjrFixgjfeeINp\n06axdu3aVr4biUTS20kJC10Ja3hnTYwmQ3V1NZmZmWRlZXH48GEWLVrU5mvdfvvt3HvvvezcuROA\nYDDIY489BsDMmTN54YUXAPjPf/7DGWecAcDu3buZOXMm9957L7m5uRw8eJDMzExqamra+c4kEklv\noUdZ6IkwrPKQpqHSPUkz06ZNY/z48RQVFTFs2DBmz57d5mtNnTqV3//+93z1q181rfyLLroIgL/8\n5S9ce+21/OY3v6GgoMCMoLn11lvZs2cPmqbxhS98gYkTJ1JQUMCDDz7I1KlT+fnPf86ll17a/jcq\nkUhSFqF1YfTIjBkztNgFLrZs2cK4ceOaPa+8zkdJRT1F/TNxOdTObGKvIZnnKpFIUgMhxGpN02a0\ndJx0uUgkEkkvIUUEPeJykUgkEok9qSHoYRM9JE10iUQiSUhKCL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8W+d4M\n3C7pHPATsrTLQ4m6AmBmF/x9DHiK7AczxbZwHjhvZqVpuJ8kC/ApupazAzhqZi/7ctt8ixDQ/wIM\n+CiCHrJTm/1tdiqxHyhdkd5Nlqsu1X/Kr2pvAV7zU7CDwKCkxX7le9DrckWSgO8BZ8zsGwXwXSap\nz8tvIcv3nyEL7HdO41v6HncCz3hPaD8w5CNL1gADwHN5uprZPjNbaWarydriM2b2yRRdASQtUvZE\nMTx9MQicIsG2YGaXgJck3ehVtwGnU3StYBdX0i0lr/b4NvNCQY4XHHaSjdR4EXigTQ6PAxeBy2Q9\nic+Q5UKfBs4CvweW+LYCvu2+J4FNZfv5NDDqr7ua5LqN7DTveeC4v3Ym7Pte4Jj7ngIe9Pq1ZEFu\nlOx0doHXL/TlUV+/tmxfD/j3GAF2NLlN3MKVUS5JurrXCX+9UPr/SbgtrAeGvS38kmzUR5KufpxF\nZGdcvWV1bfONO0WDIAg6hCKkXIIgCIJZEAE9CIKgQ4iAHgRB0CFEQA+CIOgQIqAHQRB0CBHQgyAI\nOoQI6EEQBB1CBPQgCIIO4X9iGnorp+WAJQAAAABJRU5ErkJggg==\n",
- "text/plain": [
- ""
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " \u003cMovieInfo id(1), title(Toy Story ), categories(['Animation', \"Children's\", 'Comedy'])\u003e\n",
+ "\n",
+ "\n",
+ "这表示,电影的id是1,标题是《Toy Story》,该电影被分为到三个类别中。这三个类别是动画,儿童,喜剧。\n",
+ "\n",
+ "\n"
]
- },
- "metadata": {},
- "output_type": "display_data"
},
{
- "data": {
- "text/plain": [
- ""
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "user_info = paddle.dataset.movielens.user_info()\n",
+ "print user_info.values()[0]\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " \u003cUserInfo id(1), gender(F), age(1), job(10)\u003e\n",
+ "\n",
+ "\n",
+ "这表示,该用户ID是1,女性,年龄比18岁还年轻。职业ID是10。\n",
+ "\n",
+ "\n",
+ "其中,年龄使用下列分布\n",
+ "* 1: \"Under 18\"\n",
+ "* 18: \"18-24\"\n",
+ "* 25: \"25-34\"\n",
+ "* 35: \"35-44\"\n",
+ "* 45: \"45-49\"\n",
+ "* 50: \"50-55\"\n",
+ "* 56: \"56+\"\n",
+ "\n",
+ "职业是从下面几种选项里面选则得出:\n",
+ "* 0: \"other\" or not specified\n",
+ "* 1: \"academic/educator\"\n",
+ "* 2: \"artist\"\n",
+ "* 3: \"clerical/admin\"\n",
+ "* 4: \"college/grad student\"\n",
+ "* 5: \"customer service\"\n",
+ "* 6: \"doctor/health care\"\n",
+ "* 7: \"executive/managerial\"\n",
+ "* 8: \"farmer\"\n",
+ "* 9: \"homemaker\"\n",
+ "* 10: \"K-12 student\"\n",
+ "* 11: \"lawyer\"\n",
+ "* 12: \"programmer\"\n",
+ "* 13: \"retired\"\n",
+ "* 14: \"sales/marketing\"\n",
+ "* 15: \"scientist\"\n",
+ "* 16: \"self-employed\"\n",
+ "* 17: \"technician/engineer\"\n",
+ "* 18: \"tradesman/craftsman\"\n",
+ "* 19: \"unemployed\"\n",
+ "* 20: \"writer\"\n",
+ "\n",
+ "而对于每一条训练/测试数据,均为 \u003c用户特征\u003e + \u003c电影特征\u003e + 评分。\n",
+ "\n",
+ "例如,我们获得第一条训练数据:\n",
+ "\n",
+ "\n"
]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "%matplotlib inline\n",
- "\n",
- "import matplotlib.pyplot as plt\n",
- "from IPython import display\n",
- "import cPickle\n",
- "\n",
- "feeding = {\n",
- " 'user_id': 0,\n",
- " 'gender_id': 1,\n",
- " 'age_id': 2,\n",
- " 'job_id': 3,\n",
- " 'movie_id': 4,\n",
- " 'category_id': 5,\n",
- " 'movie_title': 6,\n",
- " 'score': 7\n",
- "}\n",
- "\n",
- "step=0\n",
- "\n",
- "train_costs=[],[]\n",
- "test_costs=[],[]\n",
- "\n",
- "def event_handler(event):\n",
- " global step\n",
- " global train_costs\n",
- " global test_costs\n",
- " if isinstance(event, paddle.event.EndIteration):\n",
- " need_plot = False\n",
- " if step % 10 == 0: # every 10 batches, record a train cost\n",
- " train_costs[0].append(step)\n",
- " train_costs[1].append(event.cost)\n",
- " \n",
- " if step % 1000 == 0: # every 1000 batches, record a test cost\n",
- " result = trainer.test(reader=paddle.batch(\n",
- " paddle.dataset.movielens.test(), batch_size=256))\n",
- " test_costs[0].append(step)\n",
- " test_costs[1].append(result.cost)\n",
- " \n",
- " if step % 100 == 0: # every 100 batches, update cost plot\n",
- " plt.plot(*train_costs)\n",
- " plt.plot(*test_costs)\n",
- " plt.legend(['Train Cost', 'Test Cost'], loc='upper left')\n",
- " display.clear_output(wait=True)\n",
- " display.display(plt.gcf())\n",
- " plt.gcf().clear()\n",
- " step += 1\n",
- "\n",
- "trainer.train(\n",
- " reader=paddle.batch(\n",
- " paddle.reader.shuffle(\n",
- " paddle.dataset.movielens.train(), buf_size=8192),\n",
- " batch_size=256),\n",
- " event_handler=event_handler,\n",
- " feeding=feeding,\n",
- " num_passes=2)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## 应用模型\n",
- "\n",
- "在训练了几轮以后,您可以对模型进行推断。我们可以使用任意一个用户ID和电影ID,来预测该用户对该电影的评分。示例程序为:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
- "outputs": [
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "train_set_creator = paddle.dataset.movielens.train()\n",
+ "train_sample = next(train_set_creator())\n",
+ "uid = train_sample[0]\n",
+ "mov_id = train_sample[len(user_info[uid].value())]\n",
+ "print \"User %s rates Movie %s with Score %s\"%(user_info[uid], movie_info[mov_id], train_sample[-1])\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " User \u003cUserInfo id(1), gender(F), age(1), job(10)\u003e rates Movie \u003cMovieInfo id(1193), title(One Flew Over the Cuckoo's Nest ), categories(['Drama'])\u003e with Score [5.0]\n",
+ "\n",
+ "\n",
+ "即用户1对电影1193的评价为5分。\n",
+ "\n",
+ "## 模型配置说明\n",
+ "\n",
+ "下面我们开始根据输入数据的形式配置模型。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "uid = paddle.layer.data(\n",
+ " name='user_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " paddle.dataset.movielens.max_user_id() + 1))\n",
+ "usr_emb = paddle.layer.embedding(input=uid, size=32)\n",
+ "\n",
+ "usr_gender_id = paddle.layer.data(\n",
+ " name='gender_id', type=paddle.data_type.integer_value(2))\n",
+ "usr_gender_emb = paddle.layer.embedding(input=usr_gender_id, size=16)\n",
+ "\n",
+ "usr_age_id = paddle.layer.data(\n",
+ " name='age_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " len(paddle.dataset.movielens.age_table)))\n",
+ "usr_age_emb = paddle.layer.embedding(input=usr_age_id, size=16)\n",
+ "\n",
+ "usr_job_id = paddle.layer.data(\n",
+ " name='job_id',\n",
+ " type=paddle.data_type.integer_value(paddle.dataset.movielens.max_job_id(\n",
+ " ) + 1))\n",
+ "usr_job_emb = paddle.layer.embedding(input=usr_job_id, size=16)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "如上述代码所示,对于每个用户,我们输入4维特征。其中包括`user_id`,`gender_id`,`age_id`,`job_id`。这几维特征均是简单的整数值。为了后续神经网络处理这些特征方便,我们借鉴NLP中的语言模型,将这几维离散的整数值,变换成embedding取出。分别形成`usr_emb`, `usr_gender_emb`, `usr_age_emb`, `usr_job_emb`。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "usr_combined_features = paddle.layer.fc(\n",
+ " input=[usr_emb, usr_gender_emb, usr_age_emb, usr_job_emb],\n",
+ " size=200,\n",
+ " act=paddle.activation.Tanh())\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "然后,我们对于所有的用户特征,均输入到一个全连接层(fc)中。将所有特征融合为一个200维度的特征。\n",
+ "\n",
+ "进而,我们对每一个电影特征做类似的变换,网络配置为:\n",
+ "\n",
+ "\n"
+ ]
+ },
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "[INFO 2017-03-06 17:17:08,132 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title]\n",
- "[INFO 2017-03-06 17:17:08,134 networks.py:1478] The output order is [__cos_sim_0__]\n"
- ]
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "mov_id = paddle.layer.data(\n",
+ " name='movie_id',\n",
+ " type=paddle.data_type.integer_value(\n",
+ " paddle.dataset.movielens.max_movie_id() + 1))\n",
+ "mov_emb = paddle.layer.embedding(input=mov_id, size=32)\n",
+ "\n",
+ "mov_categories = paddle.layer.data(\n",
+ " name='category_id',\n",
+ " type=paddle.data_type.sparse_binary_vector(\n",
+ " len(paddle.dataset.movielens.movie_categories())))\n",
+ "\n",
+ "mov_categories_hidden = paddle.layer.fc(input=mov_categories, size=32)\n",
+ "\n",
+ "\n",
+ "movie_title_dict = paddle.dataset.movielens.get_movie_title_dict()\n",
+ "mov_title_id = paddle.layer.data(\n",
+ " name='movie_title',\n",
+ " type=paddle.data_type.integer_value_sequence(len(movie_title_dict)))\n",
+ "mov_title_emb = paddle.layer.embedding(input=mov_title_id, size=32)\n",
+ "mov_title_conv = paddle.networks.sequence_conv_pool(\n",
+ " input=mov_title_emb, hidden_size=32, context_len=3)\n",
+ "\n",
+ "mov_combined_features = paddle.layer.fc(\n",
+ " input=[mov_emb, mov_categories_hidden, mov_title_conv],\n",
+ " size=200,\n",
+ " act=paddle.activation.Tanh())\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "电影ID和电影类型分别映射到其对应的特征隐层。对于电影标题名称(title),一个ID序列表示的词语序列,在输入卷积层后,将得到每个时间窗口的特征(序列特征),然后通过在时间维度降采样得到固定维度的特征,整个过程在text_conv_pool实现。\n",
+ "\n",
+ "最后再将电影的特征融合进`mov_combined_features`中。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "进而,我们使用余弦相似度计算用户特征与电影特征的相似性。并将这个相似性拟合(回归)到用户评分上。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "cost = paddle.layer.regression_cost(\n",
+ " input=inference,\n",
+ " label=paddle.layer.data(\n",
+ " name='score', type=paddle.data_type.dense_vector(1)))\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "至此,我们的优化目标就是这个网络配置中的`cost`了。\n",
+ "\n",
+ "## 训练模型\n",
+ "\n",
+ "### 定义参数\n",
+ "神经网络的模型,我们可以简单的理解为网络拓朴结构+参数。之前一节,我们定义出了优化目标`cost`。这个`cost`即为网络模型的拓扑结构。我们开始训练模型,需要先定义出参数。定义方法为:\n",
+ "\n",
+ "\n"
+ ]
},
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[Predict] User 234 Rating Movie 345 With Score 4.16\n"
- ]
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "parameters = paddle.parameters.create(cost)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " [INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
+ " [INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__regression_cost_0__]\n",
+ "\n",
+ "\n",
+ "`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "print parameters.keys()\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " [u'___fc_layer_2__.wbias', u'___fc_layer_2__.w2', u'___embedding_layer_3__.w0', u'___embedding_layer_5__.w0', u'___embedding_layer_2__.w0', u'___embedding_layer_1__.w0', u'___fc_layer_1__.wbias', u'___fc_layer_0__.wbias', u'___fc_layer_1__.w0', u'___fc_layer_0__.w2', u'___fc_layer_0__.w3', u'___fc_layer_0__.w0', u'___fc_layer_0__.w1', u'___fc_layer_2__.w1', u'___fc_layer_2__.w0', u'___embedding_layer_4__.w0', u'___sequence_conv_pool_0___conv_fc.w0', u'___embedding_layer_0__.w0', u'___sequence_conv_pool_0___conv_fc.wbias']\n",
+ "\n",
+ "\n",
+ "### 构造训练(trainer)\n",
+ "\n",
+ "下面,我们根据网络拓扑结构和模型参数来构造出一个本地训练(trainer)。在构造本地训练的时候,我们还需要指定这个训练的优化方法。这里我们使用Adam来作为优化算法。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,\n",
+ " update_equation=paddle.optimizer.Adam(learning_rate=1e-4))\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
+ " [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__]\n",
+ "\n",
+ "\n",
+ "### 训练\n",
+ "\n",
+ "下面我们开始训练过程。\n",
+ "\n",
+ "我们直接使用Paddle提供的数据集读取程序。`paddle.dataset.movielens.train()`和`paddle.dataset.movielens.test()`分别做训练和预测数据集。并且通过`reader_dict`来指定每一个数据和data_layer的对应关系。\n",
+ "\n",
+ "例如,这里的reader_dict表示的是,对于数据层 `user_id`,使用了reader中每一条数据的第0个元素。`gender_id`数据层使用了第1个元素。以此类推。\n",
+ "\n",
+ "训练过程是完全自动的。我们可以使用event_handler来观察训练过程,或进行测试等。这里我们在event_handler里面绘制了训练误差曲线和测试误差曲线。并且保存了模型。\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "%matplotlib inline\n",
+ "\n",
+ "import matplotlib.pyplot as plt\n",
+ "from IPython import display\n",
+ "import cPickle\n",
+ "\n",
+ "feeding = {\n",
+ " 'user_id': 0,\n",
+ " 'gender_id': 1,\n",
+ " 'age_id': 2,\n",
+ " 'job_id': 3,\n",
+ " 'movie_id': 4,\n",
+ " 'category_id': 5,\n",
+ " 'movie_title': 6,\n",
+ " 'score': 7\n",
+ "}\n",
+ "\n",
+ "step=0\n",
+ "\n",
+ "train_costs=[],[]\n",
+ "test_costs=[],[]\n",
+ "\n",
+ "def event_handler(event):\n",
+ " global step\n",
+ " global train_costs\n",
+ " global test_costs\n",
+ " if isinstance(event, paddle.event.EndIteration):\n",
+ " need_plot = False\n",
+ " if step % 10 == 0: # every 10 batches, record a train cost\n",
+ " train_costs[0].append(step)\n",
+ " train_costs[1].append(event.cost)\n",
+ "\n",
+ " if step % 1000 == 0: # every 1000 batches, record a test cost\n",
+ " result = trainer.test(reader=paddle.batch(\n",
+ " paddle.dataset.movielens.test(), batch_size=256))\n",
+ " test_costs[0].append(step)\n",
+ " test_costs[1].append(result.cost)\n",
+ "\n",
+ " if step % 100 == 0: # every 100 batches, update cost plot\n",
+ " plt.plot(*train_costs)\n",
+ " plt.plot(*test_costs)\n",
+ " plt.legend(['Train Cost', 'Test Cost'], loc='upper left')\n",
+ " display.clear_output(wait=True)\n",
+ " display.display(plt.gcf())\n",
+ " plt.gcf().clear()\n",
+ " step += 1\n",
+ "\n",
+ "trainer.train(\n",
+ " reader=paddle.batch(\n",
+ " paddle.reader.shuffle(\n",
+ " paddle.dataset.movielens.train(), buf_size=8192),\n",
+ " batch_size=256),\n",
+ " event_handler=event_handler,\n",
+ " feeding=feeding,\n",
+ " num_passes=2)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "![png](./image/output_32_0.png)\n",
+ "\n",
+ "## 应用模型\n",
+ "\n",
+ "在训练了几轮以后,您可以对模型进行推断。我们可以使用任意一个用户ID和电影ID,来预测该用户对该电影的评分。示例程序为:\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "editable": true
+ },
+ "source": [
+ "import copy\n",
+ "user_id = 234\n",
+ "movie_id = 345\n",
+ "\n",
+ "user = user_info[user_id]\n",
+ "movie = movie_info[movie_id]\n",
+ "\n",
+ "feature = user.value() + movie.value()\n",
+ "\n",
+ "infer_dict = copy.copy(feeding)\n",
+ "del infer_dict['score']\n",
+ "\n",
+ "prediction = paddle.infer(output=inference, parameters=parameters, input=[feature], feeding=infer_dict)\n",
+ "score = (prediction[0][0] + 5.0) / 2\n",
+ "print \"[Predict] User %d Rating Movie %d With Score %.2f\"%(user_id, movie_id, score)\n"
+ ],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "execution_count": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " [INFO 2017-03-06 17:17:08,132 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title]\n",
+ " [INFO 2017-03-06 17:17:08,134 networks.py:1478] The output order is [__cos_sim_0__]\n",
+ "\n",
+ "\n",
+ " [Predict] User 234 Rating Movie 345 With Score 4.16\n",
+ "\n",
+ "\n",
+ "## 总结\n",
+ "\n",
+ "本章介绍了传统的推荐系统方法和YouTube的深度神经网络推荐系统,并以电影推荐为例,使用PaddlePaddle训练了一个个性化推荐神经网络模型。推荐系统几乎涵盖了电商系统、社交网络、广告推荐、搜索引擎等领域的方方面面,而在图像处理、自然语言处理等领域已经发挥重要作用的深度学习技术,也将会在推荐系统领域大放异彩。\n",
+ "\n",
+ "## 参考文献\n",
+ "\n",
+ "1. [Peter Brusilovsky](https://en.wikipedia.org/wiki/Peter_Brusilovsky) (2007). *The Adaptive Web*. p. 325.\n",
+ "2. Robin Burke , [Hybrid Web Recommender Systems](http://www.dcs.warwick.ac.uk/~acristea/courses/CS411/2010/Book%20-%20The%20Adaptive%20Web/HybridWebRecommenderSystems.pdf), pp. 377-408, The Adaptive Web, Peter Brusilovsky, Alfred Kobsa, Wolfgang Nejdl (Ed.), Lecture Notes in Computer Science, Springer-Verlag, Berlin, Germany, Lecture Notes in Computer Science, Vol. 4321, May 2007, 978-3-540-72078-2.\n",
+ "3. P. Resnick, N. Iacovou, etc. “[GroupLens: An Open Architecture for Collaborative Filtering of Netnews](http://ccs.mit.edu/papers/CCSWP165.html)”, Proceedings of ACM Conference on Computer Supported Cooperative Work, CSCW 1994. pp.175-186.\n",
+ "4. Sarwar, Badrul, et al. \"[Item-based collaborative filtering recommendation algorithms.](http://files.grouplens.org/papers/www10_sarwar.pdf)\" *Proceedings of the 10th international conference on World Wide Web*. ACM, 2001.\n",
+ "5. Kautz, Henry, Bart Selman, and Mehul Shah. \"[Referral Web: combining social networks and collaborative filtering.](http://www.cs.cornell.edu/selman/papers/pdf/97.cacm.refweb.pdf)\" Communications of the ACM 40.3 (1997): 63-65. APA\n",
+ "6. Yuan, Jianbo, et al. [\"Solving Cold-Start Problem in Large-scale Recommendation Engines: A Deep Learning Approach.\"](https://arxiv.org/pdf/1611.05480v1.pdf) *arXiv preprint arXiv:1611.05480* (2016).\n",
+ "7. Covington P, Adams J, Sargin E. [Deep neural networks for youtube recommendations](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/45530.pdf)[C]//Proceedings of the 10th ACM Conference on Recommender Systems. ACM, 2016: 191-198.\n",
+ "\n",
+ "\u003cbr/\u003e\n",
+ "\u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e\u003cimg alt=\"知识共享许可协议\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" /\u003e\u003c/a\u003e\u003cbr /\u003e\u003cspan xmlns:dct=\"http://purl.org/dc/terms/\" href=\"http://purl.org/dc/dcmitype/Text\" property=\"dct:title\" rel=\"dct:type\"\u003e本教程\u003c/span\u003e 由 \u003ca xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://book.paddlepaddle.org\" property=\"cc:attributionName\" rel=\"cc:attributionURL\"\u003ePaddlePaddle\u003c/a\u003e 创作,采用 \u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议\u003c/a\u003e进行许可。\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.0"
}
- ],
- "source": [
- "import copy\n",
- "user_id = 234\n",
- "movie_id = 345\n",
- "\n",
- "user = user_info[user_id]\n",
- "movie = movie_info[movie_id]\n",
- "\n",
- "feature = user.value() + movie.value()\n",
- "\n",
- "infer_dict = copy.copy(feeding)\n",
- "del infer_dict['score']\n",
- "\n",
- "prediction = paddle.infer(output=inference, parameters=parameters, input=[feature], feeding=infer_dict)\n",
- "score = (prediction[0][0] + 5.0) / 2\n",
- "print \"[Predict] User %d Rating Movie %d With Score %.2f\"%(user_id, movie_id, score)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
- "source": [
- "## 总结\n",
- "\n",
- "本章介绍了传统的推荐系统方法和YouTube的深度神经网络推荐系统,并以电影推荐为例,使用PaddlePaddle训练了一个个性化推荐神经网络模型。推荐系统几乎涵盖了电商系统、社交网络、广告推荐、搜索引擎等领域的方方面面,而在图像处理、自然语言处理等领域已经发挥重要作用的深度学习技术,也将会在推荐系统领域大放异彩。\n",
- "\n",
- "## 参考文献\n",
- "\n",
- "1. [Peter Brusilovsky](https://en.wikipedia.org/wiki/Peter_Brusilovsky) (2007). *The Adaptive Web*. p. 325.\n",
- "2. Robin Burke , [Hybrid Web Recommender Systems](http://www.dcs.warwick.ac.uk/~acristea/courses/CS411/2010/Book%20-%20The%20Adaptive%20Web/HybridWebRecommenderSystems.pdf), pp. 377-408, The Adaptive Web, Peter Brusilovsky, Alfred Kobsa, Wolfgang Nejdl (Ed.), Lecture Notes in Computer Science, Springer-Verlag, Berlin, Germany, Lecture Notes in Computer Science, Vol. 4321, May 2007, 978-3-540-72078-2.\n",
- "3. P. Resnick, N. Iacovou, etc. “[GroupLens: An Open Architecture for Collaborative Filtering of Netnews](http://ccs.mit.edu/papers/CCSWP165.html)”, Proceedings of ACM Conference on Computer Supported Cooperative Work, CSCW 1994. pp.175-186.\n",
- "4. Sarwar, Badrul, et al. \"[Item-based collaborative filtering recommendation algorithms.](http://files.grouplens.org/papers/www10_sarwar.pdf)\" *Proceedings of the 10th international conference on World Wide Web*. ACM, 2001.\n",
- "5. Kautz, Henry, Bart Selman, and Mehul Shah. \"[Referral Web: combining social networks and collaborative filtering.](http://www.cs.cornell.edu/selman/papers/pdf/97.cacm.refweb.pdf)\" Communications of the ACM 40.3 (1997): 63-65. APA\n",
- "6. Yuan, Jianbo, et al. [\"Solving Cold-Start Problem in Large-scale Recommendation Engines: A Deep Learning Approach.\"](https://arxiv.org/pdf/1611.05480v1.pdf) *arXiv preprint arXiv:1611.05480* (2016).\n",
- "7. Covington P, Adams J, Sargin E. [Deep neural networks for youtube recommendations](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/45530.pdf)[C]//Proceedings of the 10th ACM Conference on Recommender Systems. ACM, 2016: 191-198.\n",
- "\n",
- "
\n",
- "
本教程 由 PaddlePaddle 创作,采用 知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议进行许可。\n"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 2",
- "language": "python",
- "name": "python2"
},
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 2
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.13"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 0
+ "nbformat": 4,
+ "nbformat_minor": 0
}
diff --git a/recommender_system/README.md b/recommender_system/README.md
index 6f25182b7cc4cfa03e018572d1e6d005cd70a666..2e4ce1722840a56e151def6a4634a8cd3857216b 100644
--- a/recommender_system/README.md
+++ b/recommender_system/README.md
@@ -1,6 +1,6 @@
# 个性化推荐
-本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
diff --git a/recommender_system/index.en.html b/recommender_system/index.en.html
index ea02f50e6b2e490b78eaa9fe4e4e76dcaef81c17..17a2fcb652eecbbdf82898bde1d148e4ecc77c6f 100644
--- a/recommender_system/index.en.html
+++ b/recommender_system/index.en.html
@@ -44,6 +44,9 @@
The source code of this tutorial is in [book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system).
+For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
+
+
## Background
With the fast growth of e-commerce, online videos, and online reading business, users have to rely on recommender systems to avoid manually browsing tremendous volume of choices. Recommender systems understand users' interest by mining user behavior and other properties of users and products.
diff --git a/recommender_system/index.html b/recommender_system/index.html
index 3b850765d2ff0e9a340a4c1a9e0f2baf430ee8b2..ff0c5c08cdd3f09ad27f514d849bfbbfe010da5f 100644
--- a/recommender_system/index.html
+++ b/recommender_system/index.html
@@ -42,7 +42,7 @@
# 个性化推荐
-本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/recommender_system](https://github.com/PaddlePaddle/book/tree/develop/recommender_system), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
diff --git a/tools/convert-markdown-into-ipynb-and-test.sh b/tools/convert-markdown-into-ipynb-and-test.sh
new file mode 100755
index 0000000000000000000000000000000000000000..32ba98a8275d8e8277caf5893f35d1b9726d4714
--- /dev/null
+++ b/tools/convert-markdown-into-ipynb-and-test.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+command -v go >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ echo >&2 "Please install go https://golang.org/doc/install#install"
+ exit 1
+fi
+
+GOPATH=/tmp/go go get -u github.com/wangkuiyi/ipynb/markdown-to-ipynb
+
+cur_path=$(dirname $(readlink -f $0))
+cd $cur_path/../
+
+#convert md to ipynb
+for file in */{README,README\.en}.md ; do
+ /tmp/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb"
+ if [ $? -ne 0 ]; then
+ echo >&2 "markdown-to-ipynb $file error"
+ exit 1
+ fi
+done
+
+if [[ -z $TEST_EMBEDDED_PYTHON_SCRIPTS ]]; then
+ exit 0
+fi
+
+#exec ipynb's py file
+for file in */{README,README\.en}.ipynb ; do
+ pushd $PWD > /dev/null
+ cd $(dirname $file) > /dev/null
+
+ echo "begin test $file"
+ jupyter nbconvert --to python $(basename $file) --stdout | python
+
+ popd > /dev/null
+ #break
+done
diff --git a/understand_sentiment/README.en.md b/understand_sentiment/README.en.md
index 9b84b871e26a2266c0ba9c96b9fc52e217cecfdb..105a851b3537cb100d3d47a4c47e1b2c06f1e685 100644
--- a/understand_sentiment/README.en.md
+++ b/understand_sentiment/README.en.md
@@ -1,6 +1,6 @@
# Sentiment Analysis
-The source codes of this section can be located at [book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment). First-time users may refer to PaddlePaddle for [Installation guide](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html).
+The source codes of this section can be located at [book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment). First-time users may refer to PaddlePaddle for [Installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
## Background
diff --git a/understand_sentiment/README.md b/understand_sentiment/README.md
index fecb7a4146510c9c6d402af6c3d2f6b7d06922ab..3da65a419c0bc4146d2c2b55c4d446ef93706a8d 100644
--- a/understand_sentiment/README.md
+++ b/understand_sentiment/README.md
@@ -1,6 +1,6 @@
# 情感分析
-本教程源代码目录在[book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
在自然语言处理中,情感分析一般是指判断一段文本所表达的情绪状态。其中,一段文本可以是一个句子,一个段落或一个文档。情绪状态可以是两类,如(正面,负面),(高兴,悲伤);也可以是三类,如(积极,消极,中性)等等。情感分析的应用场景十分广泛,如把用户在购物网站(亚马逊、天猫、淘宝等)、旅游网站、电影评论网站上发表的评论分成正面评论和负面评论;或为了分析用户对于某一产品的整体使用感受,抓取产品的用户评论并进行情感分析等等。表格1展示了对电影评论进行情感分析的例子:
diff --git a/understand_sentiment/index.en.html b/understand_sentiment/index.en.html
index 192cd58c0cb7bc661d30d4385af177a711dc11ef..e069daccfc26f1ac43f401cd5b978fc84ed6038c 100644
--- a/understand_sentiment/index.en.html
+++ b/understand_sentiment/index.en.html
@@ -42,7 +42,7 @@
# Sentiment Analysis
-The source codes of this section can be located at [book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment). First-time users may refer to PaddlePaddle for [Installation guide](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html).
+The source codes of this section can be located at [book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment). First-time users may refer to PaddlePaddle for [Installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
## Background
diff --git a/understand_sentiment/index.html b/understand_sentiment/index.html
index 76626650be02f83fb3c2f71ae55cc78d9d177aa6..9260e7cfc23e55e6eb62c1c9992b727abc260bdc 100644
--- a/understand_sentiment/index.html
+++ b/understand_sentiment/index.html
@@ -42,7 +42,7 @@
# 情感分析
-本教程源代码目录在[book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/understand_sentiment](https://github.com/PaddlePaddle/book/tree/develop/understand_sentiment), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
在自然语言处理中,情感分析一般是指判断一段文本所表达的情绪状态。其中,一段文本可以是一个句子,一个段落或一个文档。情绪状态可以是两类,如(正面,负面),(高兴,悲伤);也可以是三类,如(积极,消极,中性)等等。情感分析的应用场景十分广泛,如把用户在购物网站(亚马逊、天猫、淘宝等)、旅游网站、电影评论网站上发表的评论分成正面评论和负面评论;或为了分析用户对于某一产品的整体使用感受,抓取产品的用户评论并进行情感分析等等。表格1展示了对电影评论进行情感分析的例子:
diff --git a/word2vec/README.en.md b/word2vec/README.en.md
index 9ed9f720809f3ad8fdd843bd49211deff2ec6b83..4c1ba71137e21d2a980bc0fda1ac3be6b158b7e2 100644
--- a/word2vec/README.en.md
+++ b/word2vec/README.en.md
@@ -2,7 +2,7 @@
This is intended as a reference tutorial. The source code of this tutorial lives on [book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec).
-For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html).
+For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
## Background Introduction
diff --git a/word2vec/README.md b/word2vec/README.md
index a6e5732ca5e7844cbb45c0a568a9bbac67ff05b6..eaf1feb77417307f9cb925240bad836631f22e09 100644
--- a/word2vec/README.md
+++ b/word2vec/README.md
@@ -1,7 +1,7 @@
# 词向量
-本教程源代码目录在[book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
@@ -32,8 +32,8 @@ $$X = USV^T$$
本章中,当词向量训练好后,我们可以用数据可视化算法t-SNE\[[4](#参考文献)\]画出词语特征在二维上的投影(如下图所示)。从图中可以看出,语义相关的词语(如a, the, these; big, huge)在投影上距离很近,语意无关的词(如say, business; decision, japan)在投影上的距离很远。
-
- 图1. 词向量的二维投影
+
+ 图1. 词向量的二维投影
另一方面,我们知道两个向量的余弦值在$[-1,1]$的区间内:两个完全相同的向量余弦值为1, 两个相互垂直的向量之间余弦值为0,两个方向完全相反的向量余弦值为-1,即相关性和余弦值大小成正比。因此我们还可以计算两个词向量的余弦相似度:
@@ -86,8 +86,8 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
其中$f(w_t, w_{t-1}, ..., w_{t-n+1})$表示根据历史n-1个词得到当前词$w_t$的条件概率,$R(\theta)$表示参数正则项。
-
- 图2. N-gram神经网络模型
+
+ 图2. N-gram神经网络模型
图2展示了N-gram神经网络模型,从下往上看,该模型分为以下几个部分:
@@ -97,7 +97,7 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
- 然后所有词语的词向量连接成一个大向量,并经过一个非线性映射得到历史词语的隐层表示:
- $$g=Utanh(\theta^Tx + b_1) + Wx + b_2$$
+ $$g=Utanh(\theta^Tx + b_1) + Wx + b_2$$
其中,$x$为所有词语的词向量连接成的大向量,表示文本历史特征;$\theta$、$U$、$b_1$、$b_2$和$W$分别为词向量层到隐层连接的参数。$g$表示未经归一化的所有输出单词概率,$g_i$表示未经归一化的字典中第$i$个单词的输出概率。
@@ -118,8 +118,8 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
CBOW模型通过一个词的上下文(各N个词)预测当前词。当N=2时,模型如下图所示:
-
- 图3. CBOW模型
+
+ 图3. CBOW模型
具体来说,不考虑上下文的词语输入顺序,CBOW是用上下文词语的词向量的均值来预测当前词。即:
@@ -133,8 +133,8 @@ $$context = \frac{x_{t-1} + x_{t-2} + x_{t+1} + x_{t+2}}{4}$$
CBOW的好处是对上下文词语的分布在词向量上进行了平滑,去掉了噪声,因此在小数据集上很有效。而Skip-gram的方法中,用一个词预测其上下文,得到了当前词上下文的很多样本,因此可用于更大的数据集。
-
- 图4. Skip-gram模型
+
+ 图4. Skip-gram模型
如上图所示,Skip-gram模型的具体做法是,将一个词的词向量映射到$2n$个词的词向量($2n$表示当前输入词的前后各$n$个词),然后分别通过softmax得到这$2n$个词的分类损失值之和。
@@ -148,21 +148,21 @@ CBOW的好处是对上下文词语的分布在词向量上进行了平滑,去
-
- 训练数据 |
- 验证数据 |
- 测试数据 |
-
-
- ptb.train.txt |
- ptb.valid.txt |
- ptb.test.txt |
-
-
- 42068句 |
- 3370句 |
- 3761句 |
-
+
+ 训练数据 |
+ 验证数据 |
+ 测试数据 |
+
+
+ ptb.train.txt |
+ ptb.valid.txt |
+ ptb.test.txt |
+
+
+ 42068句 |
+ 3370句 |
+ 3761句 |
+
@@ -189,8 +189,8 @@ dream that one day
本配置的模型结构如下图所示:
-
- 图5. 模型配置中的N-gram神经网络模型
+
+ 图5. 模型配置中的N-gram神经网络模型
首先,加载所需要的包:
diff --git a/word2vec/index.en.html b/word2vec/index.en.html
index 66e4bcc9a4eb1047524729a454c57e5268ceeb86..6c91bd3ffe28a837d821404f15da80f3d61a1258 100644
--- a/word2vec/index.en.html
+++ b/word2vec/index.en.html
@@ -44,7 +44,7 @@
This is intended as a reference tutorial. The source code of this tutorial lives on [book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec).
-For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html).
+For instructions on getting started with PaddlePaddle, see [PaddlePaddle installation guide](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
## Background Introduction
diff --git a/word2vec/index.html b/word2vec/index.html
index ad5cd1942de85a946beca2bfd7213e8924316a39..1cff9b6e3ff219bab759e318a25ad78b18342d36 100644
--- a/word2vec/index.html
+++ b/word2vec/index.html
@@ -43,7 +43,7 @@
# 词向量
-本教程源代码目录在[book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec), 初次使用请参考PaddlePaddle[安装教程](http://www.paddlepaddle.org/doc_cn/build_and_install/index.html)。
+本教程源代码目录在[book/word2vec](https://github.com/PaddlePaddle/book/tree/develop/word2vec), 初次使用请参考PaddlePaddle[安装教程](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)。
## 背景介绍
@@ -74,8 +74,8 @@ $$X = USV^T$$
本章中,当词向量训练好后,我们可以用数据可视化算法t-SNE\[[4](#参考文献)\]画出词语特征在二维上的投影(如下图所示)。从图中可以看出,语义相关的词语(如a, the, these; big, huge)在投影上距离很近,语意无关的词(如say, business; decision, japan)在投影上的距离很远。
-
- 图1. 词向量的二维投影
+
+ 图1. 词向量的二维投影
另一方面,我们知道两个向量的余弦值在$[-1,1]$的区间内:两个完全相同的向量余弦值为1, 两个相互垂直的向量之间余弦值为0,两个方向完全相反的向量余弦值为-1,即相关性和余弦值大小成正比。因此我们还可以计算两个词向量的余弦相似度:
@@ -128,8 +128,8 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
其中$f(w_t, w_{t-1}, ..., w_{t-n+1})$表示根据历史n-1个词得到当前词$w_t$的条件概率,$R(\theta)$表示参数正则项。
-
- 图2. N-gram神经网络模型
+
+ 图2. N-gram神经网络模型
图2展示了N-gram神经网络模型,从下往上看,该模型分为以下几个部分:
@@ -139,7 +139,7 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
- 然后所有词语的词向量连接成一个大向量,并经过一个非线性映射得到历史词语的隐层表示:
- $$g=Utanh(\theta^Tx + b_1) + Wx + b_2$$
+ $$g=Utanh(\theta^Tx + b_1) + Wx + b_2$$
其中,$x$为所有词语的词向量连接成的大向量,表示文本历史特征;$\theta$、$U$、$b_1$、$b_2$和$W$分别为词向量层到隐层连接的参数。$g$表示未经归一化的所有输出单词概率,$g_i$表示未经归一化的字典中第$i$个单词的输出概率。
@@ -160,8 +160,8 @@ $$\frac{1}{T}\sum_t f(w_t, w_{t-1}, ..., w_{t-n+1};\theta) + R(\theta)$$
CBOW模型通过一个词的上下文(各N个词)预测当前词。当N=2时,模型如下图所示:
-
- 图3. CBOW模型
+
+ 图3. CBOW模型
具体来说,不考虑上下文的词语输入顺序,CBOW是用上下文词语的词向量的均值来预测当前词。即:
@@ -175,8 +175,8 @@ $$context = \frac{x_{t-1} + x_{t-2} + x_{t+1} + x_{t+2}}{4}$$
CBOW的好处是对上下文词语的分布在词向量上进行了平滑,去掉了噪声,因此在小数据集上很有效。而Skip-gram的方法中,用一个词预测其上下文,得到了当前词上下文的很多样本,因此可用于更大的数据集。
-
- 图4. Skip-gram模型
+
+ 图4. Skip-gram模型
如上图所示,Skip-gram模型的具体做法是,将一个词的词向量映射到$2n$个词的词向量($2n$表示当前输入词的前后各$n$个词),然后分别通过softmax得到这$2n$个词的分类损失值之和。
@@ -190,21 +190,21 @@ CBOW的好处是对上下文词语的分布在词向量上进行了平滑,去
-
- 训练数据 |
- 验证数据 |
- 测试数据 |
-
-
- ptb.train.txt |
- ptb.valid.txt |
- ptb.test.txt |
-
-
- 42068句 |
- 3370句 |
- 3761句 |
-
+
+ 训练数据 |
+ 验证数据 |
+ 测试数据 |
+
+
+ ptb.train.txt |
+ ptb.valid.txt |
+ ptb.test.txt |
+
+
+ 42068句 |
+ 3370句 |
+ 3761句 |
+
@@ -231,8 +231,8 @@ dream that one day
本配置的模型结构如下图所示:
-
- 图5. 模型配置中的N-gram神经网络模型
+
+ 图5. 模型配置中的N-gram神经网络模型
首先,加载所需要的包: