Skip to content

more formatting, editing, etc #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions beginner_source/quickstart/autograd_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@

##################################################################
# More help with the Pytorch Quickstart
# ----------------------
#| `Tensors <quickstart/tensor_tutorial.html>`_
# -----------------
#
#| `Tensors <tensor_tutorial.html>`_
#| `DataSets and DataLoaders <data_quickstart_tutorial.html>`_
#| `Transformations <transforms_tutorial.html>`_
#| `Build Model <build_model_tutorial.html>`_
#| `Optimization Loop <optimization_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
29 changes: 20 additions & 9 deletions beginner_source/quickstart/build_model_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
"""
Build Model Tutorial
=======================================
"""

The data has been loaded and transformed we can now build the model. We will leverage `torch.nn <https://pytorch.org/docs/stable/nn.html>`_ predefined layers that Pytorch has that can both simplify our code, and make it faster.

In the below example, for our FashionMNIT image dataset, we are using a `Sequential` container from class `torch.nn.Sequential <https://pytorch.org/docs/stable/generated/torch.nn.Sequential.html>`_ that allows us to define the model layers inline. The neural network modules layers will be added to it in the order they are passed in.

Another way this model could be bulid is with a class using `nn.Module <https://pytorch.org/docs/stable/generated/torch.nn.Module.html)>`_
###############################################
# The data has been loaded and transformed we can now build the model.
# We will leverage `torch.nn <https://pytorch.org/docs/stable/nn.html>`_
# predefined layers that Pytorch has that can both simplify our code, and make it faster.
#
# In the below example, for our FashionMNIT image dataset, we are using a `Sequential`
# container from class `torch.nn.# Sequential <https://pytorch.org/docs/stable/generated/torch.nn.Sequential.html>`_
# that allows us to define the model # layers inline.
# The neural network modules layers will be added to it in the order they are passed in.
#
# Another way this model could be bulid is with a class
# using `nn.Module <https://pytorch.org/docs/stable/generated/torch.nn.Module.html)>`_
#
# We will break down the model below.
#

We will break down the model below.
"""
##########################################
# Inline nn.Sequential Example:
# ----------------------------
#

import os
import torch
import torch.nn as nn
Expand Down Expand Up @@ -139,10 +149,11 @@ def forward(self, x):

##################################################################
# More help with the Pytorch Quickstart
# -------------------------
# -----------------
#
#| `Tensors <tensor_tutorial.html>`_
#| `DataSets and DataLoaders <data_quickstart_tutorial.html>`_
#| `Transformations <transforms_tutorial.html>`_
#| `Build Model <build_model_tutorial.html>`_
#| `Optimization Loop <optimization_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
4 changes: 2 additions & 2 deletions beginner_source/quickstart/data_quickstart_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

###############################################################
# .. figure:: /_static/img/quickstart/typesofdata.png
# :alt:
# :alt: typesofdata
#

############################################################
Expand Down Expand Up @@ -59,7 +59,7 @@

#################################################################
# .. figure:: /_static/img/quickstart/fashion_mnist.png
# :alt:
# :alt: fashion_mnist
#

#################################################################
Expand Down
7 changes: 4 additions & 3 deletions beginner_source/quickstart/optimization_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@


##################################################################
# More help with the PyTorch Quickstart
# More help with the Pytorch Quickstart
# -----------------
#| `Tensors <quickstart/tensor_tutorial.html>`_
#
#| `Tensors <tensor_tutorial.html>`_
#| `DataSets and DataLoaders <data_quickstart_tutorial.html>`_
#| `Transformations <transforms_tutorial.html>`_
#| `Build Model <build_model_tutorial.html>`_
#| `Optimization Loop <optimization_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
17 changes: 9 additions & 8 deletions beginner_source/quickstart/tensor_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@


##################################################################
# More help with the PyTorch Quickstart
# ----------------------------------------
# | `Tensors <tensor_tutorial.html>`_
# | `DataSets and DataLoaders <data_quickstart_tutorial.html>`_
# | `Transformations <transforms_tutorial.html>`_
# | `Build Model <build_model_tutorial.html>`_
# | `Optimization Loop <optimization_tutorial.html>`_
# | `AutoGrad <autograd_quickstart_tutorial.html>`_
# More help with the Pytorch Quickstart
# -----------------
#
#| `Tensors <tensor_tutorial.html>`_
#| `DataSets and DataLoaders <data_quickstart_tutorial.html>`_
#| `Transformations <transforms_tutorial.html>`_
#| `Build Model <build_model_tutorial.html>`_
#| `Optimization Loop <optimization_tutorial.html>`_
#| `AutoGrad <autograd_tutorial.html>`_
4 changes: 2 additions & 2 deletions beginner_source/quickstart/transforms_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# The `transforms.compose` allows us to string together different steps of transformations in a sequential order. This allows us to add an array of transforms for both the features and labels when preparing our data for training.
#
# *ToTensor()*
#For the feature transforms we have an array of transforms to process our image data for training. The first transform in the array is `transforms.ToTensor()` this is from class [torchvision.transforms.ToTensor](https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.ToTensor). We need to take our images and turn them into a tensor. (To learn more about Tensors check out [this]() resource.) The ToTensor() transformation is doing more than converting our image into a tensor. Its also normalizing our data for us by scaling the images to be between 0 and 1.
# For the feature transforms we have an array of transforms to process our image data for training. The first transform in the array is `transforms.ToTensor()` this is from class [torchvision.transforms.ToTensor](https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.ToTensor). We need to take our images and turn them into a tensor. (To learn more about Tensors check out [this]() resource.) The ToTensor() transformation is doing more than converting our image into a tensor. Its also normalizing our data for us by scaling the images to be between 0 and 1.
#
#
# ..note: ToTensor only normalized image data that is in PIL mode of (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1) or if the numpy.ndarray has dtype = np.uint8. In the other cases, tensors are returned without scaling.
Expand All @@ -71,7 +71,7 @@
# Target_Transform: Labels
# -------------------------------
#
#Example:
# Example:
#

target_transform= transforms.Lambda(lambda y: torch.zeros(10, dtype=torchfloat).scatter_(dim=0, index=torchtensor(y), value=1))
Expand Down
4 changes: 2 additions & 2 deletions beginner_source/quickstart_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# To see more examples and details of how to work with Tensors, Datasets, DataLoaders and Transforms in Pytoch with this example checkout these resources:
# - `DataSet and DataLoader <quickstart/data_quickstart_tutorial.html>`_
# - `Tensors <quickstart/tensor_tutorial.html>`_
# - `Transformations <quickstart/transforms_tutorial.html>`_
# - `Transforms <quickstart/transforms_tutorial.html>`_

import torch
import torch.nn as nn
Expand Down Expand Up @@ -147,7 +147,7 @@ def test(dataloader, model):
# Saving Models
# -------------
#
# PyTorch has different ways you can save your model. One was is to serialize the internal model state to a file. Another would be to use the built-in `ONNX <https://github.com/onnx/tutorials>`_ support.
# PyTorch has different ways you can save your model. One way is to serialize the internal model state to a file. Another would be to use the built-in `ONNX <https://github.com/onnx/tutorials>`_ support.

# Saving PyTorch Model Dictionary
torch.save(model.state_dict(), 'model.pth')
Expand Down