When to use Variable?

Lately I read about the autogard.Variable and now I’m little bit confuse.
When should I use Variable during training?
Until now I just load batch from DataLoader, sent it to device and then run my model on it, now I saw that sometimes people warp the batch’s data with Variable before sent it to model’s forward pass, why is that? Why we need that and how this is different from what I was doing till now?

You shouldn’t use autograd.Variable anymore as it’s deprecated since PyTorch 0.4.
Use tensors directly instead.

Oh, wow, so it’s very old code…
So if i’m reading images, I only need to use the .toTensor() on the ndarray?

Yes, you would only need to transform your input to a tensor e.g. images or image-like numpy arrays via transforms.ToTensor(). There is no need to wrap the input tensor to a model into Variables anymore.