Solved by ptrblck in post #8 
              
              
                I guess you are transforming b_y to float before applying one_hot, not after? 
This works: 
# Train the model
criterion = nn.MSELoss()

for i, (images, labels) in enumerate(loaders['train']):
    b_x = images   # batch x
    b_y = labels  # batch y
    ohe_target = torch.nn.functional.one_hot(b_y, n…