Skip to content

Commit 93107ce

Browse files
committed
add regularization for test_machine_tranlation
1 parent dd8dc0e commit 93107ce

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

python/paddle/fluid/regularizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def __call__(self, param, grad, block):
176176
dtype="float32", shape=param.shape, lod_level=param.lod_level)
177177

178178
if grad.type == core.VarDesc.VarType.SELECTED_ROWS:
179-
# add concat_rows
180179
decay = block.create_var(
181180
dtype="float32",
182181
shape=param.shape,

python/paddle/fluid/tests/book/test_machine_translation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ def train_main(use_cuda, is_sparse, is_local=True):
181181
cost = pd.cross_entropy(input=rnn_out, label=label)
182182
avg_cost = pd.mean(cost)
183183

184-
optimizer = fluid.optimizer.Adagrad(learning_rate=1e-4)
184+
optimizer = fluid.optimizer.Adagrad(
185+
learning_rate=1e-4,
186+
regularization=fluid.regularizer.L2DecayRegularizer(
187+
regularization_coeff=0.1))
185188
optimize_ops, params_grads = optimizer.minimize(avg_cost)
186189

187190
train_data = paddle.batch(

0 commit comments

Comments
 (0)