Project-MONAI / research-contributions

Implementations of recent research prototypes/demonstrations using MONAI.
https://monai.io/
Apache License 2.0
995 stars 328 forks source link

Different number of input channels #284

Open sunni426 opened 1 year ago

sunni426 commented 1 year ago

Hello, I am running the UNETR on a dataset with 7 labels, so the number of my output channels would be 7+1 (background) = 8. How should I modify the patch embedding weights and other parameters to fit this? Currently, using the default parameters for BTCV Dataset, I am getting multiples of these errors: "../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block: [291,0,0], thread: [64,0,0] Assertion idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failed."

model = UNETR( in_channels=1, out_channels=8, img_size=(96, 96, 96), feature_size=16, hidden_size=768, mlp_dim=3072, num_heads=12, pos_embed="perceptron", norm_name="instance", res_block=True, dropout_rate=0.0, ).to(device)

Thanks in advance!

windyjunfeng commented 11 months ago

hello, have you solved it? I met the same problem. Thank you~

windyjunfeng commented 11 months ago

That's OK. I have made it. I found there was something wrong in mask labels. (The correct format is 0, 1, 2, ..., N-1, where N is the class number. But the format of my label is some other value larger than N-1.) Finally, I changed the format of my label.

sunni426 commented 11 months ago

Apologies for the late reply! Yes, I also solved it by changing the values of my labels to index it in a way that the code can access.

windyjunfeng commented 11 months ago

OK, thank you very much!