Skip to content

Commit f87899c

Browse files
author
Svetlana Karslioglu
authored
Merge branch 'main' into fabio
2 parents e3f19b2 + 0bee138 commit f87899c

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

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:

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))

intermediate_source/torchvision_tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Let’s write a ``torch.utils.data.Dataset`` class for this dataset.
145145
num_objs = len(obj_ids)
146146
boxes = []
147147
for i in range(num_objs):
148-
pos = np.where(masks[i])
148+
pos = np.nonzero(masks[i])
149149
xmin = np.min(pos[1])
150150
xmax = np.max(pos[1])
151151
ymin = np.min(pos[0])

0 commit comments

Comments
 (0)