码迷,mamicode.com
首页 > 其他好文 > 详细

Pytorch-Is it possible to forward a tensor through a model (only Variable works)?

时间:2018-06-30 11:00:37      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:com   ons   version   https   strong   diff   ssi   imp   ref   

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)?

标签:com   ons   version   https   strong   diff   ssi   imp   ref   

原文地址:https://www.cnblogs.com/quinn-yann/p/9245978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!