facebookresearch / facebookresearch/co-tracker
Significant Increase in Loss when Adjusting traj_per_sample Parameter
- Dominant language
- Jupyter Notebook
- Stars
- 5.1k
- Forks
- 389
- PR merge metrics
- No merged PRs in 30d
Description
I am currently performing full fine-tuning. When I attempt to adjust the `traj_per_sample` parameter from 768 to 384 during training, the average loss approximately doubles. When I adjust the `traj_per_sample` parameter from 768 to 256, the average loss increases by about three times.
After observing this phenomenon, I carefully reviewed the code for the loss function and noticed that the loss is divided by N at the end:
```python
total_balanced_loss += balanced_loss / float(N)
```
This line of code can be found [here](https://github.com/facebookresearch/co-tracker/blob/9ed05317b794cd177674e681321780614a65e073/cotracker/models/core/cotracker/losses.py#L37).
Similarly,
```python
total_flow_loss += flow_loss / float(N)
```
This line of code can be found [here](https://github.com/facebookresearch/co-tracker/blob/9ed05317b794cd177674e681321780614a65e073/cotracker/models/core/cotracker/losses.py#L60).
I believe this might be the cause of the aforementioned increase in loss. This is because before dividing the loss by N, the `reduce_masked_mean` function already computes the mean across various dimensions. Dividing by N again leads to a larger loss when N is smaller.
I think this might be a logical error in the code. Your guidance on this issue would be greatly appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.