tensorflow / tensorflow/recommenders

The loss computed in the last step is significantly smaller compared to the previous steps

Open
#709 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
300
PR merge metrics
No merged PRs in 30d

Description

tfrs.tasks.Retrieval uses the tf.keras.losses.CategoricalCrossentropy loss function by default.
I think that the number of classes in tf.keras.losses.CategoricalCrossentropy equals the batch size when we don't set the num_hard_negatives.

Usually, the batch size in the last step is smaller than the batch size we have set.
Therefore, it seems that the loss in the last steps during training is smaller than in the previous steps.

I was confused by the small loss values because the logs only display the loss from the last step when outputting the loss for each epoch.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is identified in the issue. First reproduce training with a final undersized batch and inspect the retrieval loss and epoch logging; done means establishing whether the loss calculation or the reported value is incorrect and identifying the affected code or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.