《code-of-learn-deep-learning-with-pytorch》学习笔记


https://github.com/L1aoXingyu/code-of-learn-deep-learning-with-pytorch/

chapter 2

AttributeError: ‘module’ object has no attribute ‘ones_like’

问题:找不到ones_like函数
分析
1)138服务器,conda创建0.2.0环境
2)import torch
解决方案:测试发现,可以用ones(x.size())来替代,ones_like函数

PyTorch中backward参数理解

x = Variable(torch.randn(3), requires_grad=True)
y = 2 * x
y.backward(torch.FloatTensor([1, 0.1, 0.01]))

y.backward(torch.FloatTensor([1, 1, 1])),结果是他们每个分量的梯度;
y.backward(torch.FloatTensor([1, 0.1, 0.01])),结果是原本的梯度分别乘上1,0.1,0.01.

猜你喜欢

转载自blog.csdn.net/cp_oldy/article/details/87891689
今日推荐