Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dssm infer error with gru #212

Merged
merged 3 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dssm/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Inferer(object):
def __init__(self, param_path):
logger.info("create DSSM model")

cost, prediction, label = DSSM(
prediction = DSSM(
dnn_dims=layer_dims,
vocab_sizes=[
len(load_dic(path))
Expand All @@ -104,7 +104,8 @@ def __init__(self, param_path):
model_arch=args.model_arch,
share_semantic_generator=args.share_network_between_source_target,
class_num=args.class_num,
share_embed=args.share_embed)()
share_embed=args.share_embed,
is_infer=True)()

# load parameter
logger.info("load model parameters from %s" % param_path)
Expand Down
7 changes: 3 additions & 4 deletions dssm/network_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ def create_rnn(self, emb, prefix=''):
'''
A GRU sentence vector learner.
'''
gru = paddle.layer.gru_memory(
input=emb, )
gru = paddle.networks.simple_gru(input=emb, size=256)
sent_vec = paddle.layer.last_seq(gru)
return sent_vec

Expand Down Expand Up @@ -219,7 +218,7 @@ def _build_rank_model(self):
# but this operator is not supported currently.
# so AUC will not used.
return cost, None, label
return None, [left_score, right_score], label
return right_score

def _build_classification_or_regression_model(self, is_classification):
'''
Expand Down Expand Up @@ -275,4 +274,4 @@ def _build_classification_or_regression_model(self, is_classification):

if not self.is_infer:
return cost, prediction, label
return None, prediction, label
return prediction