This is first my end2end deep learning project and I have trying to train a U-Net with images with 3 channels and labels with 1 channel respectively. However, since I need to specify the in_channels as part of my training loop in the network, I am not sure where and how the network can take in 1 channel input label.
Here is the training_loop and Dataloader for reference:
And lastly, the subsequent Dataset module, sorry for spamming, many thanks in advance for your help
And this is the runtime error, after it was successfully loaded the 3 channels images, but the loop then encounter the 1 channel label:
Based on the error message that’s not the case as at least the current input image has a single channel only.
Iterate the dataset once and check the shape of all input tensors.
Once you’ve found the samples with a single channel, add a transformation to the
__getitem__ and e.g. repeat the channel dimension to create 3 channels.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier