Skip to content

monai UNET training error , diffreneces in tensor size #35

@Alisoltan82

Description

@Alisoltan82

good day,

tensor size for image , label checked from train dataloader just before the training

data = first(train_loader)
data['image'][6].shape , data['label'][6].shape

(torch.Size([1, 90, 90, 40]), torch.Size([1, 90, 90, 40]))

Model:

device = torch.device("cuda")
model = UNet(
    spatial_dims=3,
    in_channels=1,
    out_channels=3,
    channels=(16, 32, 64, 128, 256),
    strides=(2, 2, 2, 2),
    num_res_units=2,
    norm=Norm.BATCH,
).to(device)

Error:

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 5 but got size 6 for tensor number 1 in the list.

any ideas on what to check? and what are the 5 and 6 dimensions?

Note: labels have background + 2 colors not 1
Thanks

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