Skip to content

Commit b11054f

Browse files
authored
Merge branch 'main' into splion-360/rl-qlearning-fixes
2 parents 3d084c6 + 06f9c4b commit b11054f

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

advanced_source/dynamic_quantization_tutorial.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,18 @@ def tokenize(self, path):
134134
# -----------------------------
135135
#
136136
# This is a tutorial on dynamic quantization, a quantization technique
137-
# that is applied after a model has been trained. Therefore, we'll simply load some
138-
# pretrained weights into this model architecture; these weights were obtained
139-
# by training for five epochs using the default settings in the word language model
140-
# example.
137+
# that is applied after a model has been trained. Therefore, we'll simply
138+
# load some pretrained weights into this model architecture; these
139+
# weights were obtained by training for five epochs using the default
140+
# settings in the word language model example.
141+
#
142+
# Before running this tutorial, download the required pre-trained model:
143+
#
144+
# .. code-block:: bash
145+
#
146+
# wget https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth
147+
#
148+
# Place the downloaded file in the data directory or update the model_data_filepath accordingly.
141149

142150
ntokens = len(corpus.dictionary)
143151

beginner_source/examples_autograd/polynomial_custom_function.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ def forward(ctx, input):
3333
"""
3434
In the forward pass we receive a Tensor containing the input and return
3535
a Tensor containing the output. ctx is a context object that can be used
36-
to stash information for backward computation. You can cache arbitrary
37-
objects for use in the backward pass using the ctx.save_for_backward method.
36+
to stash information for backward computation. You can cache tensors for
37+
use in the backward pass using the ``ctx.save_for_backward`` method. Other
38+
objects can be stored directly as attributes on the ctx object, such as
39+
``ctx.my_object = my_object``. Check out `Extending torch.autograd <https://docs.pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd>`_
40+
for further details.
3841
"""
3942
ctx.save_for_backward(input)
4043
return 0.5 * (5 * input ** 3 - 3 * input)

beginner_source/introyt/introyt1_tutorial.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,21 @@ def num_flat_features(self, x):
303303
# The values passed to the transform are the means (first tuple) and the
304304
# standard deviations (second tuple) of the rgb values of the images in
305305
# the dataset. You can calculate these values yourself by running these
306-
# few lines of code:
307-
# ```
308-
# from torch.utils.data import ConcatDataset
309-
# transform = transforms.Compose([transforms.ToTensor()])
310-
# trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
306+
# few lines of code::
307+
#
308+
# from torch.utils.data import ConcatDataset
309+
# transform = transforms.Compose([transforms.ToTensor()])
310+
# trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
311311
# download=True, transform=transform)
312312
#
313-
# #stack all train images together into a tensor of shape
314-
# #(50000, 3, 32, 32)
315-
# x = torch.stack([sample[0] for sample in ConcatDataset([trainset])])
313+
# # stack all train images together into a tensor of shape
314+
# # (50000, 3, 32, 32)
315+
# x = torch.stack([sample[0] for sample in ConcatDataset([trainset])])
316316
#
317-
# #get the mean of each channel
318-
# mean = torch.mean(x, dim=(0,2,3)) #tensor([0.4914, 0.4822, 0.4465])
319-
# std = torch.std(x, dim=(0,2,3)) #tensor([0.2470, 0.2435, 0.2616])
320-
#
321-
# ```
317+
# # get the mean of each channel
318+
# mean = torch.mean(x, dim=(0,2,3)) # tensor([0.4914, 0.4822, 0.4465])
319+
# std = torch.std(x, dim=(0,2,3)) # tensor([0.2470, 0.2435, 0.2616])
320+
#
322321
#
323322
# There are many more transforms available, including cropping, centering,
324323
# rotation, and reflection.

intermediate_source/ddp_tutorial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ Let's still use the Toymodel example and create a file named ``elastic_ddp.py``.
311311

312312
.. code:: python
313313
314+
import os
314315
import torch
315316
import torch.distributed as dist
316317
import torch.nn as nn

intermediate_source/flask_rest_api_tutorial.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ def get_prediction(image_bytes):
321321
# for deploying a Flask server in production.
322322
#
323323
# - You can also add a UI by creating a page with a form which takes the image and
324-
# displays the prediction. Check out the `demo <https://pytorch-imagenet.herokuapp.com/>`_
325-
# of a similar project and its `source code <https://github.com/avinassh/pytorch-flask-api-heroku>`_.
326-
#
324+
# displays the prediction.
327325
# - In this tutorial, we only showed how to build a service that could return predictions for
328326
# a single image at a time. We could modify our service to be able to return predictions for
329327
# multiple images at once. In addition, the `service-streamer <https://github.com/ShannonAI/service-streamer>`_

0 commit comments

Comments
 (0)