tensor.detach()
creates a tensor that shares storage withtensor
that does not requires grad. This will remove a tensor from a computation graph.
tensor.clone()
creates a copy of tensor that imitates the originaltensor
'srequires_grad
field. This still keeps the copy as a part of the computational graph it came from.
tensor.data
returns a new tensor that shares storage withtensor
. But it always hasrequires_grad=False
.- gradient 可以理解成一阶近似,所以梯度可以理解成某个变量
Pytorch 几个采坑点
猜你喜欢
转载自www.cnblogs.com/lifengfan/p/10367911.html
今日推荐
周排行