Skip to content

Commit 525614c

Browse files
authored
Merge branch 'main' into add-torchtext-tutorial
2 parents f48bc25 + be6e863 commit 525614c

27 files changed

+396
-338
lines changed

.pyspelling.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ matrix:
55
- beginner_source/*.py
66
- intermediate_source/*.py
77
- advanced_source/*.py
8+
- recipes_source/*/*.py
89
dictionary:
910
wordlists:
1011
- en-wordlist.txt
@@ -21,10 +22,13 @@ matrix:
2122
- open: ':(?:(class|py:mod|mod|func)):`'
2223
content: '[^`]*'
2324
close: '`'
25+
# Exclude reStructuredText hyperlinks
26+
- open: '\s'
27+
content: '\w*'
28+
close: '_'
2429
# Exclude raw directive
2530
- open: '\.\. (raw)::.*$\n*'
2631
close: '\n'
27-
# Exclude
2832
# Exclude Python coding directives
2933
- open: '-\*- coding:'
3034
close: '\n'

beginner_source/basics/optimization_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ def train_loop(dataloader, model, loss_fn, optimizer):
155155
loss = loss_fn(pred, y)
156156

157157
# Backpropagation
158-
optimizer.zero_grad()
159158
loss.backward()
160159
optimizer.step()
160+
optimizer.zero_grad()
161161

162162
if batch % 100 == 0:
163163
loss, current = loss.item(), (batch + 1) * len(X)

beginner_source/basics/quickstart_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def train(dataloader, model, loss_fn, optimizer):
152152
loss = loss_fn(pred, y)
153153

154154
# Backpropagation
155-
optimizer.zero_grad()
156155
loss.backward()
157156
optimizer.step()
157+
optimizer.zero_grad()
158158

159159
if batch % 100 == 0:
160160
loss, current = loss.item(), (batch + 1) * len(X)

beginner_source/basics/saveloadrun_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# To load model weights, you need to create an instance of the same model first, and then load the parameters
3434
# using ``load_state_dict()`` method.
3535

36-
model = models.vgg16() # we do not specify weights, i.e. create untrained model
36+
model = models.vgg16() # we do not specify ``weights``, i.e. create untrained model
3737
model.load_state_dict(torch.load('model_weights.pth'))
3838
model.eval()
3939

beginner_source/basics/tensorqs_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
######################################################################
134134
# **Joining tensors** You can use ``torch.cat`` to concatenate a sequence of tensors along a given dimension.
135135
# See also `torch.stack <https://pytorch.org/docs/stable/generated/torch.stack.html>`__,
136-
# another tensor joining option that is subtly different from ``torch.cat``.
136+
# another tensor joining operator that is subtly different from ``torch.cat``.
137137
t1 = torch.cat([tensor, tensor, tensor], dim=1)
138138
print(t1)
139139

beginner_source/dcgan_faces_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def forward(self, input):
514514
# practices shown in `ganhacks <https://github.com/soumith/ganhacks>`__.
515515
# Namely, we will “construct different mini-batches for real and fake”
516516
# images, and also adjust G’s objective function to maximize
517-
# :math:`logD(G(z))`. Training is split up into two main parts. Part 1
517+
# :math:`log(D(G(z)))`. Training is split up into two main parts. Part 1
518518
# updates the Discriminator and Part 2 updates the Generator.
519519
#
520520
# **Part 1 - Train the Discriminator**

beginner_source/ddp_series_theory.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ ensures each device gets a non-overlapping input batch. The model is replicated
3737
each replica calculates gradients and simultaneously synchronizes with the others using the `ring all-reduce
3838
algorithm <https://tech.preferred.jp/en/blog/technologies-behind-distributed-deep-learning-allreduce/>`__.
3939

40+
This `illustrative tutorial <https://pytorch.org/tutorials/intermediate/dist_tuto.html#>`__ provides a more in-depth python view of the mechanics of DDP.
41+
4042
Why you should prefer DDP over DataParallel (DP)
4143
-------------------------------------------------
4244

@@ -66,3 +68,4 @@ Further Reading
6668
API <https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html>`__
6769
- `DDP Internal
6870
Design <https://pytorch.org/docs/master/notes/ddp.html#internal-design>`__
71+
- `DDP Mechanics Tutorial <https://pytorch.org/tutorials/intermediate/dist_tuto.html#>`__

beginner_source/dist_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ DDP materials are listed below:
131131
4. The `Shard Optimizer States With ZeroRedundancyOptimizer <../recipes/zero_redundancy_optimizer.html>`__
132132
recipe demonstrates how `ZeroRedundancyOptimizer <https://pytorch.org/docs/stable/distributed.optim.html>`__
133133
helps to reduce optimizer memory footprint.
134-
5. The `Distributed Training with Uneven Inputs Using the Join Context Manager <../advanced/generic_oin.html>`__
134+
5. The `Distributed Training with Uneven Inputs Using the Join Context Manager <../advanced/generic_join.html>`__
135135
tutorial walks through using the generic join context for distributed training with uneven inputs.
136136

137137
torch.distributed.elastic

beginner_source/transformer_tutorial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def forward(self, x: Tensor) -> Tensor:
135135

136136
######################################################################
137137
# This tutorial uses ``torchtext`` to generate Wikitext-2 dataset.
138-
# To access torchtext datasets, please install torchdata following instructions at https://github.com/pytorch/data.
138+
# To access torchtext datasets, please install torchdata following instructions at https://github.com/pytorch/data.
139139
# %%
140140
# .. code-block:: bash
141141
#
@@ -175,7 +175,7 @@ def forward(self, x: Tensor) -> Tensor:
175175
train_iter = WikiText2(split='train')
176176
tokenizer = get_tokenizer('basic_english')
177177
vocab = build_vocab_from_iterator(map(tokenizer, train_iter), specials=['<unk>'])
178-
vocab.set_default_index(vocab['<unk>'])
178+
vocab.set_default_index(vocab['<unk>'])
179179

180180
def data_process(raw_text_iter: dataset.IterableDataset) -> Tensor:
181181
"""Converts raw text into a flat Tensor."""
@@ -196,7 +196,7 @@ def batchify(data: Tensor, bsz: int) -> Tensor:
196196
that wouldn't cleanly fit.
197197
198198
Arguments:
199-
data: Tensor, shape [N]
199+
data: Tensor, shape ``[N]``
200200
bsz: int, batch size
201201
202202
Returns:

en-wordlist.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
APIs
22
ATen
3+
AVX
34
Args
45
Autograd
56
BCE
@@ -15,8 +16,11 @@ CLS
1516
CNNDM
1617
CNNs
1718
CPUs
19+
CPython
1820
CUDA
1921
Caffe
22+
Captum
23+
Captum's
2024
CartPole
2125
Cayley
2226
Chatbots
@@ -28,6 +32,7 @@ DCGAN
2832
DCGANs
2933
DDP
3034
DDQN
35+
DLRM
3136
DNN
3237
DQN
3338
DataPipe
@@ -66,8 +71,10 @@ HVP
6671
Hugging Face
6772
IMDB
6873
IOT
74+
ISA
6975
ImageNet
7076
Initializations
77+
Interpretability
7178
Iteratively
7279
JSON
7380
JVP
@@ -95,6 +102,7 @@ NCHW
95102
NES
96103
NLP
97104
NTK
105+
NUMA
98106
NaN
99107
NanoGPT
100108
NeurIPS
@@ -103,6 +111,7 @@ Numericalization
103111
Numpy's
104112
ONNX
105113
OpenAI
114+
OpenMP
106115
PIL
107116
PPO
108117
Plotly
@@ -117,11 +126,13 @@ RPC
117126
RTX
118127
Radford
119128
ReLU
129+
ReLUs
120130
ResNet
121131
Runtime's
122132
SDPA
123133
SGD
124134
SPD
135+
SSD
125136
SST2
126137
STN
127138
SciPy
@@ -131,6 +142,7 @@ SoTA
131142
Spacy
132143
TPU
133144
TensorBoard
145+
TensorBoards
134146
TextVQA
135147
Tokenization
136148
TorchDynamo
@@ -160,19 +172,23 @@ approximators
160172
autodiff
161173
autoencoder
162174
autograd
175+
autotuner
163176
backend
164177
backends
165178
backprop
166179
backpropagate
167180
backpropagated
168181
backpropagates
169182
backpropagation
183+
backtrace
170184
batchnorm
171185
batchnorm's
172186
benchmarking
187+
bitwise
173188
boolean
174189
broadcasted
175190
bytecode
191+
cancelation
176192
cardinality
177193
chatbot
178194
chatbot's
@@ -204,10 +220,13 @@ deserialized
204220
deterministically
205221
dimensionality
206222
dir
223+
discontiguous
224+
distractor
207225
downsample
208226
downsamples
209227
dropdown
210228
duration
229+
elementwise
211230
embeddings
212231
encodings
213232
ensembling
@@ -245,6 +264,7 @@ iteratively
245264
jacobian
246265
jacobians
247266
jit
267+
jitter
248268
jpg
249269
judgements
250270
kwargs
@@ -253,6 +273,7 @@ learnable
253273
learnings
254274
loadFilename
255275
manualSeed
276+
matmul
256277
matplotlib
257278
minibatch
258279
minibatches
@@ -275,6 +296,7 @@ numericalize
275296
numpy
276297
nvFuser
277298
nvFuser's
299+
oneDNN
278300
optimizable
279301
optimizer's
280302
optimizers
@@ -286,8 +308,13 @@ parametrizations
286308
parametrized
287309
parametrizing
288310
perceptibility
311+
pickleable
289312
pipelining
290313
pointwise
314+
postprocessing
315+
preallocate
316+
preallocates
317+
preallocation
291318
precompute
292319
precomputing
293320
prepend
@@ -339,7 +366,11 @@ subdirectories
339366
submodule
340367
submodules
341368
subnetworks
369+
subprocess
370+
subprocesses
342371
subreddit
372+
subregion
373+
subregion's
343374
summarization
344375
tanh
345376
th
@@ -365,13 +396,17 @@ tradeoff
365396
tradeoffs
366397
uncomment
367398
uncommented
399+
underflowing
368400
unfused
369401
unimodal
370402
unnormalized
371403
unoptimized
372404
unparametrized
373405
unpickling
374406
unpruned
407+
unscale
408+
unscaled
409+
unscales
375410
upscaled
376411
utils
377412
vectorization
@@ -381,4 +416,5 @@ vhp
381416
voc
382417
walkthrough
383418
warmstart
419+
warmstarted
384420
warmstarting

recipes_source/recipes/Captum_Recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
normalize = transforms.Compose([
6161
transforms.ToTensor(), # converts the image to a tensor with values between 0 and 1
62-
transforms.Normalize( # normalize to follow 0-centered imagenet pixel rgb distribution
62+
transforms.Normalize( # normalize to follow 0-centered imagenet pixel RGB distribution
6363
mean=[0.485, 0.456, 0.406],
6464
std=[0.229, 0.224, 0.225]
6565
)

0 commit comments

Comments
 (0)