未验证 提交 688d6f61 编写于 作者: 唐树森 提交者: GitHub

fix bug: specify the dtype of w and b

上级 8d60c549
......@@ -113,8 +113,8 @@ tensor([[-1.4239, -1.3788],
我们将权重初始化成均值为0、标准差为0.01的正态随机数,偏差则初始化成0。
``` python
w = torch.from_numpy(np.random.normal(0, 0.01, (num_inputs, 1)))
b = torch.zeros(shape=(1,))
w = torch.tensor(np.random.normal(0, 0.01, (num_inputs, 1)), dtype=torch.float32)
b = torch.zeros(1, dtype=torch.float32)
```
之后的模型训练中,需要对这些参数求梯度来迭代参数的值,因此我们要让它们的`requires_grad=True`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册