I have recently started using pytorch and have written a few working models. Now i have 2 models that did not work at all and in inference only output something that looked like noise. I have now fixxed the problem by changing my data transform to Tensor from transform.PILToTensor to transforms.ToTensor and now i wanted to know what the actual difference between these two functions is as i do not see the difference in the documentation.
1 Like
PILToTensor
transforms a PIL.Image
to a PyTorch tensor of the same dtype
while ToTensor
normalizes the tensor to [0, 1]
and will return a FloatTensor
.
Usually normalized/standardized tensors are preferred while training a model as the convergence often benefits from it.
1 Like