PacktPublishing/Modern-Computer-Vision-with-PyTorch

Chapter 9 - UNET

troylane opened this issue · 1 comments

Hello,

First Thanks for this book. It is a great learning and reference tool.

I am trying to apply the UNET exercise to my own data. My data masks only have 2 integers [0,1]

I have prepared the data as highlighted in the chapter content. I have made one change which is ce(loss) = = BCELoss instead of cross entropy loss.

I have also changed out_channels=2 (representing the 2 values listed above).

When I run training, I get the following error:

ValueError: Using a target size (torch.Size([4, 512, 512])) that is different to the input size (torch.Size([4, 2, 512, 512])) is deprecated. Please ensure they have the same size.

Any help addressing this would be appreciated.

Hello @troylane, thank you for the feedback.

Since you are using BCELoss, it is okay to have only one output channel which will tell if the map is 0/1.
Ensure your target is of shape 4x1x512x512 as opposed to 4x512x512 as given above

image