Pytorch-Is it possible to forward a tensor through a model (only Variable works)?
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.
posted on 2018-06-30 06:57 Quinn-Yann 阅读(162) 评论(0) 编辑 收藏 举报