0% found this document useful (0 votes)
16 views79 pages

Chapter 1

The document provides an introduction to deep learning in Python. It discusses using neural networks to better capture interactions between variables compared to linear regression. Deep learning models with multiple hidden layers can represent complex relationships to make accurate predictions. Activation functions are applied to neural network nodes to introduce non-linearity, improving the ability of the network to learn patterns in the data.

Uploaded by

chowsaj9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views79 pages

Chapter 1

The document provides an introduction to deep learning in Python. It discusses using neural networks to better capture interactions between variables compared to linear regression. Deep learning models with multiple hidden layers can represent complex relationships to make accurate predictions. Activation functions are applied to neural network nodes to introduce non-linearity, improving the ability of the network to learn patterns in the data.

Uploaded by

chowsaj9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

Introduction to deep

learning
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N

Dan Becker
Data Scientist and contributor to Keras
and TensorFlow libraries
Imagine you work for a bank
You need to predict how many transactions each customer will
make next year

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Example as seen by linear regression

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions
Neural networks account for interactions really well

Deep learning uses especially powerful neural networks


Text

Images

Videos

Audio

Source code

INTRODUCTION TO DEEP LEARNING IN PYTHON


Course structure
First two chapters focus on conceptual knowledge
Debug and tune deep learning models on conventional
prediction problems

Lay the foundation for progressing towards modern


applications

This will pay off in the third and fourth chapters

INTRODUCTION TO DEEP LEARNING IN PYTHON


Build and tune deep learning models using keras
import numpy as np
from keras.layers import Dense
from keras.models import Sequential
predictors = np.loadtxt('predictors_data.csv', delimiter=',')
n_cols = predictors.shape[1]
model = Sequential()

model.add(Dense(100, activation='relu', input_shape = (n_cols,)))


model.add(Dense(100, activation='relu'))
model.add(Dense(1))

INTRODUCTION TO DEEP LEARNING IN PYTHON


Deep learning models capture interactions

INTRODUCTION TO DEEP LEARNING IN PYTHON


Deep learning models capture interactions

INTRODUCTION TO DEEP LEARNING IN PYTHON


Deep learning models capture interactions

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions in neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions in neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions in neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions in neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Interactions in neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Let's practice!
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N
Forward propagation
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N

Dan Becker
Data Scientist and contributor to Keras
and TensorFlow libraries
Bank transactions example
Make predictions based on:
Number of children

Number of existing accounts

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation
Multiply - add process

Dot product

Forward propagation for one data point at a time

Output is the prediction for that data point

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation code
import numpy as np
input_data = np.array([2, 3])
weights = {'node_0': np.array([1, 1]),
'node_1': np.array([-1, 1]),
'output': np.array([2, -1])}
node_0_value = (input_data * weights['node_0']).sum()
node_1_value = (input_data * weights['node_1']).sum()

INTRODUCTION TO DEEP LEARNING IN PYTHON


Forward propagation code
hidden_layer_values = np.array([node_0_value, node_1_value]

print(hidden_layer_values)

[5, 1]

output = (hidden_layer_values * weights['output']).sum()

print(output)

INTRODUCTION TO DEEP LEARNING IN PYTHON


Let's practice!
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N
Activation functions
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N

Dan Becker
Data Scientist and contributor to Keras
and TensorFlow libraries
Linear vs Nonlinear Functions

INTRODUCTION TO DEEP LEARNING IN PYTHON


Activation functions
Applied to node inputs to produce node output

INTRODUCTION TO DEEP LEARNING IN PYTHON


Improving our neural network

INTRODUCTION TO DEEP LEARNING IN PYTHON


Activation functions

INTRODUCTION TO DEEP LEARNING IN PYTHON


ReLU (Recti ed Linear Activation)

INTRODUCTION TO DEEP LEARNING IN PYTHON


Activation functions
import numpy as np
input_data = np.array([-1, 2])
weights = {'node_0': np.array([3, 3]),
'node_1': np.array([1, 5]),
'output': np.array([2, -1])}
node_0_input = (input_data * weights['node_0']).sum()
node_0_output = np.tanh(node_0_input)
node_1_input = (input_data * weights['node_1']).sum()
node_1_output = np.tanh(node_1_input)
hidden_layer_outputs = np.array([node_0_output, node_1_output])
output = (hidden_layer_output * weights['output']).sum()

print(output)

1.2382242525694254

INTRODUCTION TO DEEP LEARNING IN PYTHON


Let's practice!
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N
Deeper networks
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N

Dan Becker
Data Scientist and contributor to Keras
and TensorFlow libraries
Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Multiple hidden layers

INTRODUCTION TO DEEP LEARNING IN PYTHON


Representation learning
Deep networks internally build representations of patterns in the
data

Partially replace the need for feature engineering

Subsequent layers build increasingly sophisticated representations


of raw data

INTRODUCTION TO DEEP LEARNING IN PYTHON


Representation learning

INTRODUCTION TO DEEP LEARNING IN PYTHON


Deep learning
Modeler doesn't need to specify the interactions

When you train the model, the neural network gets weights that
nd the relevant patterns to make better predictions

INTRODUCTION TO DEEP LEARNING IN PYTHON


Let's practice!
I N T R O D U C T I O N TO D E E P L E A R N I N G I N P Y T H O N

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy