SlideShare a Scribd company logo
1 of 44
Download to read offline
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)
“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

Reproducibility and automation of machine learning process
Reproducibility and automation of machine learning processReproducibility and automation of machine learning process
Reproducibility and automation of machine learning processDenis Dus
 
Deep learning introduction
Deep learning introductionDeep learning introduction
Deep learning introductionAdwait Bhave
 
Introducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applicationsIntroducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applicationsRokesh Jankie
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...Brocade
 
Testing for the deeplearning folks
Testing for the deeplearning folksTesting for the deeplearning folks
Testing for the deeplearning folksVishwas N
 
Deep learning in production with the best
Deep learning in production   with the bestDeep learning in production   with the best
Deep learning in production with the bestAdam Gibson
 
2014 manchester-reproducibility
2014 manchester-reproducibility2014 manchester-reproducibility
2014 manchester-reproducibilityc.titus.brown
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator ProgramGoDataDriven
 
Good practices (and challenges) for reproducibility
Good practices (and challenges) for reproducibilityGood practices (and challenges) for reproducibility
Good practices (and challenges) for reproducibilityJavier Quílez Oliete
 
Ardian Haxha- Flying with Python (OSCAL2014)
Ardian Haxha- Flying with Python  (OSCAL2014)Ardian Haxha- Flying with Python  (OSCAL2014)
Ardian Haxha- Flying with Python (OSCAL2014)Open Labs Albania
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018Mike Harris
 
2014 nicta-reproducibility
2014 nicta-reproducibility2014 nicta-reproducibility
2014 nicta-reproducibilityc.titus.brown
 
Build a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlowBuild a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlowEntrepreneur / Startup
 
Introduction To TensorFlow
Introduction To TensorFlowIntroduction To TensorFlow
Introduction To TensorFlowSpotle.ai
 
Transferring Software Testing Tools to Practice
Transferring Software Testing Tools to PracticeTransferring Software Testing Tools to Practice
Transferring Software Testing Tools to PracticeTao Xie
 
Machine learning the next revolution or just another hype
Machine learning   the next revolution or just another hypeMachine learning   the next revolution or just another hype
Machine learning the next revolution or just another hypeJorge Ferrer
 
Teaching Machine Learning with Physical Computing - July 2023
Teaching Machine Learning with Physical Computing - July 2023Teaching Machine Learning with Physical Computing - July 2023
Teaching Machine Learning with Physical Computing - July 2023Hal Speed
 

Similar to 00_pytorch_and_deep_learning_fundamentals.pdf (20)

Reproducibility and automation of machine learning process
Reproducibility and automation of machine learning processReproducibility and automation of machine learning process
Reproducibility and automation of machine learning process
 
Deep learning introduction
Deep learning introductionDeep learning introduction
Deep learning introduction
 
Introducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applicationsIntroducing TensorFlow: The game changer in building "intelligent" applications
Introducing TensorFlow: The game changer in building "intelligent" applications
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...
Recent Advances in Machine Learning: Bringing a New Level of Intelligence to ...
 
Testing for the deeplearning folks
Testing for the deeplearning folksTesting for the deeplearning folks
Testing for the deeplearning folks
 
Deep learning in production with the best
Deep learning in production   with the bestDeep learning in production   with the best
Deep learning in production with the best
 
2014 manchester-reproducibility
2014 manchester-reproducibility2014 manchester-reproducibility
2014 manchester-reproducibility
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
 
Good practices (and challenges) for reproducibility
Good practices (and challenges) for reproducibilityGood practices (and challenges) for reproducibility
Good practices (and challenges) for reproducibility
 
Ardian Haxha- Flying with Python (OSCAL2014)
Ardian Haxha- Flying with Python  (OSCAL2014)Ardian Haxha- Flying with Python  (OSCAL2014)
Ardian Haxha- Flying with Python (OSCAL2014)
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
2014 nicta-reproducibility
2014 nicta-reproducibility2014 nicta-reproducibility
2014 nicta-reproducibility
 
Build a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlowBuild a Neural Network for ITSM with TensorFlow
Build a Neural Network for ITSM with TensorFlow
 
Introduction To TensorFlow
Introduction To TensorFlowIntroduction To TensorFlow
Introduction To TensorFlow
 
Transferring Software Testing Tools to Practice
Transferring Software Testing Tools to PracticeTransferring Software Testing Tools to Practice
Transferring Software Testing Tools to Practice
 
2014 pycon-talk
2014 pycon-talk2014 pycon-talk
2014 pycon-talk
 
Machine learning the next revolution or just another hype
Machine learning   the next revolution or just another hypeMachine learning   the next revolution or just another hype
Machine learning the next revolution or just another hype
 
Teaching Machine Learning with Physical Computing - July 2023
Teaching Machine Learning with Physical Computing - July 2023Teaching Machine Learning with Physical Computing - July 2023
Teaching Machine Learning with Physical Computing - July 2023
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

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: 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)
  • 21.
  • 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]…