Project-MONAI / Project-MONAI/MONAI
Shape of class_weight in FocalLoss changed after saving checkpoint.
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
When criterion and net are bundled, the shape class_weight in focal loss is changed in state_dict in after saving checkpoint. line184-185 change to loss = self.class_weight.view(broadcast_dims) * loss is a better way to avoid shape changing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at monai/losses/focal_loss.py lines 184-185 and inspect how class_weight is represented when criterion and net are bundled into a checkpoint. Reproduce a save/load cycle and verify that the state_dict preserves its shape after the loss calculation change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100