mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[docs] Remove .data from some docs (#65358)
Summary: Related to https://github.com/pytorch/pytorch/issues/30987. Fix the following task: - [ ] Remove the use of `.data` in all our internal code: - [ ] ... - [x] `docs/source/scripts/build_activation_images.py` and `docs/source/notes/extending.rst` In `docs/source/scripts/build_activation_images.py`, I used `nn.init` because the snippet already assumes `nn` is available (the class inherits from `nn.Module`). cc albanD Pull Request resolved: https://github.com/pytorch/pytorch/pull/65358 Reviewed By: malfet Differential Revision: D31061790 Pulled By: albanD fbshipit-source-id: be936c2035f0bdd49986351026fe3e932a5b4032
This commit is contained in:
committed by
Facebook GitHub Bot
parent
daa50f1e9f
commit
f0ada4bd54
@ -282,9 +282,9 @@ This is how a ``Linear`` module can be implemented::
|
|||||||
self.register_parameter('bias', None)
|
self.register_parameter('bias', None)
|
||||||
|
|
||||||
# Not a very smart way to initialize weights
|
# Not a very smart way to initialize weights
|
||||||
self.weight.data.uniform_(-0.1, 0.1)
|
nn.init.uniform_(self.weight, -0.1, 0.1)
|
||||||
if self.bias is not None:
|
if self.bias is not None:
|
||||||
self.bias.data.uniform_(-0.1, 0.1)
|
nn.init.uniform_(self.bias, -0.1, 0.1)
|
||||||
|
|
||||||
def forward(self, input):
|
def forward(self, input):
|
||||||
# See the autograd section for explanation of what happens here.
|
# See the autograd section for explanation of what happens here.
|
||||||
|
@ -58,7 +58,7 @@ def plot_function(function, **args):
|
|||||||
xrange = torch.arange(-7.0, 7.0, 0.01) # We need to go beyond 6 for ReLU6
|
xrange = torch.arange(-7.0, 7.0, 0.01) # We need to go beyond 6 for ReLU6
|
||||||
pylab.plot(
|
pylab.plot(
|
||||||
xrange.numpy(),
|
xrange.numpy(),
|
||||||
function(torch.autograd.Variable(xrange)).data.numpy(),
|
function(xrange).detach().numpy(),
|
||||||
**args
|
**args
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user