Skip to content

Commit 0f854b7

Browse files
author
Svetlana Karslioglu
authored
Merge branch 'main' into main
2 parents 782bfe2 + 56a2faf commit 0f854b7

21 files changed

+102
-71
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Fixes #ISSUE_NUMBER
88
- [ ] The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
99
- [ ] Only one issue is addressed in this pull request
1010
- [ ] Labels from the issue that this PR is fixing are added to this pull request
11-
- [ ] No unnessessary issues are included into this pull request.
11+
- [ ] No unnecessary issues are included into this pull request.

.github/scripts/docathon-label-sync.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def main():
1414
repo = g.get_repo(f'{repo_owner}/{repo_name}')
1515
pull_request = repo.get_pull(pull_request_number)
1616
pull_request_body = pull_request.body
17+
# PR without description
18+
if pull_request_body is None:
19+
return
1720

1821
# get issue number from the PR body
1922
if not re.search(r'#\d{1,5}', pull_request_body):

advanced_source/neural_style_tutorial.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ def run_style_transfer(cnn, normalization_mean, normalization_std,
423423
# We want to optimize the input and not the model parameters so we
424424
# update all the requires_grad fields accordingly
425425
input_img.requires_grad_(True)
426+
# We also put the model in evaluation mode, so that specific layers
427+
# such as dropout or batch normalization layers behave correctly.
428+
model.eval()
426429
model.requires_grad_(False)
427430

428431
optimizer = get_input_optimizer(input_img)

advanced_source/super_resolution_with_onnxruntime.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
and `ONNX Runtime <https://github.com/microsoft/onnxruntime>`__.
1717
You can get binary builds of ONNX and ONNX Runtime with
1818
``pip install onnx onnxruntime``.
19-
Note that ONNX Runtime is compatible with Python versions 3.5 to 3.7.
20-
21-
``NOTE``: This tutorial needs PyTorch master branch which can be installed by following
22-
the instructions `here <https://github.com/pytorch/pytorch#from-source>`__
19+
ONNX Runtime recommends using the latest stable runtime for PyTorch.
2320
2421
"""
2522

beginner_source/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Beginner Tutorials
2323

2424
6. transformer_translation.py
2525
Language Translation with Transformers
26-
https://pytorch.org/tutorials/beginner/transformer_tutorial.html
26+
https://pytorch.org/tutorials/beginner/translation_transformer.html

beginner_source/deep_learning_60min_blitz.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ Goal of this tutorial:
2020
- Understand PyTorch’s Tensor library and neural networks at a high level.
2121
- Train a small neural network to classify images
2222

23-
To run the tutorials below, make sure you have the `torch`_ and `torchvision`_
24-
packages installed.
23+
To run the tutorials below, make sure you have the `torch`_, `torchvision`_,
24+
and `matplotlib`_ packages installed.
2525

2626
.. _torch: https://github.com/pytorch/pytorch
2727
.. _torchvision: https://github.com/pytorch/vision
28+
.. _matplotlib: https://github.com/matplotlib/matplotlib
2829

2930
.. toctree::
3031
:hidden:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Finetuning Torchvision Models
2+
=============================
3+
4+
This tutorial has been moved to https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
5+
6+
It will redirect in 3 seconds.
7+
8+
.. raw:: html
9+
10+
<meta http-equiv="Refresh" content="3; url='https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html'" />

beginner_source/former_torchies/parallelism_tutorial.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def forward(self, x):
5353

5454
class MyDataParallel(nn.DataParallel):
5555
def __getattr__(self, name):
56-
return getattr(self.module, name)
56+
try:
57+
return super().__getattr__(name)
58+
except AttributeError:
59+
return getattr(self.module, name)
5760

5861
########################################################################
5962
# **Primitives on which DataParallel is implemented upon:**

beginner_source/introyt/tensorboardyt_tutorial.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464
# PyTorch TensorBoard support
6565
from torch.utils.tensorboard import SummaryWriter
6666

67+
# In case you are using an environment that has TensorFlow installed,
68+
# such as Google Colab, uncomment the following code to avoid
69+
# a bug with saving embeddings to your TensorBoard directory
70+
71+
# import tensorflow as tf
72+
# import tensorboard as tb
73+
# tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
6774

6875
######################################################################
6976
# Showing Images in TensorBoard

beginner_source/introyt/trainingyt.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,19 @@ def train_one_epoch(epoch_index, tb_writer):
290290
model.train(True)
291291
avg_loss = train_one_epoch(epoch_number, writer)
292292

293-
# We don't need gradients on to do reporting
294-
model.train(False)
295-
293+
296294
running_vloss = 0.0
297-
for i, vdata in enumerate(validation_loader):
298-
vinputs, vlabels = vdata
299-
voutputs = model(vinputs)
300-
vloss = loss_fn(voutputs, vlabels)
301-
running_vloss += vloss
295+
# Set the model to evaluation mode, disabling dropout and using population
296+
# statistics for batch normalization.
297+
model.eval()
298+
299+
# Disable gradient computation and reduce memory consumption.
300+
with torch.no_grad():
301+
for i, vdata in enumerate(validation_loader):
302+
vinputs, vlabels = vdata
303+
voutputs = model(vinputs)
304+
vloss = loss_fn(voutputs, vlabels)
305+
running_vloss += vloss
302306

303307
avg_vloss = running_vloss / (i + 1)
304308
print('LOSS train {} valid {}'.format(avg_loss, avg_vloss))

0 commit comments

Comments
 (0)