未验证 提交 6d637a93 编写于 作者: L lilu 提交者: GitHub

test=develop (#2249)

上级 0a31618b
...@@ -11,10 +11,12 @@ import math ...@@ -11,10 +11,12 @@ import math
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle import paddle
class Network(object): class Network(object):
""" """
Network Network
""" """
def __init__(self, def __init__(self,
vocab_size, vocab_size,
emb_size, emb_size,
...@@ -44,8 +46,7 @@ class Network(object): ...@@ -44,8 +46,7 @@ class Network(object):
name="context_wordseq", shape=[1], dtype="int64", lod_level=1) name="context_wordseq", shape=[1], dtype="int64", lod_level=1)
response_wordseq = fluid.layers.data( response_wordseq = fluid.layers.data(
name="response_wordseq", shape=[1], dtype="int64", lod_level=1) name="response_wordseq", shape=[1], dtype="int64", lod_level=1)
label = fluid.layers.data( label = fluid.layers.data(name="label", shape=[1], dtype="float32")
name="label", shape=[1], dtype="float32")
self._feed_name = ["context_wordseq", "response_wordseq", "label"] self._feed_name = ["context_wordseq", "response_wordseq", "label"]
self._feed_infer_name = ["context_wordseq", "response_wordseq"] self._feed_infer_name = ["context_wordseq", "response_wordseq"]
...@@ -111,6 +112,7 @@ class Network(object): ...@@ -111,6 +112,7 @@ class Network(object):
elif loss_type == 'L2': elif loss_type == 'L2':
norm_score = 2 * fluid.layers.sigmoid(logits) norm_score = 2 * fluid.layers.sigmoid(logits)
loss = fluid.layers.square_error_cost(norm_score, label) / 4 loss = fluid.layers.square_error_cost(norm_score, label) / 4
loss = fluid.layers.reduce_mean(loss)
else: else:
raise ValueError raise ValueError
...@@ -135,4 +137,3 @@ class Network(object): ...@@ -135,4 +137,3 @@ class Network(object):
Return inference names Return inference names
""" """
return self._feed_infer_name return self._feed_infer_name
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册