PyTorch Tutorial : Forward propagation
Skills:
ML Maths Basics70%
Key Takeaways
This video tutorial covers forward propagation in PyTorch, explaining the concept of computational graphs and how they are used in neural networks and other classifiers. The tutorial provides a simple example of a computational graph and implements it in PyTorch.
Full Transcript
welcome back here we are going to explain forward propagation also known as forward pass an important step on training and evaluation of all classifiers let's take a classifier maybe a neural network no worries if you don't know what it is I promise that you are going to soon learn about it and the principle is general for most classifiers the first step is to evaluate what classifier is doing given your data given some data the yellow layer the model does all the operation in the following blue layers until it gives some result in the output brown layer this step is called the forward step we are going to start with a simple example let's assume that we have a model it could be a neural network some other type of classifier or in more abstract terms a computational graph intuitively a computational graph is a network of nodes that represent numbers scalars or tensors and are connected via added that represent functions of operations for simplicity in visualizations instead of using large multi dimensional tensors we are going to use colors or graph has notes a B C and D and some operations between the nodes like adding not a with not B or multiplying no see with no D our job is to do all the operations until we get the result G first we add a and B getting 2 plus minus 4 equals 2 minus 2 putting the result in node E similarly we multiply C with D getting minus 2 times 2 equals 2 minus 4 and we put the result in node F now our nodes in the graph or nodes ENF containing values minus 2 and minus 4 the last step is to multiply these two values and to put the result in G we do that getting minus 2 times minus 4 equals 8 and so finishing our exercise let's implement it on fighters we first initialize dancers a b c and d to the corresponding values - 4 - 2 & 2 we then add a and B - 10 sorry and we multiply CD putting the result in tensor F finally we multiply e with F putting the result in tensor G and then we print the values of these three tenses getting the same result as in the slice now there is hardly anything fancy in this exercise however understanding it is of you to importance neural networks and most of the other classifiers can be understood as computational graphs in fact your code gets converted to a computational graph just that the graphs will be much larger and the tensors within them will contain millions of entries an additional benefit of computational graph is that they make the automatic computation of derivatives or gradients much easier as we will see in the next lesson let's do a quick exercise to solidify the knowledge about computational graphs and forward
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/introduction-to-deep-learning-with-pytorch at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Welcome back. Here we are going to explain forward propagation (also known as forward pass), an important step on training and evaluation of all classifiers.
Let's take a classifier, maybe a neural network. No worries if you don't know what it is, I promise that you are going to soon learn about it, and the principle is general for most classifiers. The first step is to evaluate what classifier is doing given your data. Given some data (the yellow layer), the model does all the operation in the following (blue) layers until it gives some result in the output (brown) layer. This step is called the forward step.
We are going to start with a simple example. Let's assume that we have a model, it could be a neural network, some other type of classifier, or in more abstract terms a computational graph. Intuitively, a computational graph is a network of nodes that represent numbers, scalars, or tensors and are connected via edges that represent functions or operations. For simplicity and visualization, instead of using large multi-dimensional tensors, we are going to use scalars. Our graph has nodes a, b, c and d and some operations between the nodes, like adding node a with node b, or multiplying node c with node d. Our job is to do all the operations until we get the result g.
First we add a and b, getting 2 + (-4) = -2, putting the result in node e. Similarly, we multiply c with d, getting (-2) * 2 = -4, and we put the result in node f. Now our nodes in the graph are nodes e and f, containing values (-2) and (-4). The last step is to multiply these two values and to put the result in g.
We do that, getting (-2) * (-4) = 8, and so finishing our exercise.
Let's implement it on PyTorch. We first initialize tensors a, b, c and d, to the
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
More on: ML Maths Basics
View skill →Related Reads
📰
📰
📰
📰
Understanding Deep Learning Through Four Interactive Experiments
Medium · Data Science
Understanding Deep Learning Through Four Interactive Experiments
Medium · Deep Learning
Optimizers in Deep Learning: From Gradient Descent to Adam
Medium · Deep Learning
The Meta-Architecture of Interface Fracture: High-Dimensional Logical Stress and Systemic Collapse…
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI