Skip to content

Commit 6cc04a0

Browse files
authored
Merge branch 'master' into jingxu10
2 parents 884423a + a162702 commit 6cc04a0

File tree

8 files changed

+127
-15
lines changed

8 files changed

+127
-15
lines changed

_static/images/microsoft-logo.svg

Lines changed: 80 additions & 0 deletions
Loading

_templates/layout.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@
33
{% block footer %}
44
{{ super() }}
55
<script>
6+
7+
8+
//add microsoft link
9+
10+
if(window.location.href.indexOf("/beginner/basics/")!= -1)
11+
{
12+
var url="https://docs.microsoft.com/learn/paths/pytorch-fundamentals/?wt.mc_id=aiml-7486-cxa";
13+
switch(window.location.pathname.split("/").pop().replace('.html',''))
14+
{
15+
case"quickstart_tutorial":
16+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/9-quickstart?WT.mc_id=aiml-7486-cxa";
17+
break;
18+
case"tensorqs_tutorial":
19+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/2-tensors?WT.mc_id=aiml-7486-cxa";
20+
break;
21+
case"data_tutorial":
22+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/3-data?WT.mc_id=aiml-7486-cxa";
23+
break;
24+
case"transforms_tutorial":
25+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/4-transforms?WT.mc_id=aiml-7486-cxa";
26+
break;
27+
case"buildmodel_tutorial":
28+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/5-model?WT.mc_id=aiml-7486-cxa";
29+
break;
30+
case"autogradqs_tutorial":
31+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/6-autograd?WT.mc_id=aiml-7486-cxa";
32+
break;
33+
case"optimization_tutorial":
34+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/7-optimization?WT.mc_id=aiml-7486-cxa";
35+
break;
36+
case"saveloadrun_tutorial":
37+
url="https://docs.microsoft.com/learn/modules/intro-machine-learning-pytorch/8-inference?WT.mc_id=aiml-7486-cxa";
38+
}
39+
40+
$(".pytorch-call-to-action-links").children().first().before("<a href="+url+' data-behavior="call-to-action-event" data-response="Run in Microsoft Learn" target="_blank"><div id="microsoft-learn-link" style="padding-bottom: 0.625rem;border-bottom: 1px solid #f3f4f7;padding-right: 2.5rem;display: -webkit-box; display: -ms-flexbox; isplay: flex; -webkit-box-align: center;-ms-flex-align: center;align-items: center;"><img class="call-to-action-img" src="../../_static/images/microsoft-logo.svg"/><div class="call-to-action-desktop-view">Run in Microsoft Learn</div><div class="call-to-action-mobile-view">Learn</div></div></a>')
41+
}
42+
643
!function(f,b,e,v,n,t,s)
744
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
845
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
@@ -46,6 +83,8 @@
4683
$(".rating-container").hide();
4784
$(".hr-bottom").hide();
4885
}
86+
87+
4988
</script>
5089

5190
<noscript>

beginner_source/basics/data_tutorial.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# -------------------
3636
#
3737
# Here is an example of how to load the `Fashion-MNIST <https://research.zalando.com/project/fashion_mnist/fashion_mnist/>`_ dataset from TorchVision.
38-
# Fashion-MNIST is a dataset of Zalando’s article images consisting of of 60,000 training examples and 10,000 test examples.
38+
# Fashion-MNIST is a dataset of Zalando’s article images consisting of 60,000 training examples and 10,000 test examples.
3939
# Each example comprises a 28×28 grayscale image and an associated label from one of 10 classes.
4040
#
4141
# We load the `FashionMNIST Dataset <https://pytorch.org/vision/stable/datasets.html#fashion-mnist>`_ with the following parameters:
@@ -140,8 +140,7 @@ def __getitem__(self, idx):
140140
image = self.transform(image)
141141
if self.target_transform:
142142
label = self.target_transform(label)
143-
sample = {"image": image, "label": label}
144-
return sample
143+
return image, label
145144

146145

147146
#################################################################
@@ -187,7 +186,7 @@ def __len__(self):
187186
# The __getitem__ function loads and returns a sample from the dataset at the given index ``idx``.
188187
# Based on the index, it identifies the image's location on disk, converts that to a tensor using ``read_image``, retrieves the
189188
# corresponding label from the csv data in ``self.img_labels``, calls the transform functions on them (if applicable), and returns the
190-
# tensor image and corresponding label in a Python dict.
189+
# tensor image and corresponding label in a tuple.
191190

192191
def __getitem__(self, idx):
193192
img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])
@@ -197,8 +196,7 @@ def __getitem__(self, idx):
197196
image = self.transform(image)
198197
if self.target_transform:
199198
label = self.target_transform(label)
200-
sample = {"image": image, "label": label}
201-
return sample
199+
return image, label
202200

203201

204202
######################################################################

beginner_source/basics/intro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
------------------
3535
You can run this tutorial in a couple of ways:
3636
37-
- **In the cloud**: This is the easiest way to get started! Each section has a Colab link at the top, which opens a notebook with the code in a fully-hosted environment. Pro tip: Use Colab with a GPU runtime to speed up operations *Runtime > Change runtime type > GPU*
37+
- **In the cloud**: This is the easiest way to get started! Each section has a "Run in Microsoft Learn" link at the top, which opens an integrated notebook in Microsoft Learn with the code in a fully-hosted environment.
3838
- **Locally**: This option requires you to setup PyTorch and TorchVision first on your local machine (`installation instructions <https://pytorch.org/get-started/locally/>`_). Download the notebook or copy the code into your favorite IDE.
3939
4040

beginner_source/chatbot_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ def evaluate(encoder, decoder, searcher, voc, sentence, max_length=MAX_LENGTH):
12071207
input_batch = torch.LongTensor(indexes_batch).transpose(0, 1)
12081208
# Use appropriate device
12091209
input_batch = input_batch.to(device)
1210-
lengths = lengths.to(device)
1210+
lengths = lengths.to("cpu")
12111211
# Decode sentence with searcher
12121212
tokens, scores = searcher(input_batch, lengths, max_length)
12131213
# indexes -> words

index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
Welcome to PyTorch Tutorials
22
============================
3-
.. raw:: html
4-
5-
<p>Share your thoughts. Take our short <a href=https://forms.gle/ekTZY4uSJaw5Vr849 target="_blank">PyTorch Tutorials reader survey</a>. </p>
6-
7-
83
.. raw:: html
94

105
<div class="tutorials-callout-container">

intermediate_source/dist_tuto.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ to obtain the sum of all tensors at all processes, we can use the
207207
208208
""" All-Reduce example."""
209209
def run(rank, size):
210-
""" Simple point-to-point communication. """
210+
""" Simple collective communication. """
211211
group = dist.new_group([0, 1])
212212
tensor = torch.ones(1)
213213
dist.all_reduce(tensor, op=dist.ReduceOp.SUM, group=group)

intermediate_source/seq2seq_translation_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
# the networks later. To keep track of all this we will use a helper class
140140
# called ``Lang`` which has word → index (``word2index``) and index → word
141141
# (``index2word``) dictionaries, as well as a count of each word
142-
# ``word2count`` to use to later replace rare words.
142+
# ``word2count`` which will be used to replace rare words later.
143143
#
144144

145145
SOS_token = 0

0 commit comments

Comments
 (0)