Skip to content

Breaking change loss function in the reconstruction tutorial. #1349

Closed

Description

@binliunls

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

Activity

  1. binliunls commented on Apr 26, 2023

    @binliunls
    ContributorAuthor

    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

  2. wyli commented on Apr 26, 2023

    @wyli
    Contributor
  3. added a commit that references this issue on Apr 27, 2023
    de88aa4
  4. wyli commented on Apr 27, 2023

    @wyli
    Contributor

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

  5. added a commit that references this issue on Apr 27, 2023
    43c7cf7
  6. added a commit that references this issue on Apr 21, 2024
    25e6179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions