diff --git a/04.word2vec/README.en.md b/04.word2vec/README.en.md index 53cdd509bd064c352207f30129586d792a0862e2..f9afc3415e553ec3225ff9c121df053dcceb191d 100644 --- a/04.word2vec/README.en.md +++ b/04.word2vec/README.en.md @@ -235,7 +235,8 @@ def wordemb(inlayer): name="_proj", initial_std=0.001, learning_rate=1, - l2_rate=0, )) + l2_rate=0, + sparse_update=True)) return wordemb ``` @@ -301,10 +302,10 @@ cost = paddle.layer.classification_cost(input=predictword, label=nextword) ```python parameters = paddle.parameters.create(cost) -adam_optimizer = paddle.optimizer.Adam( +adagrad = paddle.optimizer.AdaGrad( learning_rate=3e-3, regularization=paddle.optimizer.L2Regularization(8e-4)) -trainer = paddle.trainer.SGD(cost, parameters, adam_optimizer) +trainer = paddle.trainer.SGD(cost, parameters, adagrad) ``` Next, we will begin the training process. `paddle.dataset.imikolov.train()` and `paddle.dataset.imikolov.test()` is our training set and test set. Both of the function will return a **reader**: In PaddlePaddle, reader is a python function which returns a Python iterator which output a single data instance at a time. diff --git a/04.word2vec/README.md b/04.word2vec/README.md index 872aeec60aed997d6cd54c9ccaa8f72b2b8b30cf..a8e3864b1454772ef088db7ebd3e6b2c3f6e60d7 100644 --- a/04.word2vec/README.md +++ b/04.word2vec/README.md @@ -220,7 +220,8 @@ def wordemb(inlayer): name="_proj", initial_std=0.001, learning_rate=1, - l2_rate=0, )) + l2_rate=0, + sparse_update=True)) return wordemb ``` @@ -290,10 +291,10 @@ cost = paddle.layer.classification_cost(input=predictword, label=nextword) ```python parameters = paddle.parameters.create(cost) -adam_optimizer = paddle.optimizer.Adam( +adagrad = paddle.optimizer.AdaGrad( learning_rate=3e-3, regularization=paddle.optimizer.L2Regularization(8e-4)) -trainer = paddle.trainer.SGD(cost, parameters, adam_optimizer) +trainer = paddle.trainer.SGD(cost, parameters, adagrad) ``` 下一步,我们开始训练过程。`paddle.dataset.imikolov.train()`和`paddle.dataset.imikolov.test()`分别做训练和测试数据集。这两个函数各自返回一个reader——PaddlePaddle中的reader是一个Python函数,每次调用的时候返回一个Python generator。 diff --git a/04.word2vec/index.en.html b/04.word2vec/index.en.html index 307c72f430735d188e2078f43b09ed11e9edca66..64bb274d7971f07cb7c5ce908a1c6619ecbc255e 100644 --- a/04.word2vec/index.en.html +++ b/04.word2vec/index.en.html @@ -277,7 +277,8 @@ def wordemb(inlayer): name="_proj", initial_std=0.001, learning_rate=1, - l2_rate=0, )) + l2_rate=0, + sparse_update=True)) return wordemb ``` @@ -343,10 +344,10 @@ cost = paddle.layer.classification_cost(input=predictword, label=nextword) ```python parameters = paddle.parameters.create(cost) -adam_optimizer = paddle.optimizer.Adam( +adagrad = paddle.optimizer.AdaGrad( learning_rate=3e-3, regularization=paddle.optimizer.L2Regularization(8e-4)) -trainer = paddle.trainer.SGD(cost, parameters, adam_optimizer) +trainer = paddle.trainer.SGD(cost, parameters, adagrad) ``` Next, we will begin the training process. `paddle.dataset.imikolov.train()` and `paddle.dataset.imikolov.test()` is our training set and test set. Both of the function will return a **reader**: In PaddlePaddle, reader is a python function which returns a Python iterator which output a single data instance at a time. diff --git a/04.word2vec/index.html b/04.word2vec/index.html index 8fa126f5a8dd0497208cfd05b05e0faf6d18686e..caaa2bcd295ba2b6f1b2315b3875aab759c71045 100644 --- a/04.word2vec/index.html +++ b/04.word2vec/index.html @@ -262,7 +262,8 @@ def wordemb(inlayer): name="_proj", initial_std=0.001, learning_rate=1, - l2_rate=0, )) + l2_rate=0, + sparse_update=True)) return wordemb ``` @@ -332,10 +333,10 @@ cost = paddle.layer.classification_cost(input=predictword, label=nextword) ```python parameters = paddle.parameters.create(cost) -adam_optimizer = paddle.optimizer.Adam( +adagrad = paddle.optimizer.AdaGrad( learning_rate=3e-3, regularization=paddle.optimizer.L2Regularization(8e-4)) -trainer = paddle.trainer.SGD(cost, parameters, adam_optimizer) +trainer = paddle.trainer.SGD(cost, parameters, adagrad) ``` 下一步,我们开始训练过程。`paddle.dataset.imikolov.train()`和`paddle.dataset.imikolov.test()`分别做训练和测试数据集。这两个函数各自返回一个reader——PaddlePaddle中的reader是一个Python函数,每次调用的时候返回一个Python generator。