title: pytorch 0.4迁移
date: 2018-07-29 15:11:09
type()
1 2 3
| 本来是 type() 现在是 isinstance(x, torch.DoubleTensor), x.type()
|
Tensor(1, requires_grad=True)
1 2 3 4 5
| w = torch.ones(1, requires_grad=True) 或者是 w = w.requires_grad_() total = w + z total.backward()
|
.data 和 .detach()使用
推荐使用.detach()
0.3.0里面sum区别
tensor.sum()would return a Python number, butvariable.sum()would return a vector of size(1,).
弃用volatile, 使用torch.no_grad()
1 2 3 4 5
| with torch.no_grad(): y = x * 2 with torch.set_grad_enable(is_train): y = x * 2
|
