diff --git a/machine_translation/README.en.md b/machine_translation/README.en.md index 5d51c82bd46ad719f92d71ff382b4dfe494548b9..37631c4ad1c26e444d5234e9f50242100a6f9861 100644 --- a/machine_translation/README.en.md +++ b/machine_translation/README.en.md @@ -208,6 +208,7 @@ This subset has 193319 instances of training data and 6003 instances of test dat ### Initialize PaddlePaddle ```python +import sys import paddle.v2 as paddle # train with a single CPU @@ -396,7 +397,9 @@ for param in parameters.keys(): We need to tell trainer what to optimize, and how to optimize. Here trainer will optimize `cost` layer using stochastic gradient descent (SDG). ```python - optimizer = paddle.optimizer.Adam(learning_rate=1e-4) + optimizer = paddle.optimizer.Adam( + learning_rate=5e-5, + regularization=paddle.optimizer.L2Regularization(rate=1e-3)) trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, update_equation=optimizer) @@ -410,7 +413,7 @@ for param in parameters.keys(): def event_handler(event): if isinstance(event, paddle.event.EndIteration): if event.batch_id % 10 == 0: - print "Pass %d, Batch %d, Cost %f, %s" % ( + print "\nPass %d, Batch %d, Cost %f, %s" % ( event.pass_id, event.batch_id, event.cost, event.metrics) ``` diff --git a/machine_translation/index.en.html b/machine_translation/index.en.html index b5b767d369d7a9d9f5f6b7d992c964f8b2ccfb93..0976cc0937a88950b9edd53bb4fdf89f823b5e0a 100644 --- a/machine_translation/index.en.html +++ b/machine_translation/index.en.html @@ -250,6 +250,7 @@ This subset has 193319 instances of training data and 6003 instances of test dat ### Initialize PaddlePaddle ```python +import sys import paddle.v2 as paddle # train with a single CPU @@ -438,7 +439,9 @@ for param in parameters.keys(): We need to tell trainer what to optimize, and how to optimize. Here trainer will optimize `cost` layer using stochastic gradient descent (SDG). ```python - optimizer = paddle.optimizer.Adam(learning_rate=1e-4) + optimizer = paddle.optimizer.Adam( + learning_rate=5e-5, + regularization=paddle.optimizer.L2Regularization(rate=1e-3)) trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, update_equation=optimizer) @@ -452,7 +455,7 @@ for param in parameters.keys(): def event_handler(event): if isinstance(event, paddle.event.EndIteration): if event.batch_id % 10 == 0: - print "Pass %d, Batch %d, Cost %f, %s" % ( + print "\nPass %d, Batch %d, Cost %f, %s" % ( event.pass_id, event.batch_id, event.cost, event.metrics) ```