Skip to content

Commit

Permalink
NCF fix, normalize running loss (#537)
Browse files Browse the repository at this point in the history
Correct printed running loss 
---------

Co-authored-by: Quoc-Tuan Truong <[email protected]>
  • Loading branch information
hieuddo and tqtg authored Oct 24, 2023
1 parent d300be2 commit 9b06a51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cornac/models/ncf/recom_ncf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def _fit_tf(self):
batch_users, batch_items, batch_ratings
),
)
count += len(batch_ratings)
sum_loss += _loss * len(batch_ratings)
count += len(batch_users)
sum_loss += len(batch_users) * _loss
if i % 10 == 0:
loop.set_postfix(loss=(sum_loss / count))

Expand Down Expand Up @@ -242,7 +242,7 @@ def _fit_pt(self):
optimizer.step()

count += len(batch_users)
sum_loss += loss.data.item()
sum_loss += len(batch_users) * loss.data.item()

if batch_id % 10 == 0:
loop.set_postfix(loss=(sum_loss / count))
Expand Down

0 comments on commit 9b06a51

Please sign in to comment.