Modify the sample code of volatile (#1694)

The original two inputs (torch.randn(5,5)) can not be used as input of resnet, which must be (batch, channels, width, height)
This commit is contained in:
Bubble
2017-06-01 21:46:04 +08:00
committed by Soumith Chintala
parent 4eb448a051
commit 447fe953e5

View File

@ -77,8 +77,8 @@ no intermediate states are saved.
.. code::
>>> regular_input = Variable(torch.randn(5, 5))
>>> volatile_input = Variable(torch.randn(5, 5), volatile=True)
>>> regular_input = Variable(torch.randn(1, 3, 227, 227))
>>> volatile_input = Variable(torch.randn(1, 3, 227, 227), volatile=True)
>>> model = torchvision.models.resnet18(pretrained=True)
>>> model(regular_input).requires_grad
True