You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# We define our neural network by subclassing ``nn.Module``, and
46
+
# We define our neural network by subclassing ``nn.Module``, and
47
47
# initialize the neural network layers in ``__init__``. Every ``nn.Module`` subclass implements
48
-
# the operations on input data in the ``forward`` method.
48
+
# the operations on input data in the ``forward`` method.
49
49
50
50
classNeuralNetwork(nn.Module):
51
51
def__init__(self):
@@ -66,7 +66,7 @@ def forward(self, x):
66
66
returnlogits
67
67
68
68
##############################################
69
-
# We create an instance of ``NeuralNetwork``, and move it to the ``device``, and print
69
+
# We create an instance of ``NeuralNetwork``, and move it to the ``device``, and print
70
70
# its structure.
71
71
72
72
model=NeuralNetwork().to(device)
@@ -75,14 +75,14 @@ def forward(self, x):
75
75
76
76
##############################################
77
77
# To use the model, we pass it the input data. This executes the model's ``forward``,
78
-
# along with some `background operations <https://github.com/pytorch/pytorch/blob/270111b7b611d174967ed204776985cefca9c144/torch/nn/modules/module.py#L866>`_.
78
+
# along with some `background operations <https://github.com/pytorch/pytorch/blob/270111b7b611d174967ed204776985cefca9c144/torch/nn/modules/module.py#L866>`_.
79
79
# Do not call ``model.forward()`` directly!
80
-
#
80
+
#
81
81
# Calling the model on the input returns a 10-dimensional tensor with raw predicted values for each class.
82
82
# We get the prediction probabilities by passing it through an instance of the ``nn.Softmax`` module.
83
83
84
84
X=torch.rand(1, 28, 28, device=device)
85
-
logits=model(X)
85
+
logits=model(X)
86
86
pred_probab=nn.Softmax(dim=1)(logits)
87
87
y_pred=pred_probab.argmax(1)
88
88
print(f"Predicted class: {y_pred}")
@@ -97,26 +97,26 @@ def forward(self, x):
97
97
# Model Layers
98
98
# -------------------------
99
99
#
100
-
# Let's break down the layers in the FashionMNIST model. To illustrate it, we
101
-
# will take a sample minibatch of 3 images of size 28x28 and see what happens to it as
102
-
# we pass it through the network.
100
+
# Let's break down the layers in the FashionMNIST model. To illustrate it, we
101
+
# will take a sample minibatch of 3 images of size 28x28 and see what happens to it as
Most machine learning workflows involve working with data, creating models, optimizing model
23
-
parameters, and saving the trained models. This tutorial introduces you to a complete ML workflow
22
+
Most machine learning workflows involve working with data, creating models, optimizing model
23
+
parameters, and saving the trained models. This tutorial introduces you to a complete ML workflow
24
24
implemented in PyTorch, with links to learn more about each of these concepts.
25
25
26
-
We'll use the FashionMNIST dataset to train a neural network that predicts if an input image belongs
27
-
to one of the following classes: T-shirt/top, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker,
28
-
Bag, or Ankle boot.
26
+
We'll use the FashionMNIST dataset to train a neural network that predicts if an input image belongs
27
+
to one of the following classes: T-shirt/top, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker,
28
+
Bag, or Ankle boot.
29
29
30
30
`This tutorial assumes a basic familiarity with Python and Deep Learning concepts.`
31
31
@@ -34,12 +34,12 @@
34
34
------------------
35
35
You can run this tutorial in a couple of ways:
36
36
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.
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.
38
38
- **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.
39
39
40
40
41
41
How to Use this Guide
42
-
-----------------
42
+
-----------------
43
43
If you're familiar with other deep learning frameworks, check out the `0. Quickstart <quickstart_tutorial.html>`_ first
44
44
to quickly familiarize yourself with PyTorch's API.
0 commit comments