Skip to content

Commit 3a06265

Browse files
authored
Merge pull request #440 from frankwhzhang/lr_fix_0517
fix lr loss bug
2 parents 1d385ad + d823c6b commit 3a06265

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

models/rank/logistic_regression/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runner:
2020
use_auc: True
2121
train_batch_size: 2
2222
epochs: 3
23-
print_interval: 2
23+
print_interval: 1
2424
#model_init_path: "output_model/0" # init model
2525
model_save_path: "output_model_lr"
2626
test_data_dir: "data/sample_data/train"

models/rank/logistic_regression/dygraph_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def create_feeds(self, batch_data, config):
3838
label = paddle.to_tensor(batch_data[0].numpy().astype('int64').reshape(
3939
-1, 1))
4040
feat_idx = paddle.to_tensor(batch_data[1].numpy().astype('int64')
41-
.reshape(-1, 1))
41+
.reshape(-1, num_field))
4242
raw_feat_value = paddle.to_tensor(batch_data[2].numpy().astype(
43-
'float32').reshape(-1, 1))
43+
'float32').reshape(-1, num_field))
4444
feat_value = paddle.reshape(raw_feat_value,
4545
[-1, num_field]) # None * num_field * 1
4646
return label, feat_idx, feat_value
@@ -50,7 +50,7 @@ def create_loss(self, pred, label):
5050
cost = paddle.nn.functional.log_loss(
5151
input=pred, label=paddle.cast(
5252
label, dtype="float32"))
53-
avg_cost = paddle.mean(x=cost)
53+
avg_cost = paddle.sum(x=cost)
5454
return avg_cost
5555

5656
# define optimizer

0 commit comments

Comments
 (0)