Skip to content

Commit b856efd

Browse files
committed
2 parents a27bc7f + 307c0e3 commit b856efd

File tree

180 files changed

+6363
-4795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+6363
-4795
lines changed

_data/wizard.yml

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,41 @@
3636
matcher: 'conda,linux,cudanone,python3.6'
3737
cmd: 'conda install pytorch-cpu torchvision-cpu -c pytorch'
3838
-
39-
matcher: 'conda,osx,cuda8,python2.7'
40-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
39+
matcher: 'conda,macos,cuda8,python2.7'
40+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
4141
-
42-
matcher: 'conda,osx,cuda9.0,python2.7'
43-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
42+
matcher: 'conda,macos,cuda9.0,python2.7'
43+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
4444
-
45-
matcher: 'conda,osx,cuda9.1,python2.7'
46-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
45+
matcher: 'conda,macos,cuda9.1,python2.7'
46+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
4747
-
48-
matcher: 'conda,osx,cudanone,python2.7'
49-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
48+
matcher: 'conda,macos,cudanone,python2.7'
49+
cmd: 'conda install pytorch torchvision -c pytorch'
5050
-
51-
matcher: 'conda,osx,cuda8,python3.5'
52-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
51+
matcher: 'conda,macos,cuda8,python3.5'
52+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
5353
-
54-
matcher: 'conda,osx,cuda9.0,python3.5'
55-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
54+
matcher: 'conda,macos,cuda9.0,python3.5'
55+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
5656
-
57-
matcher: 'conda,osx,cuda9.1,python3.5'
58-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
57+
matcher: 'conda,macos,cuda9.1,python3.5'
58+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
5959
-
60-
matcher: 'conda,osx,cudanone,python3.5'
61-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
60+
matcher: 'conda,macos,cudanone,python3.5'
61+
cmd: 'conda install pytorch torchvision -c pytorch'
6262
-
63-
matcher: 'conda,osx,cuda8,python3.6'
64-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
63+
matcher: 'conda,macos,cuda8,python3.6'
64+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
6565
-
66-
matcher: 'conda,osx,cuda9.0,python3.6'
67-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
66+
matcher: 'conda,macos,cuda9.0,python3.6'
67+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
6868
-
69-
matcher: 'conda,osx,cuda9.1,python3.6'
70-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
69+
matcher: 'conda,macos,cuda9.1,python3.6'
70+
cmd: 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
7171
-
72-
matcher: 'conda,osx,cudanone,python3.6'
73-
cmd: 'conda install pytorch torchvision -c pytorch <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
72+
matcher: 'conda,macos,cudanone,python3.6'
73+
cmd: 'conda install pytorch torchvision -c pytorch'
7474
-
7575
matcher: 'conda,windows,cuda8,python2.7'
7676
cmd: '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.'
@@ -109,43 +109,43 @@
109109
cmd: 'conda install pytorch-cpu -c pytorch <br /> pip3 install torchvision'
110110

111111
############ pip section #########################
112-
######### macOS ######################
112+
######### macos ######################
113113
-
114-
matcher: 'pip,osx,cuda8,python2.7'
115-
cmd: 'pip install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
114+
matcher: 'pip,macos,cuda8,python2.7'
115+
cmd: 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
116116
-
117-
matcher: 'pip,osx,cuda9.0,python2.7'
118-
cmd: 'pip install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
117+
matcher: 'pip,macos,cuda9.0,python2.7'
118+
cmd: 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
119119
-
120-
matcher: 'pip,osx,cuda9.1,python2.7'
121-
cmd: 'pip install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
120+
matcher: 'pip,macos,cuda9.1,python2.7'
121+
cmd: 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
122122
-
123-
matcher: 'pip,osx,cudanone,python2.7'
124-
cmd: 'pip install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
123+
matcher: 'pip,macos,cudanone,python2.7'
124+
cmd: 'pip install torch torchvision'
125125
-
126-
matcher: 'pip,osx,cuda8,python3.5'
127-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
126+
matcher: 'pip,macos,cuda8,python3.5'
127+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
128128
-
129-
matcher: 'pip,osx,cuda9.0,python3.5'
130-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
129+
matcher: 'pip,macos,cuda9.0,python3.5'
130+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
131131
-
132-
matcher: 'pip,osx,cuda9.1,python3.5'
133-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
132+
matcher: 'pip,macos,cuda9.1,python3.5'
133+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
134134
-
135-
matcher: 'pip,osx,cudanone,python3.5'
136-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
135+
matcher: 'pip,macos,cudanone,python3.5'
136+
cmd: 'pip3 install torch torchvision'
137137
-
138-
matcher: 'pip,osx,cuda8,python3.6'
139-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
138+
matcher: 'pip,macos,cuda8,python3.6'
139+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
140140
-
141-
matcher: 'pip,osx,cuda9.0,python3.6'
142-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
141+
matcher: 'pip,macos,cuda9.0,python3.6'
142+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
143143
-
144-
matcher: 'pip,osx,cuda9.1,python3.6'
145-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
144+
matcher: 'pip,macos,cuda9.1,python3.6'
145+
cmd: 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed'
146146
-
147-
matcher: 'pip,osx,cudanone,python3.6'
148-
cmd: 'pip3 install torch torchvision <br /> # macOS Binaries dont support CUDA, install from source if CUDA is needed'
147+
matcher: 'pip,macos,cudanone,python3.6'
148+
cmd: 'pip3 install torch torchvision'
149149
######### Linux ######################
150150
-
151151
matcher: 'pip,linux,cudanone,python2.7'

_posts/2018-04-22-0_4_0-migration-guide.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,41 @@ True
8686

8787
However, ``.data`` can be unsafe in some cases. Any changes on ``x.data`` wouldn't be tracked by ``autograd``, and the computed gradients would be incorrect if ``x`` is needed in a backward pass. A safer alternative is to use [``x.detach()``](http://pytorch.org/docs/master/autograd.html#torch.Tensor.detach), which also returns a ``Tensor`` that shares data with ``requires_grad=False``, but will have its in-place changes reported by ``autograd`` if ``x`` is needed in backward.
8888

89+
Here is an example of the difference between ``.data`` and ``x.detach()`` (and why we recommend using ``detach`` in general).
90+
91+
If you use ``Tensor.detach()``, the gradient computation is guaranteed to be correct.
92+
93+
```
94+
>>> a = torch.tensor([1,2,3.], requires_grad = True)
95+
>>> out = a.sigmoid()
96+
>>> c = out.detach()
97+
>>> c.zero_()
98+
tensor([ 0., 0., 0.])
99+
100+
>>> out # modified by c.zero_() !!
101+
tensor([ 0., 0., 0.])
102+
103+
>>> out.sum().backward() # Requires the original value of out, but that was overwritten by c.zero_()
104+
RuntimeError: one of the variables needed for gradient computation has been modified by an
105+
```
106+
107+
However, using ``Tensor.data`` can be unsafe and can easly result in incorrect gradients
108+
when a tensor is required for gradient computation but modified in-place.
109+
110+
```
111+
>>> a = torch.tensor([1,2,3.], requires_grad = True)
112+
>>> out = a.sigmoid()
113+
>>> c = out.data
114+
>>> c.zero_()
115+
tensor([ 0., 0., 0.])
116+
117+
>>> out # out was modified by c.zero_()
118+
tensor([ 0., 0., 0.])
119+
120+
>>> out.sum().backward()
121+
>>> a.grad # The result is very, very wrong because `out` changed!
122+
tensor([ 0., 0., 0.])
123+
```
89124

90125
## Support for 0-dimensional (scalar) Tensors
91126

0 commit comments

Comments
 (0)