Pytorch-Is it possible to forward a tensor through a model (only Variable works)?
阿新 • • 發佈:2018-06-30
array arrays 圖片 operation hat near aci efi HR
In Pytorch 0.4, I can forward a tensor through a model which is the same as Variable.
import torch print(torch.__version__)
Maybe in Pytorch version < 0.4, it is not possible to forward a tensor through am model.
Ref to:
https://discuss.pytorch.org/t/what-is-the-difference-between-tensors-and-variables-in-pytorch/4914/3
The Variable class is a wrapper over torch Tensors (nd arrays in torch) that supports nearly all operations defined on tensors. PyTorch requires that the input tensor to be forward propagated has to be wrapped in a Variable. This facilitates automatic back propagation by simply calling the method backward() in the Variable class.
Pytorch-Is it possible to forward a tensor through a model (only Variable works)?