PyTorch is a deep learning framework for used to build artificial intelligence software with Python. Learn how to build a basic neural network from scratch with PyTorch 2. 

#ai #python #100SecondsOfCode

💬 Chat with Me on Discord

https://discord.gg/fireship

🔗 Resources

PyTorch Docs https://pytorch.org
Tensorflow in 100 Seconds
Python in 100 Seconds https://youtu.be/x7X9w_GIm1s

🔥 Get More Content - Upgrade to PRO

Upgrade at https://fireship.io/pro
Use code YT25 for 25% off PRO access 

🎨 My Editor Settings

- Atom One Dark 
- vscode-icons
- Fira Code Font

🔖 Topics Covered

- What is PyTorch?
- PyTorch vs Tensorflow
- Build a basic neural network with PyTorch
- PyTorch 2 basics tutorial
- What is a tensor?
- Which AI products use PyTorch?
2024-02-04T05:11:07.874Z
nova-2
2-general-nova
2024-01-09.29447
30089e05-99d1-4376-b32e-c263170674af
720bf1bd-b7d1-4ed2-9f44-d7719d3cebef
cf9d15860ace184bb0b893440b281253604a0eabf3aa1041b5f60304cd6b4d2d
67875a7f-c9c4-48a0-aa55-5bdb8a91c34a
deprecated
PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products.
It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002.
Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks.
Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python.
In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform.
Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time.
It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed.
PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few.
To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU.
Now imported into a Python file or notebook.
Like I mentioned, a tensor is similar to a multidimensional array.
Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor.
Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points.
We can also perform algebra by taking multiple tensors and multiplying them together.
What you came here to do though is build a deep neural network, like an image classifier.
To handle that, we can define a new class that inherits from the neural network module class.
Inside the constructor, we can build it out layer by layer.
The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension.
From there, sequential is used to create a container of layers that the data will flow through.
Each layer has multiple nodes, where each node is like its own mini statistical model.
As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable.
Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112.
This layer is followed by a nonlinear activation function.
When activated, it means that feature might be important and outputs the node.
Otherwise, it just outputs 0.
And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict.
With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data.
This will automatically call its forward method for training and prediction.
Congratulations.
You just built meta neural network.
This has been PyTorch in 100 seconds.
Thanks for watching, and I will see you in the next one.

Speaker 0: PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products. It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002. Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks. Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python. In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform.

Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time. It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed. PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few. To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU. Now imported into a Python file or notebook.

Like I mentioned, a tensor is similar to a multidimensional array. Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor. Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points. We can also perform algebra by taking multiple tensors and multiplying them together. What you came here to do though is build a deep neural network, like an image classifier.

To handle that, we can define a new class that inherits from the neural network module class. Inside the constructor, we can build it out layer by layer. The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension. From there, sequential is used to create a container of layers that the data will flow through. Each layer has multiple nodes, where each node is like its own mini statistical model.

As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable. Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112. This layer is followed by a nonlinear activation function. When activated, it means that feature might be important and outputs the node. Otherwise, it just outputs 0.

And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict. With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data. This will automatically call its forward method for training and prediction. Congratulations. You just built meta neural network.

This has been PyTorch in 100 seconds. Thanks for watching, and I will see you in the next one.
PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products. It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002. Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks. Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python. In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform. Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time. It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed. PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few. To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU. Now imported into a Python file or notebook. Like I mentioned, a tensor is similar to a multidimensional array. Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor.
deep learning
neural networks
machine learning
artificial intelligence
programming
computer science
visualization
software development
software
covid-19
robotics
Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points. We can also perform algebra by taking multiple tensors and multiplying them together. What you came here to do though is build a deep neural network, like an image classifier. To handle that, we can define a new class that inherits from the neural network module class. Inside the constructor, we can build it out layer by layer. The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension. From there, sequential is used to create a container of layers that the data will flow through. Each layer has multiple nodes, where each node is like its own mini statistical model. As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable. Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112.
deep learning
neural networks
data
artificial intelligence
machine learning
mathematics
programming
modeling
deepgram
This layer is followed by a nonlinear activation function.
When activated, it means that feature might be important and outputs the node. Otherwise, it just outputs 0. And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict. With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data. This will automatically call its forward method for training and prediction. Congratulations. You just built meta neural network. This has been PyTorch in 100 seconds. Thanks for watching, and I will see you in the next one.
machine learning
neural networks
modeling
deep learning
artificial intelligence
PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products. It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002. Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks. Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python. In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform. Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time. It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed. PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few. To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU. Now imported into a Python file or notebook. Like I mentioned, a tensor is similar to a multidimensional array. Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor. Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points. We can also perform algebra by taking multiple tensors and multiplying them together. What you came here to do though is build a deep neural network, like an image classifier. To handle that, we can define a new class that inherits from the neural network module class. Inside the constructor, we can build it out layer by layer. The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension. From there, sequential is used to create a container of layers that the data will flow through. Each layer has multiple nodes, where each node is like its own mini statistical model. As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable. Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112. This layer is followed by a nonlinear activation function. When activated, it means that feature might be important and outputs the node. Otherwise, it just outputs 0. And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict. With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data. This will automatically call its forward method for training and prediction. Congratulations. You just built meta neural network. This has been PyTorch in 100 seconds. Thanks for watching, and I will see you in the next one.
PyTorch,
pytorch
an
an
open
open
source
source
deep
deep
learning
learning
framework
framework
used
used
to
to
build
build
some
some
of
of
the
the
world's
world's
most
most
famous
famous
artificial
artificial
intelligence
intelligence
products.
products
It
it
was
was
created
created
at
at
the
the
AI
ai
Research
research
Lab
lab
in
in
2016,
2016
but
but
is
is
actually
actually
derived
derived
from
from
the
the
Lua
lua
based
based
Torch
torch
library
library
that
that
dates
dates
back
back
to
to
2,002.
2,002
Fundamentally,
fundamentally
it's
it's
MEG
meg
library
library
for
for
programming
programming
with
with
tensors,
tensors
which
which
are
are
basically
basically
just
just
multidimensional
multidimensional
arrays
arrays
that
that
represent
represent
data
data
and
and
parameters
parameters
in
in
deep
deep
neural
neural
networks.
networks
Sounds
sounds
complicated,
complicated
but
but
its
its
focus
focus
on
on
usability
usability
will
will
have
have
you
you
training
training
machine
machine
learning
learning
models
models
with
with
just
just
a
a
few
few
lines
lines
of
of
Python.
python
In
in
addition,
addition
it
it
facilitates
facilitates
high
high
performance
performance
parallel
parallel
computing
computing
on
on
a
a
GPU,
gpu
thanks
thanks
to
to
NVIDIA's
nvidia's
CUDA
cuda
platform.
platform
Developers
developers
love
love
prototyping
prototyping
with
with
it
it
because
because
it
it
supports
supports
a
a
dynamic
dynamic
computation
computation
graph,
graph
allowing
allowing
models
models
to
to
be
be
optimized
optimized
at
at
run
run
time.
time
It
it
does
does
this
this
by
by
constructing
constructing
a
a
directed
directed
acyclic
acyclic
graph
graph
consisting
consisting
of
of
functions
functions
that
that
keeps
keeps
track
track
of
of
all
all
the
the
executed
executed
operations
operations
on
on
the
the
tensors,
tensors
allowing
allowing
you
you
to
to
change
change
the
the
shape,
shape
size,
size
and
and
operation
operation
after
after
every
every
iteration
iteration
if
if
needed.
needed
PyTorch
pytorch
has
has
been
been
used
used
to
to
train
train
models
models
for
for
computer
computer
vision
vision
AI
ai
like
like
Tesla
tesla
autopilot,
autopilot
image
image
generators
generators
like
like
and
and
speech
speech
recognition
recognition
models
models
like
like
OpenAI
openai
Whisper,
whisper
just
just
to
to
name
name
a
a
few.
few
To
to
get
get
started,
started
install
install
PyTorch
pytorch
and
and
optionally
optionally
CUDA
cuda
if
if
you
you
want
want
to
to
accelerate
accelerate
computing
computing
on
on
your
your
GPU.
gpu
Now
now
imported
imported
into
into
a
a
Python
python
file
file
or
or
notebook.
notebook
Like
like
I
i
mentioned,
mentioned
a
a
tensor
tensor
is
is
similar
similar
to
to
a
a
multidimensional
multidimensional
array.
array
Create
create
a
a
2
2
d
d
array
array
or
or
matrix
matrix
with
with
Python,
python
then
then
used
used
Torch
torch
to
to
convert
convert
it
it
into
into
a
a
tensor.
tensor
Now,
now
we
we
can
can
run
run
all
all
kinds
kinds
of
of
computations
computations
on
on
it,
it
like
like
we
we
might
might
convert
convert
all
all
these
these
integers
integers
into
into
random
random
floating
floating
points.
points
We
we
can
can
also
also
perform
perform
algebra
algebra
by
by
taking
taking
multiple
multiple
tensors
tensors
and
and
multiplying
multiplying
them
them
together.
together
What
what
you
you
came
came
here
here
to
to
do
do
though
though
is
is
build
build
a
a
deep
deep
neural
neural
network,
network
like
like
an
an
image
image
classifier.
classifier
To
to
handle
handle
that,
that
we
we
can
can
define
define
a
a
new
new
class
class
that
that
inherits
inherits
from
from
the
the
neural
neural
network
network
module
module
class.
class
Inside
inside
the
the
constructor,
constructor
we
we
can
can
build
build
it
it
out
out
layer
layer
by
by
layer.
layer
The
the
flatten
flatten
layer
layer
will
will
take
take
a
a
multi
multi
dimensional
dimensional
input,
input
like
like
an
an
image,
image
and
and
convert
convert
it
it
to
to
one
one
dimension.
dimension
From
from
there,
there
sequential
sequential
is
is
used
used
to
to
create
create
a
a
container
container
of
of
layers
layers
that
that
the
the
data
data
will
will
flow
flow
through.
through
Each
each
layer
layer
has
has
multiple
multiple
nodes,
nodes
where
where
each
each
node
node
is
is
like
like
its
its
own
own
mini
mini
statistical
statistical
model.
model
As
as
each
each
data
data
point
point
flows
flows
through
through
it,
it
it'll
it'll
try
try
to
to
guess
guess
the
the
output,
output
and
and
gradually
gradually
update
update
a
a
mapping
mapping
of
of
weights
weights
to
to
determine
determine
the
the
importance
importance
of
of
a
a
given
given
variable.
variable
Linear
linear
is
is
a
a
fully
fully
connected
connected
layer
layer
that
that
takes
takes
the
the
flattened
flattened
28
28
by
by
28
28
image
image
and
and
transforms
transforms
it
it
to
to
an
an
output
output
of
of
5
5
112.
112
This
this
layer
layer
is
is
followed
followed
by
by
a
a
nonlinear
nonlinear
activation
activation
function.
function
When
when
activated,
activated
it
it
means
means
that
that
feature
feature
might
might
be
be
important
important
and
and
outputs
outputs
the
the
node.
node
Otherwise,
otherwise
it
it
just
just
outputs
outputs
0.
0
And
and
Finally,
finally
we
we
finish
finish
with
with
a
a
fully
fully
connected
connected
layer
layer
that
that
outputs
outputs
the
the
10
10
labels
labels
the
the
model
model
is
is
trying
trying
to
to
predict.
predict
With
with
these
these
pieces
pieces
in
in
place,
place
the
the
next
next
step
step
is
is
to
to
define
define
a
a
forward
forward
method
method
that
that
describes
describes
the
the
flow
flow
of
of
and
and
now
now
instantiate
instantiate
the
the
model
model
to
to
a
a
GPU
gpu
and
and
pass
pass
it
it
some
some
input
input
data.
data
This
this
will
will
automatically
automatically
call
call
its
its
forward
forward
method
method
for
for
training
training
and
and
prediction.
prediction
Congratulations.
congratulations
You
you
just
just
built
built
meta
meta
neural
neural
network.
network
This
this
has
has
been
been
PyTorch
pytorch
in
in
100
100
seconds.
seconds
Thanks
thanks
for
for
watching,
watching
and
and
I
i
will
will
see
see
you
you
in
in
the
the
next
next
one.
one
success
In this video, a speaker explains how Py heritage deep learning framework used to build AI products, including a Torch library that facilitates high-performance parallel computing and allows developers to train models with Python. The speaker then explains how to install Py heritage and advised on how to use it to build a deep neural network. The video ends with a demonstration of the model and a congratulations on building a meta neural network.
PyTorch in 100 Seconds
PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products. It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002. Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks. Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python. In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform. Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time. It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed. PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few. To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU. Now imported into a Python file or notebook. Like I mentioned, a tensor is similar to a multidimensional array. Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor. Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points. We can also perform algebra by taking multiple tensors and multiplying them together. What you came here to do though is build a deep neural network, like an image classifier. To handle that, we can define a new class that inherits from the neural network module class. Inside the constructor, we can build it out layer by layer. The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension. From there, sequential is used to create a container of layers that the data will flow through. Each layer has multiple nodes, where each node is like its own mini statistical model. As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable. Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112. This layer is followed by a nonlinear activation function. When activated, it means that feature might be important and outputs the node. Otherwise, it just outputs 0. And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict. With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data. This will automatically call its forward method for training and prediction. Congratulations. You just built meta neural network. This has been PyTorch in 100 seconds. Thanks for watching, and I will see you in the next one.
In this video, a speaker explains how Py heritage deep learning framework used to build AI products, including a Torch library that facilitates high-performance parallel computing and allows developers to train models with Python. The speaker then explains how to install Py heritage and advised on how to use it to build a deep neural network. The video ends with a demonstration of the model and a congratulations on building a meta neural network.

        [INST]
        You are youtuber called Fireship you make engaging high-intensity and entertaining coding tutorials and tech news. 
        you covers a wide range of topics relevant to programmers, aiming to help them learn and improve their skills quickly.
        
        Given the title of the video : PyTorch in 100 Seconds 
        and a small summary : In this video, a speaker explains how Py heritage deep learning framework used to build AI products, including a Torch library that facilitates high-performance parallel computing and allows developers to train models with Python. The speaker then explains how to install Py heritage and advised on how to use it to build a deep neural network. The video ends with a demonstration of the model and a congratulations on building a meta neural network.
        [/INST]
        
        Generate the video : PyTorch, an open source deep learning framework used to build some of the world's most famous artificial intelligence products. It was created at the AI Research Lab in 2016, but is actually derived from the Lua based Torch library that dates back to 2,002. Fundamentally, it's MEG library for programming with tensors, which are basically just multidimensional arrays that represent data and parameters in deep neural networks. Sounds complicated, but its focus on usability will have you training machine learning models with just a few lines of Python. In addition, it facilitates high performance parallel computing on a GPU, thanks to NVIDIA's CUDA platform. Developers love prototyping with it because it supports a dynamic computation graph, allowing models to be optimized at run time. It does this by constructing a directed acyclic graph consisting of functions that keeps track of all the executed operations on the tensors, allowing you to change the shape, size, and operation after every iteration if needed. PyTorch has been used to train models for computer vision AI like Tesla autopilot, image generators like and speech recognition models like OpenAI Whisper, just to name a few. To get started, install PyTorch and optionally CUDA if you want to accelerate computing on your GPU. Now imported into a Python file or notebook. Like I mentioned, a tensor is similar to a multidimensional array. Create a 2 d array or matrix with Python, then used Torch to convert it into a tensor. Now, we can run all kinds of computations on it, like we might convert all these integers into random floating points. We can also perform algebra by taking multiple tensors and multiplying them together. What you came here to do though is build a deep neural network, like an image classifier. To handle that, we can define a new class that inherits from the neural network module class. Inside the constructor, we can build it out layer by layer. The flatten layer will take a multi dimensional input, like an image, and convert it to one dimension. From there, sequential is used to create a container of layers that the data will flow through. Each layer has multiple nodes, where each node is like its own mini statistical model. As each data point flows through it, it'll try to guess the output, and gradually update a mapping of weights to determine the importance of a given variable. Linear is a fully connected layer that takes the flattened 28 by 28 image and transforms it to an output of 5 112. This layer is followed by a nonlinear activation function. When activated, it means that feature might be important and outputs the node. Otherwise, it just outputs 0. And Finally, we finish with a fully connected layer that outputs the 10 labels the model is trying to predict. With these pieces in place, the next step is to define a forward method that describes the flow of and now instantiate the model to a GPU and pass it some input data. This will automatically call its forward method for training and prediction. Congratulations. You just built meta neural network. This has been PyTorch in 100 seconds. Thanks for watching, and I will see you in the next one.
        