Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change loss function in the reconstruction tutorial. #1349

Closed
binliunls opened this issue Apr 26, 2023 · 3 comments · Fixed by #1351
Closed

Breaking change loss function in the reconstruction tutorial. #1349

binliunls opened this issue Apr 26, 2023 · 3 comments · Fixed by #1351
Assignees

Comments

@binliunls
Copy link
Contributor

Describe the bug
Because of this PR, there is a breaking change in the SSIMLoss. Unfortunatelly, this loss is used in the varnet reconstruction demo . Therefore, this tutorial must be updated according to this change.

To Reproduce
Steps to reproduce the behavior:

  1. Start a MONAI 1.2.0rc5 docker
  2. Following the README file in the varnet reconstruction demo to setup the dataset.
  3. Run commands
python ./train.py\
    --data_path_train train_dir \
    --data_path_val val_dir \
    --exp varnet_mri_recon \
    --exp_dir ./ \
    --mask_type equispaced \
    --num_epochs 50 \
    --num_workers 0 \
    --lr 0.00001

Expected behavior
Start to train.

Screenshots

  File "/workspace/tutorials/monai/reconstruction/MRI_reconstruction/varnet_demo/train.py", line 186, in trainer
    loss = loss_function(output_crp, tar, max_value)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
TypeError: forward() takes 3 positional arguments but 4 were given

Environment (please complete the following information):

  • Python version: 3.8.10
  • MONAI version 1.2.0rc5
  • CUDA: 12.1
@binliunls
Copy link
Contributor Author

Hi @Can-Zhao ,
Could you please help to take a loot at this issue? I saw the data_range parameter of the loss changed every iteration in the reconstruction code. However, the new version loss just initialized it once in the __init__ function. I don't know if there is a graceful way to adapt the new version of SSIMLoss in the reconstruction code.

Thanks,
Bin

@wyli
Copy link
Contributor

wyli commented Apr 26, 2023

that's discussed here Project-MONAI/MONAI#6267 (comment)

cc @ericspod @Warvito

wyli added a commit to wyli/tutorials that referenced this issue Apr 27, 2023
Signed-off-by: Wenqi Li <[email protected]>
@wyli
Copy link
Contributor

wyli commented Apr 27, 2023

I think one way to fix it is to create the loss later in the pipeline #1351 (untested)

wyli added a commit that referenced this issue Apr 27, 2023
Fixes #1349


### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [ ] Avoid including large-size files in the PR.
- [ ] Clean up long text outputs from code cells in the notebook.
- [ ] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Wenqi Li <[email protected]>
boneseva pushed a commit to boneseva/MONAI-tutorials that referenced this issue Apr 21, 2024
Fixes Project-MONAI#1349


### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [ ] Avoid including large-size files in the PR.
- [ ] Clean up long text outputs from code cells in the notebook.
- [ ] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Wenqi Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants