Solved by ptrblck in post #2 
              
              
                This error is raised, if you try to pass a 4-dimensional image tensor to transforms.ToPILImage(), i.e. if it contains the batch dimension. 
To avoid this you would have to call this transformation in a loop for each tensor. 
Note however, that this approach would break the computation graph and your…