I just found out that this line of code (from the previous version…) was raising the error:
torch.set_default_tensor_type(‘torch.cuda.FloatTensor’)
The problem was indeed not the normalize function itself, thanks!