Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#309 from wang001/patch-1
Browse files Browse the repository at this point in the history
fix bug for regression where is_prediction ==true
  • Loading branch information
Meiyim authored Sep 2, 2019
2 parents 088a5ce + 333e83a commit 8c1b58a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions finetune/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,19 @@ def create_model(args,
name=task_name + "_cls_out_b",
initializer=fluid.initializer.Constant(0.)))

assert is_classify != is_regression, 'is_classify or is_regression must be true and only one of them can be true'
if is_prediction:
probs = fluid.layers.softmax(logits)
if is_classify:
probs = fluid.layers.softmax(logits)
else:
probs = logits
feed_targets_name = [
src_ids.name, sent_ids.name, pos_ids.name, input_mask.name
]
if ernie_version == "2.0":
feed_targets_name += [task_ids.name]
return pyreader, probs, feed_targets_name

assert is_classify != is_regression, 'is_classify or is_regression must be true and only one of them can be true'
num_seqs = fluid.layers.create_tensor(dtype='int64')
if is_classify:
ce_loss, probs = fluid.layers.softmax_with_cross_entropy(
Expand Down

0 comments on commit 8c1b58a

Please sign in to comment.