SlideShare a Scribd company logo
Deep Learning with
“What is deep learning?”
Machine learning is turning things (data)
into numbers and finding patterns in those
numbers.
The computer does this part.
How?
Code & math.
We’re going to be writing the code.
Arti
fi
cial
Intelligence
Machine
Learning
Machine Learning vs. Deep Learning
Deep
Learning
Traditional
programming
Machine
learning
algorithm
Starts with
Inputs Output
1. Cut vegetables
2. Season chicken
3. Preheat oven
4. Cook chicken for 30-minutes
5. Add vegetables
Starts with
Inputs Rules
Makes
Output
Figures out
1. Cut vegetables
2. Season chicken
3. Preheat oven
4. Cook chicken for 30-minutes
5. Add vegetables
Rules
“Why use machine learning (or
deep learning)?”
Better reason: For a complex
problem, can you think of all the rules?
(probably not)
Good reason: Why not?
Source: 2020 Machine Learning Roadmap video.
— A wise software engineer… (actually rule 1 of Google’s Machine Learning Handbook)
“If you can build a simple rule-based system
that doesn’t require machine learning, do
that.”
(maybe not very simple…)
What deep learning is good for
• Problems with long lists of rules—when the traditional
approach fails, machine learning/deep learning may help.
• Continually changing environments—deep learning can
adapt (‘learn’) to new scenarios.
• Discovering insights within large collections of data—can
you imagine trying to hand-craft rules for what 101 di
ff
erent
kinds of food look like?
🤖✅
What deep learning is not good for
• When you need explainability—the patterns learned by a deep
learning model are typically uninterpretable by a human.
• When the traditional approach is a better option — if you can
accomplish what you need with a simple rule-based system.
• When errors are unacceptable — since the outputs of deep
learning model aren’t always predictable.
• When you don’t have much data — deep learning models
usually require a fairly large amount of data to produce great
results.
🤖🚫
(typically)
(though we’ll see how to get great results without huge amounts of data)
Unstructured data
Deep
Learning
Machine Learning vs. Deep Learning
Structured data
Machine
Learning
Algorithm: neural
network
Algorithm: gradient
boosted machine
Machine Learning vs. Deep Learning
Structured data Unstructured data
• Random forest
• Gradient boosted models
• Naive Bayes
• Nearest neighbour
• Support vector machine
• …many more
• Neural networks
• Fully connected neural network
• Convolutional neural network
• Recurrent neural network
• Transformer
• …many more
What we’re focused on building
(with PyTorch)
(since the advent of deep learning these are
often referred to as “shallow algorithms”)
(depending how you represent your problem,
many algorithms can be used for both)
(common algorithms)
“What are neural networks?”
Neural Networks
[[116, 78, 15],
[117, 43, 96],
[125, 87, 23],
…,
[[0.983, 0.004, 0.013],
[0.110, 0.889, 0.001],
[0.023, 0.027, 0.985],
…,
Inputs
Numerical
encoding
Learns
representation
(patterns/features/weights)
Representation
outputs
Outputs
(a human can
understand these)
Ramen,
Spaghetti
Not a diaster
“Hey Siri, what’s
the weather
today?”
(choose the appropriate
neural network for your
problem)
(before data gets used
with a neural network,
it needs to be turned
into numbers)
Each of these nodes is
called a “hidden unit”
or “neuron”.
Anatomy of Neural Networks
Input layer
(data goes in here)
Output layer
(outputs learned representation or
prediction probabilities)
Hidden layer(s)
(learns patterns in data)
Note: “patterns” is an arbitrary term, you’ll often hear “embedding”, “weights”, “feature representation”,
“feature vectors” all referring to similar things.
# units/neurons = 2
# units/neurons = 3
# units/neurons = 1
Each layer is usually combination of
linear (straight line) and/or non-
linear (not-straight line) functions
Overall
architecture
Supervised
Learning
Unsupervised &
Self-supervised
Learning
Transfer
Learning
Types of Learning
We’ll be writing code to do these,
but the style of code can be adopted across learning paradigms.
“What is deep learning actually
used for?”
Source: 2020 Machine Learning Roadmap video.
Deep Learning Use Cases
Recommendation Translation
“Hey Siri, who’s the
biggest big dog of
them all?”
Speech recognition
Computer Vision Natural Language Processing (NLP)
To: daniel@mrdbourke.com
Hey Daniel,
This deep learning course is incredible!
I can’t wait to use what I’ve learned!
To: daniel@mrdbourke.com
Hay daniel…
C0ongratu1ations! U win $1139239230
Spam
Not spam
Sequence to sequence
(seq2seq)
Classi
fi
cation/regression
(some)
00_pytorch_and_deep_learning_fundamentals.pdf
“What is PyTorch?”
What is PyTorch?
• Most popular research deep learning framework*
• Write fast deep learning code in Python (able to run on a GPU/many
GPUs)
• Able to access many pre-built deep learning models (Torch Hub/
torchvision.models)
• Whole stack: preprocess data, model data, deploy model in your
application/cloud
• Originally designed and used in-house by Facebook/Meta (now open-
source and used by companies such as Tesla, Microsoft, OpenAI)
*Source: paperswithcode.com/trends February 2022
Why PyTorch?
Research favourite
Source: paperswithcode.com/trends February 2022
Why PyTorch?
Source: @fchollet Twitter
and PyTorch
Why PyTorch?
What is a GPU/TPU?
GPU (Graphics Processing Unit)
TPU (Tensor Processing Unit)
“What is a tensor?”
Neural Networks
[[116, 78, 15],
[117, 43, 96],
[125, 87, 23],
…,
[[0.983, 0.004, 0.013],
[0.110, 0.889, 0.001],
[0.023, 0.027, 0.985],
…,
Inputs
Numerical
encoding
Learns
representation
(patterns/features/weights)
Representation
outputs
Outputs
(a human can
understand these)
Ramen,
Spaghetti
Not spam
“Hey Siri, what’s
the weather
today?”
(choose the appropriate
neural network for your
problem)
(before data gets used
with an algorithm, it
needs to be turned into
numbers)
These are tensors!
[[116, 78, 15],
[117, 43, 96],
[125, 87, 23],
…,
[[0.983, 0.004, 0.013],
[0.110, 0.889, 0.001],
[0.023, 0.027, 0.985],
…,
Inputs
Numerical
encoding
Learns
representation
(patterns/features/weights)
Representation
outputs
Outputs
Ramen,
Spaghetti
These are tensors!
“What are we going to
cover?”
Source: @elonmusk Twitter
• Now:
• PyTorch basics & fundamentals (dealing with tensors and tensor operations)
• Later:
• Preprocessing data (getting it into tensors)
• Building and using pretrained deep learning models
• Fitting a model to the data (learning patterns)
• Making predictions with a model (using patterns)
• Evaluating model predictions
• Saving and loading models
• Using a trained model to make predictions on custom data
How: 👩🔬
👩🍳
What we’re going to cover
(broadly)
(we’ll be cooking up lots of code!)
What we’re going to cover
A PyTorch workflow
(one of many)
“How should I approach
this course?”
2. Explore and
experiment
How to approach this course
1. Code along
Motto #1: if in doubt, run the code!
Motto #2:
Experiment, experiment,
experiment!
3. Visualize what you
don’t understand
Motto #3:
Visualize, visualize, visualize!
4. Ask questions
🛠
5. Do the exercises
🤗
6. Share your work
(including the
“dumb” ones)
How not to approach this course
Avoid: 🧠
🔥
🔥
🔥 “I can’t learn
______”
Resources
https://www.github.com/mrdbourke/pytorch-deep-learning
Course materials
https://www.github.com/mrdbourke/pytorch-deep-learning/
discussions
Course Q&A
https://learnpytorch.io
Course online book
PyTorch website &
forums
This course
All things PyTorch
Let’s code!
tensor([[[1, 2, 3],
[3, 6, 9],
[2, 4, 5]]])
0
1
2
0 1 2
tensor([[[1, 2, 3],
[3, 6, 9],
[2, 4, 5]]])
tensor([[[1, 2, 3],
[3, 6, 9],
[2, 4, 5]]])
torch.Size([1, 3, 3])
0 1 2
Dimension (dim)
dim=0
dim=1
dim=2
Tensor dimensions
20 0 24 44
A*J + B*L + C*N A*K + B*M + C*O
D*J + E*L + F*N D*K + E*M + F*O
G*J + H*L + I*N G*K + H*M + I*O
44 38
126 86
58 63
4 6 8
5 0 3
3x2
3x3 3x2
4 7
6 8
8 1
J K
L M
N O
5 0 3
3 7 9
3 5 2
A B C
D E F
G H I
Dot product
3x3 3x2
torch.matmul( )
, )
* * *
= = =
+ +
3x2
For a live demo, checkout www.matrixmultiplication.xyz
Numbers on the inside must match New size is same as outside numbers
=
torch.matmul(
,
[[116, 78, 15],
[117, 43, 96],
[125, 87, 23],
…,
[[0.983, 0.004, 0.013],
[0.110, 0.889, 0.001],
[0.023, 0.027, 0.985],
…,
Inputs
Numerical
encoding
Learns
representation
(patterns/features/weights)
Representation
outputs
Outputs
Ramen,
Spaghetti
[[0.092, 0.210, 0.415],
[0.778, 0.929, 0.030],
[0.019, 0.182, 0.555],
…,
1. Initialise with random
weights (only at beginning)
2. Show examples
3. Update representation
outputs
4. Repeat with more
examples
Supervised
learning
(overview)
Tensor attributes
Attribute Meaning Code
Shape
The length (number of elements) of
each of the dimensions of a tensor.
tensor.shape
Rank/dimensions
The total number of tensor
dimensions. A scalar has rank 0, a
vector has rank 1, a matrix is rank 2, a
tensor has rank n.
tensor.ndim or tensor.size()
Speci
fi
c axis or dimension (e.g. “1st
axis” or “0th dimension”)
A particular dimension of a tensor. tensor[0], tensor[:, 1]…
00_pytorch_and_deep_learning_fundamentals.pdf

More Related Content

Similar to 00_pytorch_and_deep_learning_fundamentals.pdf (20)

PDF
PyTorch for Deep Learning Practitioners
Bayu Aldi Yansyah
 
PPTX
AI Deep Learning - CF Machine Learning
Karl Seiler
 
PDF
Deep-Learning-with-PydddddddddddddTorch.pdf
drjigarsoni28
 
PDF
0b85886e-4490-4af0-8b46-7ff3caf5dc2e.pdf
phailinpsp
 
PDF
Neural network book. Interesting and precise
ShilpaMaratheSardesa
 
PPTX
Deep learning short introduction
Adwait Bhave
 
PDF
Main principles of Data Science and Machine Learning
Nikolay Karelin
 
PPTX
Deep Learning Jump Start
Michele Toni
 
PPTX
Mastering PyTorch: A Comprehensive Guide for Deep Learning Enthusiasts
YourTechDiet
 
PDF
Neural Networks, Spark MLlib, Deep Learning
Asim Jalis
 
PDF
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
Edureka!
 
PDF
Intro to TensorFlow and PyTorch Workshop at Tubular Labs
Kendall
 
PDF
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
Roelof Pieters
 
PDF
Getting started with Machine Learning
Gaurav Bhalotia
 
PDF
01_pytorch_workflow jutedssd huge hhgggdf
stuartkyeswa4
 
PDF
Machine learning the next revolution or just another hype
Jorge Ferrer
 
PPTX
Pytroch-basic.pptx
rebeen4
 
PDF
Deep Learning in a nutshell
HopeBay Technologies, Inc.
 
PDF
Deep learning: Cutting through the Myths and Hype
Siby Jose Plathottam
 
PyTorch for Deep Learning Practitioners
Bayu Aldi Yansyah
 
AI Deep Learning - CF Machine Learning
Karl Seiler
 
Deep-Learning-with-PydddddddddddddTorch.pdf
drjigarsoni28
 
0b85886e-4490-4af0-8b46-7ff3caf5dc2e.pdf
phailinpsp
 
Neural network book. Interesting and precise
ShilpaMaratheSardesa
 
Deep learning short introduction
Adwait Bhave
 
Main principles of Data Science and Machine Learning
Nikolay Karelin
 
Deep Learning Jump Start
Michele Toni
 
Mastering PyTorch: A Comprehensive Guide for Deep Learning Enthusiasts
YourTechDiet
 
Neural Networks, Spark MLlib, Deep Learning
Asim Jalis
 
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
Edureka!
 
Intro to TensorFlow and PyTorch Workshop at Tubular Labs
Kendall
 
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
Roelof Pieters
 
Getting started with Machine Learning
Gaurav Bhalotia
 
01_pytorch_workflow jutedssd huge hhgggdf
stuartkyeswa4
 
Machine learning the next revolution or just another hype
Jorge Ferrer
 
Pytroch-basic.pptx
rebeen4
 
Deep Learning in a nutshell
HopeBay Technologies, Inc.
 
Deep learning: Cutting through the Myths and Hype
Siby Jose Plathottam
 

Recently uploaded (20)

PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPT
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
epi editorial commitee meeting presentation
MIPLM
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Ad

00_pytorch_and_deep_learning_fundamentals.pdf

  • 2. “What is deep learning?”
  • 3. Machine learning is turning things (data) into numbers and finding patterns in those numbers. The computer does this part. How? Code & math. We’re going to be writing the code.
  • 5. Traditional programming Machine learning algorithm Starts with Inputs Output 1. Cut vegetables 2. Season chicken 3. Preheat oven 4. Cook chicken for 30-minutes 5. Add vegetables Starts with Inputs Rules Makes Output Figures out 1. Cut vegetables 2. Season chicken 3. Preheat oven 4. Cook chicken for 30-minutes 5. Add vegetables Rules
  • 6. “Why use machine learning (or deep learning)?”
  • 7. Better reason: For a complex problem, can you think of all the rules? (probably not) Good reason: Why not?
  • 8. Source: 2020 Machine Learning Roadmap video.
  • 9. — A wise software engineer… (actually rule 1 of Google’s Machine Learning Handbook) “If you can build a simple rule-based system that doesn’t require machine learning, do that.” (maybe not very simple…)
  • 10. What deep learning is good for • Problems with long lists of rules—when the traditional approach fails, machine learning/deep learning may help. • Continually changing environments—deep learning can adapt (‘learn’) to new scenarios. • Discovering insights within large collections of data—can you imagine trying to hand-craft rules for what 101 di ff erent kinds of food look like? 🤖✅
  • 11. What deep learning is not good for • When you need explainability—the patterns learned by a deep learning model are typically uninterpretable by a human. • When the traditional approach is a better option — if you can accomplish what you need with a simple rule-based system. • When errors are unacceptable — since the outputs of deep learning model aren’t always predictable. • When you don’t have much data — deep learning models usually require a fairly large amount of data to produce great results. 🤖🚫 (typically) (though we’ll see how to get great results without huge amounts of data)
  • 12. Unstructured data Deep Learning Machine Learning vs. Deep Learning Structured data Machine Learning Algorithm: neural network Algorithm: gradient boosted machine
  • 13. Machine Learning vs. Deep Learning Structured data Unstructured data • Random forest • Gradient boosted models • Naive Bayes • Nearest neighbour • Support vector machine • …many more • Neural networks • Fully connected neural network • Convolutional neural network • Recurrent neural network • Transformer • …many more What we’re focused on building (with PyTorch) (since the advent of deep learning these are often referred to as “shallow algorithms”) (depending how you represent your problem, many algorithms can be used for both) (common algorithms)
  • 14. “What are neural networks?”
  • 15. Neural Networks [[116, 78, 15], [117, 43, 96], [125, 87, 23], …, [[0.983, 0.004, 0.013], [0.110, 0.889, 0.001], [0.023, 0.027, 0.985], …, Inputs Numerical encoding Learns representation (patterns/features/weights) Representation outputs Outputs (a human can understand these) Ramen, Spaghetti Not a diaster “Hey Siri, what’s the weather today?” (choose the appropriate neural network for your problem) (before data gets used with a neural network, it needs to be turned into numbers) Each of these nodes is called a “hidden unit” or “neuron”.
  • 16. Anatomy of Neural Networks Input layer (data goes in here) Output layer (outputs learned representation or prediction probabilities) Hidden layer(s) (learns patterns in data) Note: “patterns” is an arbitrary term, you’ll often hear “embedding”, “weights”, “feature representation”, “feature vectors” all referring to similar things. # units/neurons = 2 # units/neurons = 3 # units/neurons = 1 Each layer is usually combination of linear (straight line) and/or non- linear (not-straight line) functions Overall architecture
  • 17. Supervised Learning Unsupervised & Self-supervised Learning Transfer Learning Types of Learning We’ll be writing code to do these, but the style of code can be adopted across learning paradigms.
  • 18. “What is deep learning actually used for?”
  • 19. Source: 2020 Machine Learning Roadmap video.
  • 20. Deep Learning Use Cases Recommendation Translation “Hey Siri, who’s the biggest big dog of them all?” Speech recognition Computer Vision Natural Language Processing (NLP) To: [email protected] Hey Daniel, This deep learning course is incredible! I can’t wait to use what I’ve learned! To: [email protected] Hay daniel… C0ongratu1ations! U win $1139239230 Spam Not spam Sequence to sequence (seq2seq) Classi fi cation/regression (some)
  • 23. What is PyTorch? • Most popular research deep learning framework* • Write fast deep learning code in Python (able to run on a GPU/many GPUs) • Able to access many pre-built deep learning models (Torch Hub/ torchvision.models) • Whole stack: preprocess data, model data, deploy model in your application/cloud • Originally designed and used in-house by Facebook/Meta (now open- source and used by companies such as Tesla, Microsoft, OpenAI) *Source: paperswithcode.com/trends February 2022
  • 24. Why PyTorch? Research favourite Source: paperswithcode.com/trends February 2022
  • 25. Why PyTorch? Source: @fchollet Twitter and PyTorch
  • 27. What is a GPU/TPU? GPU (Graphics Processing Unit) TPU (Tensor Processing Unit)
  • 28. “What is a tensor?”
  • 29. Neural Networks [[116, 78, 15], [117, 43, 96], [125, 87, 23], …, [[0.983, 0.004, 0.013], [0.110, 0.889, 0.001], [0.023, 0.027, 0.985], …, Inputs Numerical encoding Learns representation (patterns/features/weights) Representation outputs Outputs (a human can understand these) Ramen, Spaghetti Not spam “Hey Siri, what’s the weather today?” (choose the appropriate neural network for your problem) (before data gets used with an algorithm, it needs to be turned into numbers) These are tensors!
  • 30. [[116, 78, 15], [117, 43, 96], [125, 87, 23], …, [[0.983, 0.004, 0.013], [0.110, 0.889, 0.001], [0.023, 0.027, 0.985], …, Inputs Numerical encoding Learns representation (patterns/features/weights) Representation outputs Outputs Ramen, Spaghetti These are tensors!
  • 31. “What are we going to cover?”
  • 33. • Now: • PyTorch basics & fundamentals (dealing with tensors and tensor operations) • Later: • Preprocessing data (getting it into tensors) • Building and using pretrained deep learning models • Fitting a model to the data (learning patterns) • Making predictions with a model (using patterns) • Evaluating model predictions • Saving and loading models • Using a trained model to make predictions on custom data How: 👩🔬 👩🍳 What we’re going to cover (broadly) (we’ll be cooking up lots of code!)
  • 34. What we’re going to cover A PyTorch workflow (one of many)
  • 35. “How should I approach this course?”
  • 36. 2. Explore and experiment How to approach this course 1. Code along Motto #1: if in doubt, run the code! Motto #2: Experiment, experiment, experiment! 3. Visualize what you don’t understand Motto #3: Visualize, visualize, visualize! 4. Ask questions 🛠 5. Do the exercises 🤗 6. Share your work (including the “dumb” ones)
  • 37. How not to approach this course Avoid: 🧠 🔥 🔥 🔥 “I can’t learn ______”
  • 40. tensor([[[1, 2, 3], [3, 6, 9], [2, 4, 5]]]) 0 1 2 0 1 2 tensor([[[1, 2, 3], [3, 6, 9], [2, 4, 5]]]) tensor([[[1, 2, 3], [3, 6, 9], [2, 4, 5]]]) torch.Size([1, 3, 3]) 0 1 2 Dimension (dim) dim=0 dim=1 dim=2 Tensor dimensions
  • 41. 20 0 24 44 A*J + B*L + C*N A*K + B*M + C*O D*J + E*L + F*N D*K + E*M + F*O G*J + H*L + I*N G*K + H*M + I*O 44 38 126 86 58 63 4 6 8 5 0 3 3x2 3x3 3x2 4 7 6 8 8 1 J K L M N O 5 0 3 3 7 9 3 5 2 A B C D E F G H I Dot product 3x3 3x2 torch.matmul( ) , ) * * * = = = + + 3x2 For a live demo, checkout www.matrixmultiplication.xyz Numbers on the inside must match New size is same as outside numbers = torch.matmul( ,
  • 42. [[116, 78, 15], [117, 43, 96], [125, 87, 23], …, [[0.983, 0.004, 0.013], [0.110, 0.889, 0.001], [0.023, 0.027, 0.985], …, Inputs Numerical encoding Learns representation (patterns/features/weights) Representation outputs Outputs Ramen, Spaghetti [[0.092, 0.210, 0.415], [0.778, 0.929, 0.030], [0.019, 0.182, 0.555], …, 1. Initialise with random weights (only at beginning) 2. Show examples 3. Update representation outputs 4. Repeat with more examples Supervised learning (overview)
  • 43. Tensor attributes Attribute Meaning Code Shape The length (number of elements) of each of the dimensions of a tensor. tensor.shape Rank/dimensions The total number of tensor dimensions. A scalar has rank 0, a vector has rank 1, a matrix is rank 2, a tensor has rank n. tensor.ndim or tensor.size() Speci fi c axis or dimension (e.g. “1st axis” or “0th dimension”) A particular dimension of a tensor. tensor[0], tensor[:, 1]…