Skip to content

RuntimeError: SSIMLoss 3 Channel; 2D  #6267

Closed
@a-parida12

Description

@a-parida12

Describe the bug
I have a 2D image of batch size =128 and channel 3. What is the correct way to use the SSIMLOss

To Reproduce

from monai.losses.ssim_loss import SSIMLoss
criterion = SSIMLoss(spatial_dims=2)
loss = criterion(images, pred, data_range=images.max().unsqueeze(0))
# images.shape == pred.shape == torch.Size([128, 3, 64, 64])

In the above code, I get a RuntimeError.

RuntimeError: shape '[1]' is invalid for the input of size 3

Metadata

Metadata

Assignees

No one assigned

    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