提交 f4188f73 编写于 作者: Z zhangwenhui03

fix fc/gru bias parameter

上级 84edc6f7
...@@ -33,7 +33,7 @@ class CNNEncoder(object): ...@@ -33,7 +33,7 @@ class CNNEncoder(object):
""" cnn-encoder""" """ cnn-encoder"""
def __init__(self, def __init__(self,
param_name="cnn.w", param_name="cnn",
win_size=3, win_size=3,
ksize=128, ksize=128,
act='tanh', act='tanh',
...@@ -51,13 +51,15 @@ class CNNEncoder(object): ...@@ -51,13 +51,15 @@ class CNNEncoder(object):
filter_size=self.win_size, filter_size=self.win_size,
act=self.act, act=self.act,
pool_type=self.pool_type, pool_type=self.pool_type,
param_attr=str(self.param_name)) param_attr=str(str(self.param_name) + "_param"),
bias_attr=str(str(self.param_name) + "_bias"))
class GrnnEncoder(object): class GrnnEncoder(object):
""" grnn-encoder """ """ grnn-encoder """
def __init__(self, param_name="grnn.w", hidden_size=128): def __init__(self, param_name="grnn", hidden_size=128):
self.param_name = param_name self.param_name = param_name
self.hidden_size = hidden_size self.hidden_size = hidden_size
...@@ -65,13 +67,15 @@ class GrnnEncoder(object): ...@@ -65,13 +67,15 @@ class GrnnEncoder(object):
fc0 = nn.fc( fc0 = nn.fc(
input=emb, input=emb,
size=self.hidden_size * 3, size=self.hidden_size * 3,
param_attr=str(str(self.param_name) + "_fc") param_attr=str(str(self.param_name) + "_fc.w"),
bias_attr=str(str(self.param_name) + "_fc.b")
) )
gru_h = nn.dynamic_gru( gru_h = nn.dynamic_gru(
input=fc0, input=fc0,
size=self.hidden_size, size=self.hidden_size,
is_reverse=False, is_reverse=False,
param_attr=str(self.param_name)) param_attr=str(str(self.param_name) + ".param"),
bias_attr=str(str(self.param_name) + ".bias"))
return nn.sequence_pool(input=gru_h, pool_type='max') return nn.sequence_pool(input=gru_h, pool_type='max')
...@@ -139,17 +143,17 @@ class MultiviewSimnet(object): ...@@ -139,17 +143,17 @@ class MultiviewSimnet(object):
# lookup embedding for each slot # lookup embedding for each slot
q_embs = [ q_embs = [
nn.embedding( nn.embedding(
input=query, size=self.emb_shape, param_attr="emb.w") input=query, size=self.emb_shape, param_attr="emb")
for query in q_slots for query in q_slots
] ]
pt_embs = [ pt_embs = [
nn.embedding( nn.embedding(
input=title, size=self.emb_shape, param_attr="emb.w") input=title, size=self.emb_shape, param_attr="emb")
for title in pt_slots for title in pt_slots
] ]
nt_embs = [ nt_embs = [
nn.embedding( nn.embedding(
input=title, size=self.emb_shape, param_attr="emb.w") input=title, size=self.emb_shape, param_attr="emb")
for title in nt_slots for title in nt_slots
] ]
...@@ -170,9 +174,9 @@ class MultiviewSimnet(object): ...@@ -170,9 +174,9 @@ class MultiviewSimnet(object):
nt_concat = nn.concat(nt_encodes) nt_concat = nn.concat(nt_encodes)
# projection of hidden layer # projection of hidden layer
q_hid = nn.fc(q_concat, size=self.hidden_size, param_attr='q_fc.w') q_hid = nn.fc(q_concat, size=self.hidden_size, param_attr='q_fc.w', bias_attr='q_fc.b')
pt_hid = nn.fc(pt_concat, size=self.hidden_size, param_attr='t_fc.w') pt_hid = nn.fc(pt_concat, size=self.hidden_size, param_attr='t_fc.w', bias_attr='t_fc.b')
nt_hid = nn.fc(nt_concat, size=self.hidden_size, param_attr='t_fc.w') nt_hid = nn.fc(nt_concat, size=self.hidden_size, param_attr='t_fc.w', bias_attr='t_fc.b')
# cosine of hidden layers # cosine of hidden layers
cos_pos = nn.cos_sim(q_hid, pt_hid) cos_pos = nn.cos_sim(q_hid, pt_hid)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册