Solved by anujd9 in post #3 
              
              
                Hi. I think this error is due to different sized images at input. Make sure to resize the images and the mask to a common size using the Resize() transform before training the model.