Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
ce31579
added basic devcontainer
sethjuarez Nov 2, 2020
a0ce8e1
added more complete devcontainer
sethjuarez Nov 2, 2020
390e283
added auto reload for in browser editing
sethjuarez Nov 2, 2020
6271276
moved pip packages for codespaces to the end
sethjuarez Nov 2, 2020
762ca9d
corrected auto preview
sethjuarez Nov 2, 2020
31cb408
added better ignore criteria for watch
sethjuarez Nov 2, 2020
97300e3
added quickstart and folder for sub-docs
sethjuarez Nov 3, 2020
5aa2c24
added staging build for reviews
sethjuarez Nov 4, 2020
1a023b4
corrected yaml error
sethjuarez Nov 4, 2020
3588209
another yaml correction
sethjuarez Nov 4, 2020
ebf5aa8
revised yaml
sethjuarez Nov 4, 2020
fa26938
changed job name
sethjuarez Nov 4, 2020
4cb5ce2
added tutorial files and work on data and tensors
cassiebreviu Nov 4, 2020
f86760a
fixing syntax issues
cassiebreviu Nov 5, 2020
fccac71
fix syntax
cassiebreviu Nov 5, 2020
d527c8c
renamed file
cassiebreviu Nov 5, 2020
031b9df
syntax fix
cassiebreviu Nov 5, 2020
2bcdc8c
Merge pull request #1 from cassieview/seth-blitz
sethjuarez Nov 5, 2020
bd782b0
Add tensors, autograd tutorials
shwars Nov 5, 2020
40a261c
more work on quickstart
cassiebreviu Nov 5, 2020
1fff4d1
updated optimization tutorial
cassiebreviu Nov 5, 2020
41e866a
added more links to quickstart main page
cassiebreviu Nov 5, 2020
86e5834
Merge pull request #2 from shwars/seth-blitz
sethjuarez Nov 5, 2020
ef51239
Merge branch 'seth-blitz' of https://github.com/cassieview/tutorials …
sethjuarez Nov 5, 2020
6cf32e3
Merge branch 'cassieview-seth-blitz' into seth-blitz
sethjuarez Nov 5, 2020
7d62395
merged content
sethjuarez Nov 5, 2020
ad410b6
removed links at bottom of page causing error
cassiebreviu Nov 5, 2020
9a740b6
Merge branch 'seth-blitz' into seth-blitz
cassiebreviu Nov 5, 2020
3e60a85
Merge pull request #4 from cassieview/seth-blitz
cassiebreviu Nov 5, 2020
c7d4159
fix data formatting
cassiebreviu Nov 6, 2020
d4e4cfd
Merge branch 'seth-blitz' of https://github.com/cassieview/tutorials …
cassiebreviu Nov 6, 2020
506eac2
fix on optimization formatting
cassiebreviu Nov 6, 2020
edffc4a
more updates on sections and formatting
cassiebreviu Nov 6, 2020
45767c2
Merge pull request #5 from cassieview/seth-blitz
cassiebreviu Nov 6, 2020
72f5848
work on autograd
cassiebreviu Nov 6, 2020
486bf5b
more format work
cassiebreviu Nov 6, 2020
675bfe5
Merge pull request #6 from cassieview/seth-blitz
cassiebreviu Nov 6, 2020
2c72883
add images
cassiebreviu Nov 6, 2020
8f249aa
add images to data and optimization
cassiebreviu Nov 6, 2020
54a5bfb
Merge pull request #7 from cassieview/seth-blitz
cassiebreviu Nov 6, 2020
911a07a
moved images fixed links
cassiebreviu Nov 9, 2020
783b83c
Merge pull request #8 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
c881fe3
more work on quickstart
cassiebreviu Nov 9, 2020
2a1d814
Merge pull request #9 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
8592289
more updates to make quickstart page
cassiebreviu Nov 9, 2020
f610061
Merge pull request #10 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
89d5902
fix subsections on main quickstart
cassiebreviu Nov 9, 2020
52285c6
Merge pull request #11 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
ad5023a
updates to main, data and model
cassiebreviu Nov 9, 2020
67bba76
Merge pull request #12 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
5175725
format updates
cassiebreviu Nov 9, 2020
dc8bc32
Merge pull request #13 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
3bd01bb
fix link, fix format, fix stuff
cassiebreviu Nov 9, 2020
e49761a
Merge pull request #14 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
374f8cf
more formatting
cassiebreviu Nov 9, 2020
9404252
Merge pull request #15 from cassieview/seth-blitz
cassiebreviu Nov 9, 2020
138420a
fix image and format
cassiebreviu Nov 10, 2020
3a34561
Merge pull request #16 from cassieview/seth-blitz
cassiebreviu Nov 10, 2020
b01c6c7
tensor updates
cassiebreviu Nov 10, 2020
8e06cf1
Merge pull request #17 from cassieview/seth-blitz
cassiebreviu Nov 10, 2020
ee60f9f
format fixes
cassiebreviu Nov 10, 2020
99f3613
more formatting
cassiebreviu Nov 10, 2020
398a0ed
Merge pull request #18 from cassieview/seth-blitz
cassiebreviu Nov 10, 2020
43716fb
fix note formatting and optimzation text
cassiebreviu Nov 10, 2020
7e2881d
img rename optmization formatting
cassiebreviu Nov 10, 2020
5485db3
Merge pull request #20 from cassieview/seth-blitz
cassiebreviu Nov 10, 2020
0823df8
updated links, next text, model format
cassiebreviu Nov 10, 2020
316a91b
Merge pull request #21 from cassieview/seth-blitz
cassiebreviu Nov 10, 2020
6319625
fix transforms and autograd link
cassiebreviu Nov 11, 2020
91249f2
Merge pull request #22 from cassieview/seth-blitz
cassiebreviu Nov 11, 2020
d18db14
fixers gonna fix
cassiebreviu Nov 11, 2020
9fb1450
Fixed formatting, move autograd before optimization
shwars Nov 11, 2020
feeb669
Merge pull request #23 from shwars/seth-blitz
cassiebreviu Nov 11, 2020
5bb6be1
Merge remote-tracking branch 'upstream/seth-blitz' into seth-blitz
cassiebreviu Nov 11, 2020
ab22cdc
Merge branch 'seth-blitz' into seth-blitz
cassiebreviu Dec 7, 2020
ed51b90
Merge branch 'seth-blitz' of https://github.com/sethjuarez/tutorials …
cassiebreviu Dec 7, 2020
45a02c6
Added more detail to the intro of the quickstart
cassiebreviu Dec 7, 2020
ac96721
primitive dataset text update
cassiebreviu Dec 8, 2020
0a3c261
fix build model
cassiebreviu Dec 8, 2020
ab9c2ce
updated quickstart to class model
cassiebreviu Dec 9, 2020
202bda0
Merge branch 'seth-blitz' into seth-blitz
cassiebreviu Dec 9, 2020
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
20 changes: 14 additions & 6 deletions beginner_source/quickstart/build_model_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
###############################################
# 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 simplify our code.

# predefined layers that PyTorch has that can simplify our code.
#
# 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>`_
Expand Down Expand Up @@ -53,18 +54,26 @@
# --------------------------
#

class NeuralNework(nn.Module):
def __init__(self, x):
super(NeuralNework, self).__init__()

class NeuralNetwork(nn.Module):
def __init__(self):
super(NeuralNetwork, self).__init__()
self.flatten = nn.Flatten()
self.layer1 = nn.Linear(28*28, 512)
self.layer2 = nn.Linear(512, 512)
self.output = nn.Linear(512, 10)

def forward(self, x):

x = self.flatten(x)
x = F.relu(self.layer1(x))
x = F.relu(self.layer2(x))
x = self.output(x)
return F.softmax(x, dim=1)
model = NeuralNetwork().to(device)

print(model)


#############################################
# Get Device for Training
Expand All @@ -90,8 +99,6 @@ def forward(self, x):
#
# From the docs:
# ``torch.nn.Flatten(start_dim: int = 1, end_dim: int = -1)``
#

# Here is an example using one of the training_data set items:
tensor = training_data[0][0]
print(tensor.size())
Expand All @@ -112,6 +119,7 @@ def forward(self, x):
#
# Now that we have flattened our tensor dimension we will apply a linear layer transform that will calculate/learn the weights and the bias.
#

# From the docs:
#
# ``torch.nn.Linear(in_features: int, out_features: int, bias: bool = True)``
Expand Down
38 changes: 22 additions & 16 deletions beginner_source/quickstart_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
#
# PyTorch has two basic data primitives: ``DataSet`` and ``DataLoader``.
# The `torchvision.datasets` ``DataSet`` object includes a ``transforms`` mechanism to
# modify data in-place. Below is an example of how to load that data from the Pytorch open datasets and transform the data to a normalized tensor.

# modify data in-place. Below is an example of how to load that data from the PyTorch open datasets and transform the data to a normalized tensor.
# This example is using the `torchvision.datasets` which is a subclass from the primitive `torch.utils.data.Dataset`. Note that the primitive dataset doesnt have the built in transforms param like the built in dataset in `torchvision.datasets.`
#
# To see more examples and details of how to work with Tensors, Datasets, DataLoaders and Transforms in Pytoch with this example checkout these resources:
# To see more examples and details of how to work with Tensors, Datasets, DataLoaders and Transforms in PyTorch with this example checkout these resources:
#
# - `Tensors <quickstart/tensor_tutorial.html>`_
# - `DataSet and DataLoader <quickstart/data_quickstart_tutorial.html>`_
Expand All @@ -29,6 +28,7 @@
import matplotlib.pyplot as plt
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import torch.nn.functional as F

classes = ["T-shirt/top", "Trouser", "Pullover", "Dress", "Coat", "Sandal", "Shirt", "Sneaker", "Bag", "Ankle boot"]

Expand All @@ -51,26 +51,32 @@
train_dataloader = DataLoader(training_data, batch_size=batch_size, num_workers=0, pin_memory=True)
test_dataloader = DataLoader(test_data, batch_size=batch_size, num_workers=0, pin_memory=True)

################################
# Creating Models
# ---------------
#
# There are two ways of creating models: in-line or as a class. This
# quickstart will consider an in-line definition. For more examples checkout `building the model <quickstart/build_model_tutorial.html>`_.
# quickstart will consider a class definition. For more examples checkout `building the model <quickstart/build_model_tutorial.html>`_.

device = 'cuda' if torch.cuda.is_available() else 'cpu'
print('Using {} device'.format(device))

# in-line model

model = nn.Sequential(
nn.Flatten(),
nn.Linear(28*28, 512),
nn.ReLU(),
nn.Linear(512, 512),
nn.ReLU(),
nn.Linear(512, len(classes)),
nn.Softmax(dim=1)
).to(device)
# Define model
class NeuralNetwork(nn.Module):
def __init__(self):
super(NeuralNetwork, self).__init__()
self.flatten = nn.Flatten()
self.layer1 = nn.Linear(28*28, 512)
self.layer2 = nn.Linear(512, 512)
self.output = nn.Linear(512, 10)

def forward(self, x):
x = self.flatten(x)
x = F.relu(self.layer1(x))
x = F.relu(self.layer2(x))
x = self.output(x)
return F.softmax(x, dim=1)
model = NeuralNetwork().to(device)

print(model)

Expand Down Expand Up @@ -193,7 +199,7 @@ def test(dataloader, model):
print(f'Predicted: "{predicted}", Actual: "{actual}"')

##################################################################
# Pytorch Quickstart Topics
# PyTorch Quickstart Topics
# ----------------------------------------
# | `Tensors <quickstart/tensor_tutorial.html>`_
# | `DataSets and DataLoaders <quickstart/data_quickstart_tutorial.html>`_
Expand Down