提交 169f6512 编写于 作者: P peterzhang2029

add sum eval for to caculate ppl

上级 82611c75
...@@ -57,4 +57,4 @@ def rnn_lm(vocab_dim, ...@@ -57,4 +57,4 @@ def rnn_lm(vocab_dim,
else: else:
cost = paddle.layer.classification_cost(input=output, label=target) cost = paddle.layer.classification_cost(input=output, label=target)
return cost, output return cost
...@@ -43,9 +43,14 @@ def train(topology, ...@@ -43,9 +43,14 @@ def train(topology,
# create parameters # create parameters
parameters = paddle.parameters.create(topology) parameters = paddle.parameters.create(topology)
# create sum evaluator
sum_eval = paddle.evaluator.sum(topology)
# create trainer # create trainer
trainer = paddle.trainer.SGD( trainer = paddle.trainer.SGD(
cost=topology, parameters=parameters, update_equation=adam_optimizer) cost=topology,
parameters=parameters,
update_equation=adam_optimizer,
extra_layers=sum_eval)
# define the event_handler callback # define the event_handler callback
def event_handler(event): def event_handler(event):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册