From c519fe118a6740d28e48f7b80f4701dff4d283b3 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Sun, 13 Oct 2024 15:38:19 +0200 Subject: [PATCH] update --- doc/pub/week42/html/._week42-bs000.html | 281 +-- doc/pub/week42/html/._week42-bs001.html | 304 ++- doc/pub/week42/html/._week42-bs002.html | 285 +-- doc/pub/week42/html/._week42-bs003.html | 283 +-- doc/pub/week42/html/._week42-bs004.html | 281 +-- doc/pub/week42/html/._week42-bs005.html | 281 +-- doc/pub/week42/html/._week42-bs006.html | 281 +-- doc/pub/week42/html/._week42-bs007.html | 307 ++- doc/pub/week42/html/._week42-bs008.html | 293 +-- doc/pub/week42/html/._week42-bs009.html | 303 ++- doc/pub/week42/html/._week42-bs010.html | 312 ++- doc/pub/week42/html/._week42-bs011.html | 329 +-- doc/pub/week42/html/._week42-bs012.html | 306 ++- doc/pub/week42/html/._week42-bs013.html | 307 +-- doc/pub/week42/html/._week42-bs014.html | 304 +-- doc/pub/week42/html/._week42-bs015.html | 397 ++-- doc/pub/week42/html/._week42-bs016.html | 329 +-- doc/pub/week42/html/._week42-bs017.html | 295 +-- doc/pub/week42/html/._week42-bs018.html | 309 +-- doc/pub/week42/html/._week42-bs019.html | 313 +-- doc/pub/week42/html/._week42-bs020.html | 307 +-- doc/pub/week42/html/._week42-bs021.html | 308 ++- doc/pub/week42/html/._week42-bs022.html | 307 +-- doc/pub/week42/html/._week42-bs023.html | 306 +-- doc/pub/week42/html/._week42-bs024.html | 307 +-- doc/pub/week42/html/._week42-bs025.html | 299 +-- doc/pub/week42/html/._week42-bs026.html | 309 +-- doc/pub/week42/html/._week42-bs027.html | 307 +-- doc/pub/week42/html/._week42-bs028.html | 285 +-- doc/pub/week42/html/._week42-bs029.html | 308 ++- doc/pub/week42/html/._week42-bs030.html | 302 +-- doc/pub/week42/html/._week42-bs031.html | 298 +-- doc/pub/week42/html/._week42-bs032.html | 384 ++-- doc/pub/week42/html/._week42-bs033.html | 304 +-- doc/pub/week42/html/._week42-bs034.html | 306 +-- doc/pub/week42/html/._week42-bs035.html | 306 ++- doc/pub/week42/html/._week42-bs036.html | 295 +-- doc/pub/week42/html/._week42-bs037.html | 309 ++- doc/pub/week42/html/._week42-bs038.html | 293 +-- doc/pub/week42/html/._week42-bs039.html | 304 +-- doc/pub/week42/html/._week42-bs040.html | 307 +-- doc/pub/week42/html/._week42-bs041.html | 297 +-- doc/pub/week42/html/._week42-bs042.html | 301 +-- doc/pub/week42/html/._week42-bs043.html | 297 +-- doc/pub/week42/html/._week42-bs044.html | 315 +-- doc/pub/week42/html/._week42-bs045.html | 316 ++- doc/pub/week42/html/._week42-bs046.html | 392 ++-- doc/pub/week42/html/._week42-bs047.html | 309 ++- doc/pub/week42/html/._week42-bs048.html | 316 ++- doc/pub/week42/html/._week42-bs049.html | 305 +-- doc/pub/week42/html/._week42-bs050.html | 306 +-- doc/pub/week42/html/._week42-bs051.html | 315 ++- doc/pub/week42/html/._week42-bs052.html | 307 +-- doc/pub/week42/html/._week42-bs053.html | 308 ++- doc/pub/week42/html/._week42-bs054.html | 309 +-- doc/pub/week42/html/._week42-bs055.html | 305 +-- doc/pub/week42/html/._week42-bs056.html | 310 +-- doc/pub/week42/html/._week42-bs057.html | 300 +-- doc/pub/week42/html/._week42-bs058.html | 310 +-- doc/pub/week42/html/._week42-bs059.html | 308 ++- doc/pub/week42/html/._week42-bs060.html | 302 +-- doc/pub/week42/html/._week42-bs061.html | 303 +-- doc/pub/week42/html/._week42-bs062.html | 315 ++- doc/pub/week42/html/._week42-bs063.html | 312 ++- doc/pub/week42/html/._week42-bs064.html | 309 +-- doc/pub/week42/html/._week42-bs065.html | 388 +--- doc/pub/week42/html/._week42-bs066.html | 304 +-- doc/pub/week42/html/._week42-bs067.html | 304 +-- doc/pub/week42/html/._week42-bs068.html | 358 ++-- doc/pub/week42/html/._week42-bs069.html | 324 ++- doc/pub/week42/html/._week42-bs070.html | 341 ++-- doc/pub/week42/html/._week42-bs071.html | 332 ++- doc/pub/week42/html/._week42-bs072.html | 316 ++- doc/pub/week42/html/._week42-bs073.html | 304 +-- doc/pub/week42/html/._week42-bs074.html | 397 ++-- doc/pub/week42/html/._week42-bs075.html | 346 ++-- doc/pub/week42/html/._week42-bs076.html | 328 ++- doc/pub/week42/html/._week42-bs077.html | 333 ++- doc/pub/week42/html/._week42-bs078.html | 344 ++-- doc/pub/week42/html/._week42-bs079.html | 307 ++- doc/pub/week42/html/._week42-bs080.html | 374 ++-- doc/pub/week42/html/._week42-bs081.html | 322 ++- doc/pub/week42/html/._week42-bs082.html | 328 ++- doc/pub/week42/html/._week42-bs083.html | 317 ++- doc/pub/week42/html/._week42-bs084.html | 411 ++-- doc/pub/week42/html/._week42-bs085.html | 300 ++- doc/pub/week42/html/._week42-bs086.html | 412 ++-- doc/pub/week42/html/._week42-bs087.html | 388 ++-- doc/pub/week42/html/._week42-bs088.html | 354 ++-- doc/pub/week42/html/._week42-bs089.html | 370 ++-- doc/pub/week42/html/._week42-bs090.html | 368 ++-- doc/pub/week42/html/._week42-bs091.html | 352 ++-- doc/pub/week42/html/._week42-bs092.html | 306 +-- doc/pub/week42/html/week42-bs.html | 281 +-- doc/pub/week42/html/week42-reveal.html | 590 +----- doc/pub/week42/html/week42-solarized.html | 568 +----- doc/pub/week42/html/week42.html | 568 +----- doc/pub/week42/ipynb/ipynb-week42-src.tar.gz | Bin 960220 -> 960220 bytes doc/pub/week42/ipynb/week42.ipynb | 1912 ++++-------------- doc/src/week42/week42.do.txt | 43 +- 100 files changed, 11939 insertions(+), 21669 deletions(-) diff --git a/doc/pub/week42/html/._week42-bs000.html b/doc/pub/week42/html/._week42-bs000.html index 9992218e0..dddce8a8e 100644 --- a/doc/pub/week42/html/._week42-bs000.html +++ b/doc/pub/week42/html/._week42-bs000.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -583,7 +500,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs001.html b/doc/pub/week42/html/._week42-bs001.html index 54a8aa777..afd7261b3 100644 --- a/doc/pub/week42/html/._week42-bs001.html +++ b/doc/pub/week42/html/._week42-bs001.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -546,17 +463,22 @@ MathJax.Hub.Config({
    1. Building our own Feed-forward Neural Network and discussion of project 2
    2. -
    3. Readings and Videos: -
        -
      1. These lecture notes +
      + + + +
      +
      + +
        +
      1. These lecture notes
      2. -
      3. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
      4. -
      5. Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
      6. -
      7. Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
      8. -
      9. Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
      10. -
      11. Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
      12. -
      +
    4. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
    5. +
    6. Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
    7. +
    8. Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
    9. +
    10. Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
    11. +
    12. Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U

    I also recommend Michael Nielsen's intuitive approach to the neural networks and the universal approximation theorem, see the slides at http://neuralnetworksanddeeplearning.com/chap4.html.

    @@ -579,7 +501,7 @@ MathJax.Hub.Config({
  • 10
  • 11
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs002.html b/doc/pub/week42/html/._week42-bs002.html index 33fda1f6f..9976d9706 100644 --- a/doc/pub/week42/html/._week42-bs002.html +++ b/doc/pub/week42/html/._week42-bs002.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -550,7 +467,9 @@ MathJax.Hub.Config({ - + + +

    Note: some of the codes will also be discussed next week in connection with the solution of differential equations.

    @@ -569,7 +488,7 @@ MathJax.Hub.Config({

  • 11
  • 12
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs003.html b/doc/pub/week42/html/._week42-bs003.html index 0094e2124..a3e1cd48d 100644 --- a/doc/pub/week42/html/._week42-bs003.html +++ b/doc/pub/week42/html/._week42-bs003.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -545,7 +462,7 @@ MathJax.Hub.Config({

    Last week we discussed the basics of neural networks and deep learning and the basics of automatic differentiation. We looked also at examples on how compute the parameters of a simple network with scalar -inputs and ouputs and no or just one hiden layers. +inputs and ouputs and no or just one hidden layers.

    We ended our discussions with the derivation of the equations for a @@ -571,7 +488,7 @@ hidden nodes but only one output node.

  • 12
  • 13
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs004.html b/doc/pub/week42/html/._week42-bs004.html index 06936bfae..dc4af5349 100644 --- a/doc/pub/week42/html/._week42-bs004.html +++ b/doc/pub/week42/html/._week42-bs004.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -572,7 +489,7 @@ MathJax.Hub.Config({
  • 13
  • 14
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs005.html b/doc/pub/week42/html/._week42-bs005.html index ba8e03c58..dcab679d1 100644 --- a/doc/pub/week42/html/._week42-bs005.html +++ b/doc/pub/week42/html/._week42-bs005.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -571,7 +488,7 @@ MathJax.Hub.Config({
  • 14
  • 15
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs006.html b/doc/pub/week42/html/._week42-bs006.html index 4194f2efc..95d36c77f 100644 --- a/doc/pub/week42/html/._week42-bs006.html +++ b/doc/pub/week42/html/._week42-bs006.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -567,7 +484,7 @@ MathJax.Hub.Config({
  • 15
  • 16
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs007.html b/doc/pub/week42/html/._week42-bs007.html index 223d0e383..d0e16119b 100644 --- a/doc/pub/week42/html/._week42-bs007.html +++ b/doc/pub/week42/html/._week42-bs007.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,14 +457,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Simpler examples first, and automatic differentiation

    +

    First network example, simple percepetron with one input

    -

    In order to understand the back propagation algorithm and its -derivation (an implementation of the chain rule), let us first digress -with some simple examples. These examples are also meant to motivate -the link with back propagation and automatic differentiation. +

    As yet another example we define now a simple perceptron model with +all quantities given by scalars. We consider only one input variable +\( x \) and one target value \( y \). We define an activation function +\( \sigma_1 \) which takes as input

    +$$ +z_1 = w_1x+b_1, +$$ + +

    where \( w_1 \) is the weight and \( b_1 \) is the bias. These are the +parameters we want to optimize. The output is \( a_1=\sigma(z_1) \) (see +graph from whiteboard notes). This output is then fed into the +cost/loss function, which we here for the sake of simplicity just +define as the squared error +

    + +$$ +C(x;w_1,b_1)=\frac{1}{2}(a_1-y)^2. +$$ + +

    diff --git a/doc/pub/week42/html/._week42-bs008.html b/doc/pub/week42/html/._week42-bs008.html index b392e7126..0f2c12c8d 100644 --- a/doc/pub/week42/html/._week42-bs008.html +++ b/doc/pub/week42/html/._week42-bs008.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,13 +457,13 @@ MathJax.Hub.Config({

     

     

     

    -

    Reminder on the chain rule and gradients

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t) \) and \( y=y(t) \) are functions of a variable \( t \), we have that the gradient of \( f \) with respect to \( t \) (without the explicit unit vector components)

    -$$ -\frac{df}{dt} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial t} \end{bmatrix}=\frac{\partial f}{\partial x} \frac{\partial x}{\partial t} +\frac{\partial f}{\partial y} \frac{\partial y}{\partial t}. -$$ +

    Layout of a simple neural network with no hidden layer

    +

    +
    +

    +
    +

    @@ -571,7 +488,7 @@ $$

  • 17
  • 18
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs009.html b/doc/pub/week42/html/._week42-bs009.html index ad3bc1815..e676d244c 100644 --- a/doc/pub/week42/html/._week42-bs009.html +++ b/doc/pub/week42/html/._week42-bs009.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,21 +457,31 @@ MathJax.Hub.Config({

     

     

     

    -

    Multivariable functions

    +

    Optimizing the parameters

    -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t,s) \) and \( y=y(t,s) \) are functions of the variables \( t \) and \( s \), we have that the partial derivatives

    +

    In setting up the feed forward and back propagation parts of the +algorithm, we need now the derivative of the various variables we want +to train. +

    + +

    We need

    $$ -\frac{\partial f}{\partial s}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial s}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial s}, +\frac{\partial C}{\partial w_1} \hspace{0.1cm}\mathrm{and}\hspace{0.1cm}\frac{\partial C}{\partial b_1}. +$$ + +

    Using the chain rule we find

    +$$ +\frac{\partial C}{\partial w_1}=\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial w_1}=(a_1-y)\sigma_1'x, $$

    and

    $$ -\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}. +\frac{\partial C}{\partial b_1}=\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial b_1}=(a_1-y)\sigma_1', $$ -

    the gradient of \( f \) with respect to \( t \) and \( s \) (without the explicit unit vector components)

    +

    which we later will just define as

    $$ -\frac{df}{d(s,t)} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial s} &\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial s} & \frac{\partial y}{\partial t} \end{bmatrix}. +\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}=\delta_1. $$ @@ -582,7 +509,7 @@ $$
  • 18
  • 19
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs010.html b/doc/pub/week42/html/._week42-bs010.html index 8375fd905..0409da91c 100644 --- a/doc/pub/week42/html/._week42-bs010.html +++ b/doc/pub/week42/html/._week42-bs010.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,19 +457,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Automatic differentiation through examples

    +

    Adding a hidden layer

    -

    A great introduction to automatic differentiation is given by Baydin et al., see https://arxiv.org/abs/1502.05767.

    - -

    Automatic differentiation is a represented by a repeated application -of the chain rule on well-known functions and allows for the -calculation of derivatives to numerical precision. It is not the same -as the calculation of symbolic derivatives via for example SymPy, nor -does it use approximative formulae based on Taylor-expansions of a -function around a given value. The latter are error prone due to -truncation errors and values of the step size \( \Delta \). +

    We change our simple model to (see graph) +a network with just one hidden layer but with scalar variables only.

    +

    Our output variable changes to \( a_2 \) and \( a_1 \) is now the output from the hidden node and \( a_0=x \). +We have then +

    +$$ +z_1 = w_1a_0+b_1 \hspace{0.1cm} \wedge a_1 = \sigma_1(z_1), +$$ + +$$ +z_2 = w_2a_1+b_2 \hspace{0.1cm} \wedge a_2 = \sigma_2(z_2), +$$ + +

    and the cost function

    +$$ +C(x;\boldsymbol{\Theta})=\frac{1}{2}(a_2-y)^2, +$$ + +

    with \( \boldsymbol{\Theta}=[w_1,w_2,b_1,b_2] \).

    +

    diff --git a/doc/pub/week42/html/._week42-bs011.html b/doc/pub/week42/html/._week42-bs011.html index 294be80d4..1f3594913 100644 --- a/doc/pub/week42/html/._week42-bs011.html +++ b/doc/pub/week42/html/._week42-bs011.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,49 +457,13 @@ MathJax.Hub.Config({

     

     

     

    -

    Simple example

    - -

    Our first example is rather simple,

    -$$ -f(x) =\exp{x^2}, -$$ - -

    with derivative

    -$$ -f'(x) =2x\exp{x^2}. -$$ - -

    We can use SymPy to extract the pertinent lines of Python code through the following simple example

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = exp(x*x)
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    Layout of a simple neural network with one hidden layer

    +

    +
    +

    +
    +

    @@ -609,7 +490,7 @@ derivative = diff(expr,x)

  • 20
  • 21
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs012.html b/doc/pub/week42/html/._week42-bs012.html index e3fc9e6d0..834a84a1f 100644 --- a/doc/pub/week42/html/._week42-bs012.html +++ b/doc/pub/week42/html/._week42-bs012.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,22 +457,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Smarter way of evaluating the above function

    -

    If we study this function, we note that we can reduce the number of operations by introducing an intermediate variable

    +

    The derivatives

    + +

    The derivatives are now, using the chain rule again

    + $$ -a = x^2, +\frac{\partial C}{\partial w_2}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial w_2}=(a_2-y)\sigma_2'a_1=\delta_2a_1, $$ -

    leading to

    $$ -f(x) = f(a(x)) = b= \exp{a}. +\frac{\partial C}{\partial b_2}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial b_2}=(a_2-y)\sigma_2'=\delta_2, $$ -

    We now assume that all operations can be counted in terms of equal -floating point operations. This means that in order to calculate -\( f(x) \) we need first to square \( x \) and then compute the exponential. We -have thus two floating point operations only. -

    +$$ +\frac{\partial C}{\partial w_1}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial w_1}=(a_2-y)\sigma_2'a_1\sigma_1'a_0, +$$ + +$$ +\frac{\partial C}{\partial b_1}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial b_1}=(a_2-y)\sigma_2'\sigma_1'=\delta_1. +$$ + +

    Can you generalize this to more than one hidden layer?

    @@ -582,7 +504,7 @@ have thus two floating point operations only.

  • 21
  • 22
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs013.html b/doc/pub/week42/html/._week42-bs013.html index db96d8c66..a6f1b0282 100644 --- a/doc/pub/week42/html/._week42-bs013.html +++ b/doc/pub/week42/html/._week42-bs013.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,24 +457,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Reducing the number of operations

    +

    Important observations

    -

    With the introduction of a precalculated quantity \( a \) and thereby \( f(x) \) we have that the derivative can be written as

    - -$$ -f'(x) = 2xb, -$$ - -

    which reduces the number of operations from four in the orginal -expression to two. This means that if we need to compute \( f(x) \) and -its derivative (a common task in optimizations), we have reduced the -number of operations from six to four in total. +

    +
    + +

    From the above equations we see that the derivatives of the activation +functions play a central role. If they vanish, the training may +stop. This is called the vanishing gradient problem, see discussions below. If they become +large, the parameters \( w_i \) and \( b_i \) may simply go to infinity. This +is referenced as the exploding gradient problem.

    +
    +
    -

    Note that the usage of a symbolic software like SymPy does not -include such simplifications and the calculations of the function and -the derivatives yield in general more floating point operations. -

    @@ -584,7 +497,7 @@ the derivatives yield in general more floating point operations.

  • 22
  • 23
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs014.html b/doc/pub/week42/html/._week42-bs014.html index 078b44a58..ec140681c 100644 --- a/doc/pub/week42/html/._week42-bs014.html +++ b/doc/pub/week42/html/._week42-bs014.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,24 @@ MathJax.Hub.Config({

     

     

     

    -

    Chain rule, forward and reverse modes

    +

    The training

    + +

    The training of the parameters is done through various gradient descent approximations with

    -

    In the above example we have introduced the variables \( a \) and \( b \), and our function is

    $$ -f(x) = f(a(x)) = b= \exp{a}, +w_{i}\leftarrow w_{i}- \eta \delta_i a_{i-1}, $$ -

    with \( a=x^2 \). We can decompose the derivative of \( f \) with respect to \( x \) as

    +

    and

    $$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}. +b_i \leftarrow b_i-\eta \delta_i, $$ -

    We note that since \( b=f(x) \) that

    -$$ -\frac{df}{db}=1, -$$ +

    with \( \eta \) is the learning rate.

    -

    leading to

    -$$ -\frac{df}{dx}=\frac{db}{da}\frac{da}{dx}=2x\exp{x^2}, -$$ +

    One iteration consists of one feed forward step and one back-propagation step. Each back-propagation step does one update of the parameters \( \boldsymbol{\Theta} \).

    -

    as before.

    +

    For the first hidden layer \( a_{i-1}=a_0=x \) for this simple model.

    @@ -589,7 +501,7 @@ $$

  • 23
  • 24
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs015.html b/doc/pub/week42/html/._week42-bs015.html index d920d369b..0f433440e 100644 --- a/doc/pub/week42/html/._week42-bs015.html +++ b/doc/pub/week42/html/._week42-bs015.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,33 +457,101 @@ MathJax.Hub.Config({

     

     

     

    -

    Forward and reverse modes

    +

    Code example

    -

    We have that

    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}, -$$ - -

    which we can rewrite either as

    -$$ -\frac{df}{dx}=\left[\frac{df}{db}\frac{db}{da}\right]\frac{da}{dx}, -$$ - -

    or

    -$$ -\frac{df}{dx}=\frac{df}{db}\left[\frac{db}{da}\frac{da}{dx}\right]. -$$ - -

    The first expression is called reverse mode (or back propagation) -since we start by evaluating the derivatives at the end point and then -propagate backwards. This is the standard way of evaluating -derivatives (gradients) when optimizing the parameters of a neural -network. In the context of deep learning this is computationally -more efficient since the output of a neural network consists of either -one or some few other output variables. +

    The code here implements the above model with one hidden layer and +scalar variables for the same function we studied in the previous +example. The code is however set up so that we can add multiple +inputs \( x \) and target values \( y \). Note also that we have the +possibility of defining a feature matrix \( \boldsymbol{X} \) with more than just +one column for the input values. This will turn useful in our next example. We have also defined matrices and vectors for all of our operations although it is not necessary here.

    -

    The second equation defines the so-called forward mode.

    + + +
    +
    +
    +
    +
    +
    import numpy as np
    +# We use the Sigmoid function as activation function
    +def sigmoid(z):
    +    return 1.0/(1.0+np.exp(-z))
    +
    +def forwardpropagation(x):
    +    # weighted sum of inputs to the hidden layer
    +    z_1 = np.matmul(x, w_1) + b_1
    +    # activation in the hidden layer
    +    a_1 = sigmoid(z_1)
    +    # weighted sum of inputs to the output layer
    +    z_2 = np.matmul(a_1, w_2) + b_2
    +    a_2 = z_2
    +    return a_1, a_2
    +
    +def backpropagation(x, y):
    +    a_1, a_2 = forwardpropagation(x)
    +    # parameter delta for the output layer, note that a_2=z_2 and its derivative wrt z_2 is just 1
    +    delta_2 = a_2 - y
    +    print(0.5*((a_2-y)**2))
    +    # delta for  the hidden layer
    +    delta_1 = np.matmul(delta_2, w_2.T) * a_1 * (1 - a_1)
    +    # gradients for the output layer
    +    output_weights_gradient = np.matmul(a_1.T, delta_2)
    +    output_bias_gradient = np.sum(delta_2, axis=0)
    +    # gradient for the hidden layer
    +    hidden_weights_gradient = np.matmul(x.T, delta_1)
    +    hidden_bias_gradient = np.sum(delta_1, axis=0)
    +    return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient
    +
    +
    +# ensure the same random numbers appear every time
    +np.random.seed(0)
    +# Input variable
    +x = np.array([4.0],dtype=np.float64)
    +# Target values
    +y = 2*x+1.0 
    +
    +# Defining the neural network, only scalars here
    +n_inputs = x.shape
    +n_features = 1
    +n_hidden_neurons = 1
    +n_outputs = 1
    +
    +# Initialize the network
    +# weights and bias in the hidden layer
    +w_1 = np.random.randn(n_features, n_hidden_neurons)
    +b_1 = np.zeros(n_hidden_neurons) + 0.01
    +
    +# weights and bias in the output layer
    +w_2 = np.random.randn(n_hidden_neurons, n_outputs)
    +b_2 = np.zeros(n_outputs) + 0.01
    +
    +eta = 0.1
    +for i in range(50):
    +    # calculate gradients
    +    derivW2, derivB2, derivW1, derivB1 = backpropagation(x, y)
    +    # update weights and biases
    +    w_2 -= eta * derivW2
    +    b_2 -= eta * derivB2
    +    w_1 -= eta * derivW1
    +    b_1 -= eta * derivB1
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    We see that after some few iterations (the results do depend on the learning rate however), we get an error which is rather small.

    @@ -593,7 +578,7 @@ one or some few other output variables.

  • 24
  • 25
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs016.html b/doc/pub/week42/html/._week42-bs016.html index 4b9e9bd49..ddd2039f8 100644 --- a/doc/pub/week42/html/._week42-bs016.html +++ b/doc/pub/week42/html/._week42-bs016.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,49 +457,25 @@ MathJax.Hub.Config({

     

     

     

    -

    More complicated function

    +

    Simple neural network and the back propagation equations

    -

    We increase our ambitions and introduce a slightly more complicated function

    +

    Let us now try to increase our level of ambition and attempt at setting +up the equations for a neural network with two input nodes, one hidden +layer with two hidden nodes and one output layer with one output node/neuron only (see graph).. +

    + +

    We need to define the following parameters and variables with the input layer (layer \( (0) \)) +where we label the nodes \( x_0 \) and \( x_1 \) +

    $$ -f(x) =\sqrt{x^2+exp{x^2}}, +x_0 = a_0^{(0)} \wedge x_1 = a_1^{(0)}. $$ -

    with derivative

    +

    The hidden layer (layer \( (1) \)) has nodes which yield the outputs \( a_0^{(1)} \) and \( a_1^{(1)} \)) with weight \( \boldsymbol{w} \) and bias \( \boldsymbol{b} \) parameters

    $$ -f'(x) =\frac{x(1+\exp{x^2})}{\sqrt{x^2+exp{x^2}}}. +w_{ij}^{(1)}=\left\{w_{00}^{(1)},w_{01}^{(1)},w_{10}^{(1)},w_{11}^{(1)}\right\} \wedge b^{(1)}=\left\{b_0^{(1)},b_1^{(1)}\right\}. $$ -

    The corresponding SymPy code reads

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = sqrt(x*x+exp(x*x))
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    @@ -609,7 +502,7 @@ derivative = diff(expr,x)

  • 25
  • 26
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs017.html b/doc/pub/week42/html/._week42-bs017.html index cd8597932..6284d7bb7 100644 --- a/doc/pub/week42/html/._week42-bs017.html +++ b/doc/pub/week42/html/._week42-bs017.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,15 +457,13 @@ MathJax.Hub.Config({

     

     

     

    -

    Counting the number of floating point operations

    +

    Layout of a simple neural network with two input nodes, one hidden layer and one output node

    -

    A simple count of operations shows that we need five operations for -the function itself and ten for the derivative. Fifteen operations in total if we wish to proceed with the above codes. -

    - -

    Can we reduce this to -say half the number of operations? -

    +

    +
    +

    +
    +

    @@ -575,7 +490,7 @@ say half the number of operations?

  • 26
  • 27
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs018.html b/doc/pub/week42/html/._week42-bs018.html index 5775dcaf0..2449657cd 100644 --- a/doc/pub/week42/html/._week42-bs018.html +++ b/doc/pub/week42/html/._week42-bs018.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,28 +457,18 @@ MathJax.Hub.Config({

     

     

     

    -

    Defining intermediate operations

    +

    The ouput layer

    -

    We can indeed reduce the number of operation to half of those listed in the brute force approach above. -We define the following quantities +

    Finally, we have the ouput layer given by layer label \( (2) \) with output \( a^{(2)} \) and weights and biases to be determined given by the variables

    +$$ +w_{i}^{(2)}=\left\{w_{0}^{(2)},w_{1}^{(2)}\right\} \wedge b^{(2)}. +$$ + +

    Our output is \( \tilde{y}=a^{(2)} \) and we define a generic cost function \( C(a^{(2)},y;\boldsymbol{\Theta}) \) where \( y \) is the target value (a scalar here). +The parameters we need to optimize are given by

    $$ -a = x^2, -$$ - -

    and

    -$$ -b = \exp{x^2} = \exp{a}, -$$ - -

    and

    -$$ -c= a+b, -$$ - -

    and

    -$$ -d=f(x)=\sqrt{c}. +\boldsymbol{\Theta}=\left\{w_{00}^{(1)},w_{01}^{(1)},w_{10}^{(1)},w_{11}^{(1)},w_{0}^{(2)},w_{1}^{(2)},b_0^{(1)},b_1^{(1)},b^{(2)}\right\}. $$ @@ -590,7 +497,7 @@ $$
  • 27
  • 28
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs019.html b/doc/pub/week42/html/._week42-bs019.html index 9882e9a87..0eac6400e 100644 --- a/doc/pub/week42/html/._week42-bs019.html +++ b/doc/pub/week42/html/._week42-bs019.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,36 +457,18 @@ MathJax.Hub.Config({

     

     

     

    -

    New expression for the derivative

    +

    Compact expressions

    -

    With these definitions we obtain the following partial derivatives

    +

    We can define the inputs to the activation functions for the various layers in terms of various matrix-vector multiplications and vector additions. +The inputs to the first hidden layer are +

    $$ -\frac{\partial a}{\partial x} = 2x, +\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\left(\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\right)^{T}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, $$ -

    and

    +

    with outputs

    $$ -\frac{\partial b}{\partial a} = \exp{a}, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial a} = 1, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial b} = 1, -$$ - -

    and

    -$$ -\frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial d} = 1. +\begin{bmatrix}a_0^{(1)} \\ a_1^{(1)} \end{bmatrix}=\begin{bmatrix}\sigma^{(1)}(z_0^{(1)}) \\ \sigma^{(1)}(z_1^{(1)}) \end{bmatrix}. $$ @@ -598,7 +497,7 @@ $$
  • 28
  • 29
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs020.html b/doc/pub/week42/html/._week42-bs020.html index 9885060e7..a84ac648e 100644 --- a/doc/pub/week42/html/._week42-bs020.html +++ b/doc/pub/week42/html/._week42-bs020.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,32 +457,18 @@ MathJax.Hub.Config({

     

     

     

    -

    Final derivatives

    -

    Our final derivatives are thus

    +

    Output layer

    + +

    For the final output layer we have the inputs to the final activation function

    $$ -\frac{\partial f}{\partial c} = \frac{\partial f}{\partial d} \frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, +z^{(2)} = w_{0}^{(2)}a_0^{(1)} +w_{1}^{(2)}a_1^{(1)}+b^{(2)}, $$ +

    resulting in the output

    $$ -\frac{\partial f}{\partial b} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial b} = \frac{1}{2\sqrt{c}}, +a^{(2)}=\sigma^{(2)}(z^{(2)}). $$ -$$ -\frac{\partial f}{\partial a} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial a}+ -\frac{\partial f}{\partial b} \frac{\partial b}{\partial a} = \frac{1+\exp{a}}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial x} = \frac{\partial f}{\partial a} \frac{\partial a}{\partial x} = \frac{x(1+\exp{a})}{\sqrt{c}}, -$$ - -

    which is just

    -$$ -\frac{\partial f}{\partial x} = \frac{x(1+b)}{d}, -$$ - -

    and requires only three operations if we can reuse all intermediate variables.

    @@ -592,7 +495,7 @@ $$

  • 29
  • 30
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs021.html b/doc/pub/week42/html/._week42-bs021.html index d3f2ffde1..a69de5a4e 100644 --- a/doc/pub/week42/html/._week42-bs021.html +++ b/doc/pub/week42/html/._week42-bs021.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,15 +457,30 @@ MathJax.Hub.Config({

     

     

     

    -

    In general not this simple

    +

    Explicit derivatives

    -

    In general, see the generalization below, unless we can obtain simple -analytical expressions which we can simplify further, the final -implementation of automatic differentiation involves repeated -calculations (and thereby operations) of derivatives of elementary -functions. +

    In total we have nine parameters which we need to train. Using the +chain rule (or just the back-propagation algorithm) we can find all +derivatives. Since we will use automatic differentiation in reverse +mode, we start with the derivatives of the cost function with respect +to the parameters of the output layer, namely

    +$$ +\frac{\partial C}{\partial w_{i}^{(2)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}}\frac{\partial z^{(2)}}{\partial w_{i}^{(2)}}=\delta^{(2)}a_i^{(1)}, +$$ + +

    with

    +$$ +\delta^{(2)}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}} +$$ + +

    and finally

    +$$ +\frac{\partial C}{\partial b^{(2)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}}\frac{\partial z^{(2)}}{\partial b^{(2)}}=\delta^{(2)}. +$$ + +

    diff --git a/doc/pub/week42/html/._week42-bs022.html b/doc/pub/week42/html/._week42-bs022.html index a47dd343f..55e51689c 100644 --- a/doc/pub/week42/html/._week42-bs022.html +++ b/doc/pub/week42/html/._week42-bs022.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,24 +457,24 @@ MathJax.Hub.Config({

     

     

     

    -

    Automatic differentiation

    +

    Derivatives of the hidden layer

    -

    We can make this example more formal. Automatic differentiation is a -formalization of the previous example (see graph). -

    - -

    We define \( \boldsymbol{x}\in x_1,\dots, x_l \) input variables to a given function \( f(\boldsymbol{x}) \) and \( x_{l+1},\dots, x_L \) intermediate variables.

    - -

    In the above example we have only one input variable, \( l=1 \) and four intermediate variables, that is

    +

    Using the chain rule we have the following expressions for say one of the weight parameters (it is easy to generalize to the other weight parameters)

    $$ -\begin{bmatrix} x_1=x & x_2 = x^2=a & x_3 =\exp{a}= b & x_4=c=a+b & x_5 = \sqrt{c}=d \end{bmatrix}. +\frac{\partial C}{\partial w_{00}^{(1)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}} +\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}= \delta^{(2)}\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}, $$ -

    Furthemore, for \( i=l+1, \dots, L \) (here \( i=2,3,4,5 \) and \( f=x_L=d \)), we -define the elementary functions \( g_i(x_{Pa(x_i)}) \) where \( x_{Pa(x_i)} \) are the parent nodes of the variable \( x_i \). -

    +

    which, noting that

    +$$ +z^{(2)} =w_0^{(2)}a_0^{(1)}+w_1^{(2)}a_1^{(1)}+b^{(2)}, +$$ + +

    allows us to rewrite

    +$$ +\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}=w_0^{(2)}\frac{\partial a_0^{(1)}}{\partial z_0^{(1)}}a_0^{(1)}. +$$ -

    In our case, we have for example for \( x_3=g_3(x_{Pa(x_i)})=\exp{a} \), that \( g_3=\exp{()} \) and \( x_{Pa(x_3)}=a \).

    @@ -584,7 +501,7 @@ define the elementary functions \( g_i(x_{Pa(x_i)}) \) where \( x_{Pa(x_i)} \) a

  • 31
  • 32
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs023.html b/doc/pub/week42/html/._week42-bs023.html index 4e3a6d5e3..f9ef2d351 100644 --- a/doc/pub/week42/html/._week42-bs023.html +++ b/doc/pub/week42/html/._week42-bs023.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Chain rule

    - -

    We can now compute the gradients by back-propagating the derivatives using the chain rule. -We have defined -

    +

    Final expression

    +

    Defining

    $$ -\frac{\partial f}{\partial x_L} = 1, +\delta_0^{(1)}=w_0^{(2)}\frac{\partial a_0^{(1)}}{\partial z_0^{(1)}}\delta^{(2)}, $$ -

    which allows us to find the derivatives of the various variables \( x_i \) as

    +

    we have

    $$ -\frac{\partial f}{\partial x_i} = \sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial x_j}{\partial x_i}=\sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial g_j}{\partial x_i}. +\frac{\partial C}{\partial w_{00}^{(1)}}=\delta_0^{(1)}a_0^{(1)}. +$$ + +

    Similarly, we obtain

    +$$ +\frac{\partial C}{\partial w_{01}^{(1)}}=\delta_0^{(1)}a_1^{(1)}. $$ -

    Whenever we have a function which can be expressed as a computation -graph and the various functions can be expressed in terms of -elementary functions that are differentiable, then automatic -differentiation works. The functions may not need to be elementary -functions, they could also be computer programs, although not all -programs can be automatically differentiated. -

    @@ -587,7 +499,7 @@ programs can be automatically differentiated.

  • 32
  • 33
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs024.html b/doc/pub/week42/html/._week42-bs024.html index 0fdfb72a3..bd5af2a55 100644 --- a/doc/pub/week42/html/._week42-bs024.html +++ b/doc/pub/week42/html/._week42-bs024.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,21 @@ MathJax.Hub.Config({

     

     

     

    -

    First network example, simple percepetron with one input

    - -

    As yet another example we define now a simple perceptron model with -all quantities given by scalars. We consider only one input variable -\( x \) and one target value \( y \). We define an activation function -\( \sigma_1 \) which takes as input -

    +

    Completing the list

    +

    Similarly, we find

    $$ -z_1 = w_1x+b_1, +\frac{\partial C}{\partial w_{10}^{(1)}}=\delta_1^{(1)}a_0^{(1)}, $$ -

    where \( w_1 \) is the weight and \( b_1 \) is the bias. These are the -parameters we want to optimize. The output is \( a_1=\sigma(z_1) \) (see -graph from whiteboard notes). This output is then fed into the -cost/loss function, which we here for the sake of simplicity just -define as the squared error -

    - +

    and

    $$ -C(x;w_1,b_1)=\frac{1}{2}(a_1-y)^2. +\frac{\partial C}{\partial w_{11}^{(1)}}=\delta_1^{(1)}a_1^{(1)}, +$$ + +

    where we have defined

    +$$ +\delta_1^{(1)}=w_1^{(2)}\frac{\partial a_1^{(1)}}{\partial z_1^{(1)}}\delta^{(2)}. $$ @@ -589,7 +500,7 @@ $$
  • 33
  • 34
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs025.html b/doc/pub/week42/html/._week42-bs025.html index 37d30d7bf..a7f4b90a2 100644 --- a/doc/pub/week42/html/._week42-bs025.html +++ b/doc/pub/week42/html/._week42-bs025.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,13 +457,19 @@ MathJax.Hub.Config({

     

     

     

    -

    Layout of a simple neural network with no hidden layer

    +

    Final expressions for the biases of the hidden layer

    -

    -
    -

    -
    -

    +

    For the sake of completeness, we list the derivatives of the biases, which are

    +$$ +\frac{\partial C}{\partial b_{0}^{(1)}}=\delta_0^{(1)}, +$$ + +

    and

    +$$ +\frac{\partial C}{\partial b_{1}^{(1)}}=\delta_1^{(1)}. +$$ + +

    As we will see below, these expressions can be generalized in a more compact form.

    @@ -573,7 +496,7 @@ MathJax.Hub.Config({

  • 34
  • 35
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs026.html b/doc/pub/week42/html/._week42-bs026.html index 521dadf03..ecded6b7e 100644 --- a/doc/pub/week42/html/._week42-bs026.html +++ b/doc/pub/week42/html/._week42-bs026.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,33 +457,31 @@ MathJax.Hub.Config({

     

     

     

    -

    Optimizing the parameters

    +

    Gradient expressions

    -

    In setting up the feed forward and back propagation parts of the -algorithm, we need now the derivative of the various variables we want -to train. +

    For this specific model, with just one output node and two hidden +nodes, the gradient descent equations take the following form for output layer

    - -

    We need

    $$ -\frac{\partial C}{\partial w_1} \hspace{0.1cm}\mathrm{and}\hspace{0.1cm}\frac{\partial C}{\partial b_1}. -$$ - -

    Using the chain rule we find

    -$$ -\frac{\partial C}{\partial w_1}=\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial w_1}=(a_1-y)\sigma_1'x, +w_{i}^{(2)}\leftarrow w_{i}^{(2)}- \eta \delta^{(2)} a_{i}^{(1)}, $$

    and

    $$ -\frac{\partial C}{\partial b_1}=\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial b_1}=(a_1-y)\sigma_1', +b^{(2)} \leftarrow b^{(2)}-\eta \delta^{(2)}, $$ -

    which we later will just define as

    +

    and

    $$ -\frac{\partial C}{\partial a_1}\frac{\partial a_1}{\partial z_1}=\delta_1. +w_{ij}^{(1)}\leftarrow w_{ij}^{(1)}- \eta \delta_{i}^{(1)} a_{j}^{(0)}, $$ +

    and

    +$$ +b_{i}^{(1)} \leftarrow b_{i}^{(1)}-\eta \delta_{i}^{(1)}, +$$ + +

    where \( \eta \) is the learning rate.

    @@ -593,7 +508,7 @@ $$

  • 35
  • 36
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs027.html b/doc/pub/week42/html/._week42-bs027.html index c3488d99e..d080537fa 100644 --- a/doc/pub/week42/html/._week42-bs027.html +++ b/doc/pub/week42/html/._week42-bs027.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,25 @@ MathJax.Hub.Config({

     

     

     

    -

    Adding a hidden layer

    +

    Setting up the equations for a neural network

    -

    We change our simple model to (see graph) -a network with just one hidden layer but with scalar variables only. +

    The questions we want to ask are how do changes in the biases and the +weights in our network change the cost function and how can we use the +final output to modify the weights and biases?

    -

    Our output variable changes to \( a_2 \) and \( a_1 \) is now the output from the hidden node and \( a_0=x \). -We have then +

    To derive these equations let us start with a plain regression problem +and define our cost function as

    -$$ -z_1 = w_1a_0+b_1 \hspace{0.1cm} \wedge a_1 = \sigma_1(z_1), -$$ $$ -z_2 = w_2a_1+b_2 \hspace{0.1cm} \wedge a_2 = \sigma_2(z_2), +{\cal C}(\boldsymbol{\Theta}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - \tilde{y}_i\right)^2, $$ -

    and the cost function

    -$$ -C(x;\boldsymbol{\Theta})=\frac{1}{2}(a_2-y)^2, -$$ - -

    with \( \boldsymbol{\Theta}=[w_1,w_2,b_1,b_2] \).

    +

    where the $y_i$s are our \( n \) targets (the values we want to +reproduce), while the outputs of the network after having propagated +all inputs \( \boldsymbol{x} \) are given by \( \boldsymbol{\tilde{y}}_i \). +

    @@ -589,7 +502,7 @@ $$

  • 36
  • 37
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs028.html b/doc/pub/week42/html/._week42-bs028.html index f49e30e98..9ff9b2a49 100644 --- a/doc/pub/week42/html/._week42-bs028.html +++ b/doc/pub/week42/html/._week42-bs028.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,11 +457,11 @@ MathJax.Hub.Config({

     

     

     

    -

    Layout of a simple neural network with one hidden layer

    +

    Layout of a neural network with three hidden layers



    -

    +



    @@ -573,7 +490,7 @@ MathJax.Hub.Config({
  • 37
  • 38
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs029.html b/doc/pub/week42/html/._week42-bs029.html index 09e02e808..494b7a613 100644 --- a/doc/pub/week42/html/._week42-bs029.html +++ b/doc/pub/week42/html/._week42-bs029.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,30 @@ MathJax.Hub.Config({

     

     

     

    -

    The derivatives

    +

    Definitions

    -

    The derivatives are now, using the chain rule again

    +

    With our definition of the targets \( \boldsymbol{y} \), the outputs of the +network \( \boldsymbol{\tilde{y}} \) and the inputs \( \boldsymbol{x} \) we +define now the activation \( z_j^l \) of node/neuron/unit \( j \) of the +\( l \)-th layer as a function of the bias, the weights which add up from +the previous layer \( l-1 \) and the forward passes/outputs +\( \boldsymbol{a}^{l-1} \) from the previous layer as +

    $$ -\frac{\partial C}{\partial w_2}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial w_2}=(a_2-y)\sigma_2'a_1=\delta_2a_1, +z_j^l = \sum_{i=1}^{M_{l-1}}w_{ij}^la_i^{l-1}+b_j^l, $$ -$$ -\frac{\partial C}{\partial b_2}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial b_2}=(a_2-y)\sigma_2'=\delta_2, -$$ +

    where \( b_k^l \) are the biases from layer \( l \). Here \( M_{l-1} \) +represents the total number of nodes/neurons/units of layer \( l-1 \). The +figure in the whiteboard notes illustrates this equation. We can rewrite this in a more +compact form as the matrix-vector products we discussed earlier, +

    $$ -\frac{\partial C}{\partial w_1}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial w_1}=(a_2-y)\sigma_2'a_1\sigma_1'a_0, +\boldsymbol{z}^l = \left(\boldsymbol{W}^l\right)^T\boldsymbol{a}^{l-1}+\boldsymbol{b}^l. $$ -$$ -\frac{\partial C}{\partial b_1}=\frac{\partial C}{\partial a_2}\frac{\partial a_2}{\partial z_2}\frac{\partial z_2}{\partial a_1}\frac{\partial a_1}{\partial z_1}\frac{\partial z_1}{\partial b_1}=(a_2-y)\sigma_2'\sigma_1'=\delta_1. -$$ - -

    Can you generalize this to more than one hidden layer?

    @@ -587,7 +507,7 @@ $$

  • 38
  • 39
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs030.html b/doc/pub/week42/html/._week42-bs030.html index f2777cb1a..eee5502ff 100644 --- a/doc/pub/week42/html/._week42-bs030.html +++ b/doc/pub/week42/html/._week42-bs030.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,19 +457,18 @@ MathJax.Hub.Config({

     

     

     

    -

    Important observations

    +

    Inputs to the activation function

    -
    -
    - -

    From the above equations we see that the derivatives of the activation -functions play a central role. If they vanish, the training may -stop. This is called the vanishing gradient problem, see discussions below. If they become -large, the parameters \( w_i \) and \( b_i \) may simply go to infinity. This -is referenced as the exploding gradient problem. +

    With the activation values \( \boldsymbol{z}^l \) we can in turn define the +output of layer \( l \) as \( \boldsymbol{a}^l = \sigma(\boldsymbol{z}^l) \) where \( \sigma \) is our +activation function. In the examples here we will use the sigmoid +function discussed in our logistic regression lectures. We will also use the same activation function \( \sigma \) for all layers +and their nodes. It means we have

    -
    -
    + +$$ +a_j^l = \sigma(z_j^l) = \frac{1}{1+\exp{-(z_j^l)}}. +$$

    @@ -580,7 +496,7 @@ is referenced as the exploding gradient problem.

  • 39
  • 40
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs031.html b/doc/pub/week42/html/._week42-bs031.html index ff9fbcb63..cc7596e1e 100644 --- a/doc/pub/week42/html/._week42-bs031.html +++ b/doc/pub/week42/html/._week42-bs031.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,24 +457,23 @@ MathJax.Hub.Config({

     

     

     

    -

    The training

    - -

    The training of the parameters is done through various gradient descent approximations with

    +

    Derivatives and the chain rule

    +

    From the definition of the input variable to the activation function, that is \( z_j^l \) we have

    $$ -w_{i}\leftarrow w_{i}- \eta \delta_i a_{i-1}, +\frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, $$

    and

    $$ -b_i \leftarrow b_i-\eta \delta_i, +\frac{\partial z_j^l}{\partial a_i^{l-1}} = w_{ji}^l. $$ -

    with \( \eta \) is the learning rate.

    +

    With our definition of the activation function we have that (note that this function depends only on \( z_j^l \))

    +$$ +\frac{\partial a_j^l}{\partial z_j^{l}} = a_j^l(1-a_j^l)=\sigma(z_j^l)(1-\sigma(z_j^l)). +$$ -

    One iteration consists of one feed forward step and one back-propagation step. Each back-propagation step does one update of the parameters \( \boldsymbol{\Theta} \).

    - -

    For the first hidden layer \( a_{i-1}=a_0=x \) for this simple model.

    @@ -584,7 +500,7 @@ $$

  • 40
  • 41
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs032.html b/doc/pub/week42/html/._week42-bs032.html index a9a364ec4..9b2b119e0 100644 --- a/doc/pub/week42/html/._week42-bs032.html +++ b/doc/pub/week42/html/._week42-bs032.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,102 +457,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Code example

    +

    Derivative of the cost function

    -

    The code here implements the above model with one hidden layer and -scalar variables for the same function we studied in the previous -example. The code is however set up so that we can add multiple -inputs \( x \) and target values \( y \). Note also that we have the -possibility of defining a feature matrix \( \boldsymbol{X} \) with more than just -one column for the input values. This will turn useful in our next example. We have also defined matrices and vectors for all of our operations although it is not necessary here. -

    +

    With these definitions we can now compute the derivative of the cost function in terms of the weights.

    +

    Let us specialize to the output layer \( l=L \). Our cost function is

    +$$ +{\cal C}(\boldsymbol{\Theta}^L) = \frac{1}{2}\sum_{i=1}^n\left(y_i - \tilde{y}_i\right)^2=\frac{1}{2}\sum_{i=1}^n\left(a_i^L - y_i\right)^2, +$$ - -
    -
    -
    -
    -
    -
    import numpy as np
    -# We use the Sigmoid function as activation function
    -def sigmoid(z):
    -    return 1.0/(1.0+np.exp(-z))
    +

    The derivative of this function with respect to the weights is

    -def forwardpropagation(x): - # weighted sum of inputs to the hidden layer - z_1 = np.matmul(x, w_1) + b_1 - # activation in the hidden layer - a_1 = sigmoid(z_1) - # weighted sum of inputs to the output layer - z_2 = np.matmul(a_1, w_2) + b_2 - a_2 = z_2 - return a_1, a_2 +$$ +\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{ij}^{L}}, +$$ -def backpropagation(x, y): - a_1, a_2 = forwardpropagation(x) - # parameter delta for the output layer, note that a_2=z_2 and its derivative wrt z_2 is just 1 - delta_2 = a_2 - y - print(0.5*((a_2-y)**2)) - # delta for the hidden layer - delta_1 = np.matmul(delta_2, w_2.T) * a_1 * (1 - a_1) - # gradients for the output layer - output_weights_gradient = np.matmul(a_1.T, delta_2) - output_bias_gradient = np.sum(delta_2, axis=0) - # gradient for the hidden layer - hidden_weights_gradient = np.matmul(x.T, delta_1) - hidden_bias_gradient = np.sum(delta_1, axis=0) - return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient +

    The last partial derivative can easily be computed and reads (by applying the chain rule)

    +$$ +\frac{\partial a_j^L}{\partial w_{ij}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{ij}^{L}}=a_j^L(1-a_j^L)a_i^{L-1}. +$$ -# ensure the same random numbers appear every time -np.random.seed(0) -# Input variable -x = np.array([4.0],dtype=np.float64) -# Target values -y = 2*x+1.0 - -# Defining the neural network, only scalars here -n_inputs = x.shape -n_features = 1 -n_hidden_neurons = 1 -n_outputs = 1 - -# Initialize the network -# weights and bias in the hidden layer -w_1 = np.random.randn(n_features, n_hidden_neurons) -b_1 = np.zeros(n_hidden_neurons) + 0.01 - -# weights and bias in the output layer -w_2 = np.random.randn(n_hidden_neurons, n_outputs) -b_2 = np.zeros(n_outputs) + 0.01 - -eta = 0.1 -for i in range(50): - # calculate gradients - derivW2, derivB2, derivW1, derivB1 = backpropagation(x, y) - # update weights and biases - w_2 -= eta * derivW2 - b_2 -= eta * derivB2 - w_1 -= eta * derivW1 - b_1 -= eta * derivB1 -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -

    We see that after some few iterations (the results do depend on the learning rate however), we get an error which is rather small.

    -

    diff --git a/doc/pub/week42/html/._week42-bs033.html b/doc/pub/week42/html/._week42-bs033.html index 11a36c338..aa2a0fbbb 100644 --- a/doc/pub/week42/html/._week42-bs033.html +++ b/doc/pub/week42/html/._week42-bs033.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,20 +457,23 @@ MathJax.Hub.Config({

     

     

     

    +

    The back propagation equations for a neural network

    - -

    Exercise 1: Including more data

    +

    We have thus

    +$$ +\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_i^{L-1}, +$$ -

    Try to increase the amount of input and -target/output data. Try also to perform calculations for more values -of the learning rates. Feel free to add either hyperparameters with an -\( l_1 \) norm or an \( l_2 \) norm and discuss your results. -Discuss your results as functions of the amount of training data and various learning rates. -

    +

    Defining

    +$$ +\delta_j^L = a_j^L(1-a_j^L)\left(a_j^L - y_j\right) = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}, +$$ -

    Challenge: Try to change the activation functions and replace the hard-coded analytical expressions with automatic derivation via either autograd or JAX.

    +

    and using the Hadamard product of two vectors we can write this as

    +$$ +\boldsymbol{\delta}^L = \sigma'(\boldsymbol{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. +$$ -

    @@ -580,7 +500,7 @@ Discuss your results as functions of the amount of training data and various lea

  • 42
  • 43
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs034.html b/doc/pub/week42/html/._week42-bs034.html index 764b2e301..61ee18d9c 100644 --- a/doc/pub/week42/html/._week42-bs034.html +++ b/doc/pub/week42/html/._week42-bs034.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,26 +457,17 @@ MathJax.Hub.Config({

     

     

     

    -

    Simple neural network and the back propagation equations

    +

    Analyzing the last results

    -

    Let us now try to increase our level of ambition and attempt at setting -up the equations for a neural network with two input nodes, one hidden -layer with two hidden nodes and one output layer with one output node/neuron only (see graph).. +

    This is an important expression. The second term on the right handside +measures how fast the cost function is changing as a function of the $j$th +output activation. If, for example, the cost function doesn't depend +much on a particular output node \( j \), then \( \delta_j^L \) will be small, +which is what we would expect. The first term on the right, measures +how fast the activation function \( f \) is changing at a given activation +value \( z_j^L \).

    -

    We need to define the following parameters and variables with the input layer (layer \( (0) \)) -where we label the nodes \( x_0 \) and \( x_1 \) -

    -$$ -x_0 = a_0^{(0)} \wedge x_1 = a_1^{(0)}. -$$ - -

    The hidden layer (layer \( (1) \)) has nodes which yield the outputs \( a_0^{(1)} \) and \( a_1^{(1)} \)) with weight \( \boldsymbol{w} \) and bias \( \boldsymbol{b} \) parameters

    -$$ -w_{ij}^{(1)}=\left\{w_{00}^{(1)},w_{01}^{(1)},w_{10}^{(1)},w_{11}^{(1)}\right\} \wedge b^{(1)}=\left\{b_0^{(1)},b_1^{(1)}\right\}. -$$ - -

    diff --git a/doc/pub/week42/html/._week42-bs035.html b/doc/pub/week42/html/._week42-bs035.html index 6c5e7427a..9125a580e 100644 --- a/doc/pub/week42/html/._week42-bs035.html +++ b/doc/pub/week42/html/._week42-bs035.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,13 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Layout of a simple neural network with two input nodes, one hidden layer and one output node

    +

    More considerations

    + +

    Notice that everything in the above equations is easily computed. In +particular, we compute \( z_j^L \) while computing the behaviour of the +network, and it is only a small additional overhead to compute +\( \sigma'(z^L_j) \). The exact form of the derivative with respect to the +output depends on the form of the cost function. +However, provided the cost function is known there should be little +trouble in calculating +

    + +$$ +\frac{\partial {\cal C}}{\partial (a_j^L)} +$$ + +

    With the definition of \( \delta_j^L \) we have a more compact definition of the derivative of the cost function in terms of the weights, namely

    +$$ +\frac{\partial{\cal C}}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}. +$$ -

    -
    -

    -
    -

    @@ -573,7 +503,7 @@ MathJax.Hub.Config({

  • 44
  • 45
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs036.html b/doc/pub/week42/html/._week42-bs036.html index 0e8015f08..94383fcbd 100644 --- a/doc/pub/week42/html/._week42-bs036.html +++ b/doc/pub/week42/html/._week42-bs036.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,20 +457,20 @@ MathJax.Hub.Config({

     

     

     

    -

    The ouput layer

    +

    Derivatives in terms of \( z_j^L \)

    + +

    It is also easy to see that our previous equation can be written as

    -

    Finally, we have the ouput layer given by layer label \( (2) \) with output \( a^{(2)} \) and weights and biases to be determined given by the variables

    $$ -w_{i}^{(2)}=\left\{w_{0}^{(2)},w_{1}^{(2)}\right\} \wedge b^{(2)}. +\delta_j^L =\frac{\partial {\cal C}}{\partial z_j^L}= \frac{\partial {\cal C}}{\partial a_j^L}\frac{\partial a_j^L}{\partial z_j^L}, $$ -

    Our output is \( \tilde{y}=a^{(2)} \) and we define a generic cost function \( C(a^{(2)},y;\boldsymbol{\Theta}) \) where \( y \) is the target value (a scalar here). -The parameters we need to optimize are given by -

    +

    which can also be interpreted as the partial derivative of the cost function with respect to the biases \( b_j^L \), namely

    $$ -\boldsymbol{\Theta}=\left\{w_{00}^{(1)},w_{01}^{(1)},w_{10}^{(1)},w_{11}^{(1)},w_{0}^{(2)},w_{1}^{(2)},b_0^{(1)},b_1^{(1)},b^{(2)}\right\}. +\delta_j^L = \frac{\partial {\cal C}}{\partial b_j^L}\frac{\partial b_j^L}{\partial z_j^L}=\frac{\partial {\cal C}}{\partial b_j^L}, $$ +

    That is, the error \( \delta_j^L \) is exactly equal to the rate of change of the cost function as a function of the bias.

    @@ -580,7 +497,7 @@ $$

  • 45
  • 46
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs037.html b/doc/pub/week42/html/._week42-bs037.html index 7f0b91123..ab9b6e9aa 100644 --- a/doc/pub/week42/html/._week42-bs037.html +++ b/doc/pub/week42/html/._week42-bs037.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,18 +457,32 @@ MathJax.Hub.Config({

     

     

     

    -

    Compact expressions

    +

    Bringing it together

    + +

    We have now three equations that are essential for the computations of the derivatives of the cost function at the output layer. These equations are needed to start the algorithm and they are

    -

    We can define the inputs to the activation functions for the various layers in terms of various matrix-vector multiplications and vector additions. -The inputs to the first hidden layer are -

    $$ -\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, +\begin{equation} +\frac{\partial{\cal C}(\boldsymbol{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, +\tag{1} +\end{equation} $$ -

    with outputs

    +

    and

    $$ -\begin{bmatrix}a_0^{(1)} \\ a_1^{(1)} \end{bmatrix}=\begin{bmatrix}\sigma^{(1)}(z_0^{(1)}) \\ \sigma^{(1)}(z_1^{(1)}) \end{bmatrix}. +\begin{equation} +\delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}, +\tag{2} +\end{equation} +$$ + +

    and

    + +$$ +\begin{equation} +\delta_j^L = \frac{\partial {\cal C}}{\partial b_j^L}, +\tag{3} +\end{equation} $$ @@ -580,7 +511,7 @@ $$
  • 46
  • 47
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs038.html b/doc/pub/week42/html/._week42-bs038.html index 0730669ac..1ba4bbe23 100644 --- a/doc/pub/week42/html/._week42-bs038.html +++ b/doc/pub/week42/html/._week42-bs038.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,18 +457,14 @@ MathJax.Hub.Config({

     

     

     

    -

    Output layer

    +

    Final back propagating equation

    -

    For the final output layer we have the inputs to the final activation function

    +

    We have that (replacing \( L \) with a general layer \( l \))

    $$ -z^{(2)} = w_{0}^{(2)}a_0^{(1)} +w_{1}^{(2)}a_1^{(1)}+b^{(2)}, -$$ - -

    resulting in the output

    -$$ -a^{(2)}=\sigma^{(2)}(z^{(2)}). +\delta_j^l =\frac{\partial {\cal C}}{\partial z_j^l}. $$ +

    We want to express this in terms of the equations for layer \( l+1 \).

    @@ -578,7 +491,7 @@ $$

  • 47
  • 48
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs039.html b/doc/pub/week42/html/._week42-bs039.html index c5bc39d08..f91b8d751 100644 --- a/doc/pub/week42/html/._week42-bs039.html +++ b/doc/pub/week42/html/._week42-bs039.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Explicit derivatives

    - -

    In total we have nine parameters which we need to train. Using the -chain rule (or just the back-propagation algorithm) we can find all -derivatives. Since we will use automatic differentiation in reverse -mode, we start with the derivatives of the cost function with respect -to the parameters of the output layer, namely -

    +

    Using the chain rule and summing over all \( k \) entries

    +

    We obtain

    $$ -\frac{\partial C}{\partial w_{i}^{(2)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}}\frac{\partial z^{(2)}}{\partial w_{i}^{(2)}}=\delta^{(2)}a_i^{(1)}, +\delta_j^l =\sum_k \frac{\partial {\cal C}}{\partial z_k^{l+1}}\frac{\partial z_k^{l+1}}{\partial z_j^{l}}=\sum_k \delta_k^{l+1}\frac{\partial z_k^{l+1}}{\partial z_j^{l}}, $$ -

    with

    +

    and recalling that

    $$ -\delta^{(2)}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}} +z_j^{l+1} = \sum_{i=1}^{M_{l}}w_{ij}^{l+1}a_i^{l}+b_j^{l+1}, $$ -

    and finally

    +

    with \( M_l \) being the number of nodes in layer \( l \), we obtain

    $$ -\frac{\partial C}{\partial b^{(2)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}}\frac{\partial z^{(2)}}{\partial b^{(2)}}=\delta^{(2)}. +\delta_j^l =\sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), $$ +

    This is our final equation.

    + +

    We are now ready to set up the algorithm for back propagation and learning the weights and biases.

    @@ -589,7 +503,7 @@ $$

  • 48
  • 49
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs040.html b/doc/pub/week42/html/._week42-bs040.html index 59ea6258b..b38eb44f2 100644 --- a/doc/pub/week42/html/._week42-bs040.html +++ b/doc/pub/week42/html/._week42-bs040.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,24 +457,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivatives of the hidden layer

    +

    Setting up the back propagation algorithm

    -

    Using the chain rule we have the following expressions for say one of the weight parameters (it is easy to generalize to the other weight parameters)

    -$$ -\frac{\partial C}{\partial w_{00}^{(1)}}=\frac{\partial C}{\partial a^{(2)}}\frac{\partial a^{(2)}}{\partial z^{(2)}} -\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}= \delta^{(2)}\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}, -$$ +

    The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.

    -

    which, noting that

    -$$ -z^{(2)} =w_0^{(2)}a_0^{(1)}+w_1^{(2)}a_1^{(1)}+b^{(2)}, -$$ +

    First, we set up the input data \( \boldsymbol{x} \) and the activations +\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and +the pertinent outputs \( \boldsymbol{a}^1 \). +

    -

    allows us to rewrite

    -$$ -\frac{\partial z^{(2)}}{\partial z_0^{(1)}}\frac{\partial z_0^{(1)}}{\partial w_{00}^{(1)}}=w_0^{(2)}\frac{\partial a_0^{(1)}}{\partial z_0^{(1)}}a_0^{(1)}. -$$ +

    Secondly, we perform then the feed forward till we reach the output +layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the +activation function and the pertinent outputs \( \boldsymbol{a}^l \) for +\( l=1,2,3,\dots,L \). +

    +

    Notation: The first hidden layer has \( l=1 \) as label and the final output layer has \( l=L \).

    @@ -584,7 +499,7 @@ $$

  • 49
  • 50
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs041.html b/doc/pub/week42/html/._week42-bs041.html index 86e2a9cc5..0ab64d8a6 100644 --- a/doc/pub/week42/html/._week42-bs041.html +++ b/doc/pub/week42/html/._week42-bs041.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,20 +457,16 @@ MathJax.Hub.Config({

     

     

     

    -

    Final expression

    -

    Defining

    +

    Setting up the back propagation algorithm, part 2

    + +

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

    $$ -\delta_0^{(1)}=w_0^{(2)}\frac{\partial a_0^{(1)}}{\partial z_0^{(1)}}\delta^{(2)}, +\delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. $$ -

    we have

    +

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    $$ -\frac{\partial C}{\partial w_{00}^{(1)}}=\delta_0^{(1)}a_0^{(1)}. -$$ - -

    Similarly, we obtain

    -$$ -\frac{\partial C}{\partial w_{01}^{(1)}}=\delta_0^{(1)}a_1^{(1)}. +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). $$ @@ -582,7 +495,7 @@ $$
  • 50
  • 51
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs042.html b/doc/pub/week42/html/._week42-bs042.html index 29cd089bb..bf659b445 100644 --- a/doc/pub/week42/html/._week42-bs042.html +++ b/doc/pub/week42/html/._week42-bs042.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,23 +457,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Completing the list

    +

    Setting up the Back propagation algorithm, part 3

    + +

    Finally, we update the weights and the biases using gradient descent +for each \( l=L-1,L-2,\dots,1 \) (the first hidden layer) and update the weights and biases +according to the rules +

    -

    Similarly, we find

    $$ -\frac{\partial C}{\partial w_{10}^{(1)}}=\delta_1^{(1)}a_0^{(1)}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ -

    and

    + $$ -\frac{\partial C}{\partial w_{11}^{(1)}}=\delta_1^{(1)}a_1^{(1)}, -$$ - -

    where we have defined

    -$$ -\delta_1^{(1)}=w_1^{(2)}\frac{\partial a_1^{(1)}}{\partial z_1^{(1)}}\delta^{(2)}. +b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, $$ +

    with \( \eta \) being the learning rate.

    @@ -583,7 +500,7 @@ $$

  • 51
  • 52
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs043.html b/doc/pub/week42/html/._week42-bs043.html index 76882440d..c2618d03d 100644 --- a/doc/pub/week42/html/._week42-bs043.html +++ b/doc/pub/week42/html/._week42-bs043.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,19 +457,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Final expressions for the biases of the hidden layer

    +

    Updating the gradients

    -

    For the sake of completeness, we list the derivatives of the biases, which are

    +

    With the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    $$ -\frac{\partial C}{\partial b_{0}^{(1)}}=\delta_0^{(1)}, +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), $$ -

    and

    +

    we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases according to the rules

    $$ -\frac{\partial C}{\partial b_{1}^{(1)}}=\delta_1^{(1)}. +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, +$$ + + +$$ +b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, $$ -

    As we will see below, these expressions can be generalized in a more compact form.

    @@ -579,7 +500,7 @@ $$

  • 52
  • 53
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs044.html b/doc/pub/week42/html/._week42-bs044.html index 8fa2ab2bb..9ba7f7680 100644 --- a/doc/pub/week42/html/._week42-bs044.html +++ b/doc/pub/week42/html/._week42-bs044.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,32 +457,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Gradient expressions

    +

    Activation functions

    -

    For this specific model, with just one output node and two hidden -nodes, the gradient descent equations take the following form for output layer +

    A property that characterizes a neural network, other than its +connectivity, is the choice of activation function(s). As described +in, the following restrictions are imposed on an activation function +for a FFNN to fulfill the universal approximation theorem

    -$$ -w_{i}^{(2)}\leftarrow w_{i}^{(2)}- \eta \delta^{(2)} a_{i}^{(1)}, -$$ - -

    and

    -$$ -b^{(2)} \leftarrow b^{(2)}-\eta \delta^{(2)}, -$$ - -

    and

    -$$ -w_{ij}^{(1)}\leftarrow w_{ij}^{(1)}- \eta \delta_{i}^{(1)} a_{j}^{(0)}, -$$ - -

    and

    -$$ -b_{i}^{(1)} \leftarrow b_{i}^{(1)}-\eta \delta_{i}^{(1)}, -$$ - -

    where \( \eta \) is the learning rate.

    +

    diff --git a/doc/pub/week42/html/._week42-bs045.html b/doc/pub/week42/html/._week42-bs045.html index a249b0a24..af21f45b1 100644 --- a/doc/pub/week42/html/._week42-bs045.html +++ b/doc/pub/week42/html/._week42-bs045.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,28 @@ MathJax.Hub.Config({

     

     

     

    +

    Activation functions, Logistic and Hyperbolic ones

    - -

    Exercise 2: Extended program

    - -

    We extend our simple code to a function which depends on two variable \( x_0 \) and \( x_1 \), that is

    -$$ -y=f(x_0,x_1)=x_0^2+3x_0x_1+x_1^2+5. -$$ - -

    We feed our network with \( n=100 \) entries \( x_0 \) and \( x_1 \). We have thus two features represented by these variable and an input matrix/design matrix \( \boldsymbol{X}\in \mathbf{R}^{n\times 2} \)

    -$$ -\boldsymbol{X}=\begin{bmatrix} x_{00} & x_{01} \\ x_{00} & x_{01} \\ x_{10} & x_{11} \\ x_{20} & x_{21} \\ \dots & \dots \\ \dots & \dots \\ x_{n-20} & x_{n-21} \\ x_{n-10} & x_{n-11} \end{bmatrix}. -$$ - -

    Write a code, based on the previous code examples, which takes as input these data and fit the above function. -You can extend your code to include automatic differentiation. +

    The second requirement excludes all linear functions. Furthermore, in +a MLP with only linear activation functions, each layer simply +performs a linear transformation of its inputs.

    -

    With these examples, we are now ready to embark upon the writing of more a general code for neural networks.

    +

    Regardless of the number of layers, the output of the NN will be +nothing but a linear function of the inputs. Thus we need to introduce +some kind of non-linearity to the NN to be able to fit non-linear +functions Typical examples are the logistic Sigmoid +

    + +$$ + \sigma(x) = \frac{1}{1 + e^{-x}}, +$$ + +

    and the hyperbolic tangent function

    +$$ + \sigma(x) = \tanh(x) +$$ -

    @@ -587,7 +505,7 @@ You can extend your code to include automatic differentiation.

  • 54
  • 55
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs046.html b/doc/pub/week42/html/._week42-bs046.html index d08e13ec7..a4a93ab63 100644 --- a/doc/pub/week42/html/._week42-bs046.html +++ b/doc/pub/week42/html/._week42-bs046.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,25 +457,108 @@ MathJax.Hub.Config({

     

     

     

    -

    Setting up the equations for a neural network

    +

    Relevance

    -

    The questions we want to ask are how do changes in the biases and the -weights in our network change the cost function and how can we use the -final output to modify the weights and biases? +

    The sigmoid function are more biologically plausible because the +output of inactive neurons are zero. Such activation function are +called one-sided. However, it has been shown that the hyperbolic +tangent performs better than the sigmoid for training MLPs. has +become the most popular for deep neural networks

    -

    To derive these equations let us start with a plain regression problem -and define our cost function as -

    -$$ -{\cal C}(\boldsymbol{\Theta}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - \tilde{y}_i\right)^2, -$$ + +
    +
    +
    +
    +
    +
    """The sigmoid function (or the logistic curve) is a 
    +function that takes any real number, z, and outputs a number (0,1).
    +It is useful in neural networks for assigning weights on a relative scale.
    +The value z is the weighted sum of parameters involved in the learning algorithm."""
    +
    +import numpy
    +import matplotlib.pyplot as plt
    +import math as mt
    +
    +z = numpy.arange(-5, 5, .1)
    +sigma_fn = numpy.vectorize(lambda z: 1/(1+numpy.exp(-z)))
    +sigma = sigma_fn(z)
    +
    +fig = plt.figure()
    +ax = fig.add_subplot(111)
    +ax.plot(z, sigma)
    +ax.set_ylim([-0.1, 1.1])
    +ax.set_xlim([-5,5])
    +ax.grid(True)
    +ax.set_xlabel('z')
    +ax.set_title('sigmoid function')
    +
    +plt.show()
    +
    +"""Step Function"""
    +z = numpy.arange(-5, 5, .02)
    +step_fn = numpy.vectorize(lambda z: 1.0 if z >= 0.0 else 0.0)
    +step = step_fn(z)
    +
    +fig = plt.figure()
    +ax = fig.add_subplot(111)
    +ax.plot(z, step)
    +ax.set_ylim([-0.5, 1.5])
    +ax.set_xlim([-5,5])
    +ax.grid(True)
    +ax.set_xlabel('z')
    +ax.set_title('step function')
    +
    +plt.show()
    +
    +"""Sine Function"""
    +z = numpy.arange(-2*mt.pi, 2*mt.pi, 0.1)
    +t = numpy.sin(z)
    +
    +fig = plt.figure()
    +ax = fig.add_subplot(111)
    +ax.plot(z, t)
    +ax.set_ylim([-1.0, 1.0])
    +ax.set_xlim([-2*mt.pi,2*mt.pi])
    +ax.grid(True)
    +ax.set_xlabel('z')
    +ax.set_title('sine function')
    +
    +plt.show()
    +
    +"""Plots a graph of the squashing function used by a rectified linear
    +unit"""
    +z = numpy.arange(-2, 2, .1)
    +zero = numpy.zeros(len(z))
    +y = numpy.max([zero, z], axis=0)
    +
    +fig = plt.figure()
    +ax = fig.add_subplot(111)
    +ax.plot(z, y)
    +ax.set_ylim([-2.0, 2.0])
    +ax.set_xlim([-2.0, 2.0])
    +ax.grid(True)
    +ax.set_xlabel('z')
    +ax.set_title('Rectified linear unit')
    +
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    where the $y_i$s are our \( n \) targets (the values we want to -reproduce), while the outputs of the network after having propagated -all inputs \( \boldsymbol{x} \) are given by \( \boldsymbol{\tilde{y}}_i \). -

    @@ -585,7 +585,7 @@ all inputs \( \boldsymbol{x} \) are given by \( \boldsymbol{\tilde{y}}_i \).

  • 55
  • 56
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs047.html b/doc/pub/week42/html/._week42-bs047.html index 16226abbb..53d66b288 100644 --- a/doc/pub/week42/html/._week42-bs047.html +++ b/doc/pub/week42/html/._week42-bs047.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,14 +457,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Layout of a neural network with three hidden layers

    +

    Fine-tuning neural network hyperparameters

    -

    -
    -

    -
    -

    +

    The flexibility of neural networks is also one of their main +drawbacks: there are many hyperparameters to tweak. Not only can you +use any imaginable network topology (how neurons/nodes are +interconnected), but even in a simple FFNN you can change the number +of layers, the number of neurons per layer, the type of activation +function to use in each layer, the weight initialization logic, the +stochastic gradient optmized and much more. How do you know what +combination of hyperparameters is the best for your task? +

    + +

    However,since there are many hyperparameters to tune, and since +training a neural network on a large dataset takes a lot of time, you +will only be able to explore a tiny part of the hyperparameter space. +

    + +

    diff --git a/doc/pub/week42/html/._week42-bs048.html b/doc/pub/week42/html/._week42-bs048.html index ff7085cc4..42bfd6c60 100644 --- a/doc/pub/week42/html/._week42-bs048.html +++ b/doc/pub/week42/html/._week42-bs048.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,31 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Definitions

    +

    Hidden layers

    -

    With our definition of the targets \( \boldsymbol{y} \), the outputs of the -network \( \boldsymbol{\tilde{y}} \) and the inputs \( \boldsymbol{x} \) we -define now the activation \( z_j^l \) of node/neuron/unit \( j \) of the -\( l \)-th layer as a function of the bias, the weights which add up from -the previous layer \( l-1 \) and the forward passes/outputs -\( \hat{a}^{l-1} \) from the previous layer as +

    For many problems you can start with just one or two hidden layers and +it will work just fine. For the MNIST data set you ca easily get a +high accuracy using just one hidden layer with a few hundred neurons. +You can reach for this data set above 98% accuracy using two hidden +layers with the same total amount of neurons, in roughly the same +amount of training time.

    -$$ -z_j^l = \sum_{i=1}^{M_{l-1}}w_{ij}^la_i^{l-1}+b_j^l, -$$ - -

    where \( b_k^l \) are the biases from layer \( l \). Here \( M_{l-1} \) -represents the total number of nodes/neurons/units of layer \( l-1 \). The -figure in the whiteboard notes illustrates this equation. We can rewrite this in a more -compact form as the matrix-vector products we discussed earlier, +

    For more complex problems, you can gradually ramp up the number of +hidden layers, until you start overfitting the training set. Very +complex tasks, such as large image classification or speech +recognition, typically require networks with dozens of layers and they +need a huge amount of training data. However, you will rarely have to +train such networks from scratch: it is much more common to reuse +parts of a pretrained state-of-the-art network that performs a similar +task.

    -$$ -\hat{z}^l = \left(\hat{W}^l\right)^T\hat{a}^{l-1}+\hat{b}^l. -$$ - -

    diff --git a/doc/pub/week42/html/._week42-bs049.html b/doc/pub/week42/html/._week42-bs049.html index 25b72d223..744a0b520 100644 --- a/doc/pub/week42/html/._week42-bs049.html +++ b/doc/pub/week42/html/._week42-bs049.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,20 +456,22 @@ MathJax.Hub.Config({

     

     

     

    - -

    Inputs to the activation function

    + +

    Vanishing gradients

    -

    With the activation values \( \boldsymbol{z}^l \) we can in turn define the -output of layer \( l \) as \( \boldsymbol{a}^l = f(\boldsymbol{z}^l) \) where \( f \) is our -activation function. In the examples here we will use the sigmoid -function discussed in our logistic regression lectures. We will also use the same activation function \( f \) for all layers -and their nodes. It means we have +

    The Back propagation algorithm we derived above works by going from +the output layer to the input layer, propagating the error gradient on +the way. Once the algorithm has computed the gradient of the cost +function with regards to each parameter in the network, it uses these +gradients to update each parameter with a Gradient Descent (GD) step.

    -$$ -a_j^l = \sigma(z_j^l) = \frac{1}{1+\exp{-(z_j^l)}}. -$$ - +

    Unfortunately for us, the gradients often get smaller and smaller as +the algorithm progresses down to the first hidden layers. As a result, +the GD update leaves the lower layer connection weights virtually +unchanged, and training never converges to a good solution. This is +known in the literature as the vanishing gradients problem. +

    @@ -579,7 +498,7 @@ $$

  • 58
  • 59
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs050.html b/doc/pub/week42/html/._week42-bs050.html index 76eb8e442..6007bf9a2 100644 --- a/doc/pub/week42/html/._week42-bs050.html +++ b/doc/pub/week42/html/._week42-bs050.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,23 +457,16 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivatives and the chain rule

    - -

    From the definition of the activation \( z_j^l \) we have

    -$$ -\frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, -$$ - -

    and

    -$$ -\frac{\partial z_j^l}{\partial a_i^{l-1}} = w_{ji}^l. -$$ - -

    With our definition of the activation function we have that (note that this function depends only on \( z_j^l \))

    -$$ -\frac{\partial a_j^l}{\partial z_j^{l}} = a_j^l(1-a_j^l)=\sigma(z_j^l)(1-\sigma(z_j^l)). -$$ +

    Exploding gradients

    +

    In other cases, the opposite can happen, namely the the gradients can +grow bigger and bigger. The result is that many of the layers get +large updates of the weights the algorithm diverges. This is the +exploding gradients problem, which is mostly encountered in +recurrent neural networks. More generally, deep neural networks suffer +from unstable gradients, different layers may learn at widely +different speeds +

    @@ -583,7 +493,7 @@ $$

  • 59
  • 60
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs051.html b/doc/pub/week42/html/._week42-bs051.html index e464edee0..931762fec 100644 --- a/doc/pub/week42/html/._week42-bs051.html +++ b/doc/pub/week42/html/._week42-bs051.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,27 +456,23 @@ MathJax.Hub.Config({

     

     

     

    - -

    Derivative of the cost function

    + +

    Is the Logistic activation function (Sigmoid) our choice?

    -

    With these definitions we can now compute the derivative of the cost function in terms of the weights.

    - -

    Let us specialize to the output layer \( l=L \). Our cost function is

    -$$ -{\cal C}(\boldsymbol{\Theta}^L) = \frac{1}{2}\sum_{i=1}^n\left(y_i - \tilde{y}_i\right)^2=\frac{1}{2}\sum_{i=1}^n\left(a_i^L - y_i\right)^2, -$$ - -

    The derivative of this function with respect to the weights is

    - -$$ -\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{L}}, -$$ - -

    The last partial derivative can easily be computed and reads (by applying the chain rule)

    -$$ -\frac{\partial a_j^L}{\partial w_{jk}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{jk}^{L}}=a_j^L(1-a_j^L)a_k^{L-1}. -$$ +

    Although this unfortunate behavior has been empirically observed for +quite a while (it was one of the reasons why deep neural networks were +mostly abandoned for a long time), it is only around 2010 that +significant progress was made in understanding it. +

    +

    A paper titled Understanding the Difficulty of Training Deep +Feedforward Neural Networks by Xavier Glorot and Yoshua Bengio found that +the problems with the popular logistic +sigmoid activation function and the weight initialization technique +that was most popular at the time, namely random initialization using +a normal distribution with a mean of 0 and a standard deviation of +1. +

    @@ -586,7 +499,7 @@ $$

  • 60
  • 61
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs052.html b/doc/pub/week42/html/._week42-bs052.html index 0979c23fb..b5c954d2b 100644 --- a/doc/pub/week42/html/._week42-bs052.html +++ b/doc/pub/week42/html/._week42-bs052.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,23 +457,17 @@ MathJax.Hub.Config({

     

     

     

    -

    The back propagation equations for a neural network

    - -

    We have thus

    -$$ -\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_k^{L-1}, -$$ - -

    Defining

    -$$ -\delta_j^L = a_j^L(1-a_j^L)\left(a_j^L - y_j\right) = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}, -$$ - -

    and using the Hadamard product of two vectors we can write this as

    -$$ -\boldsymbol{\delta}^L = \sigma'(\hat{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. -$$ +

    Logistic function as the root of problems

    +

    They showed that with this activation function and this +initialization scheme, the variance of the outputs of each layer is +much greater than the variance of its inputs. Going forward in the +network, the variance keeps increasing after each layer until the +activation function saturates at the top layers. This is actually made +worse by the fact that the logistic function has a mean of 0.5, not 0 +(the hyperbolic tangent function has a mean of 0 and behaves slightly +better than the logistic function in deep networks). +

    @@ -583,7 +494,7 @@ $$

  • 61
  • 62
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs053.html b/doc/pub/week42/html/._week42-bs053.html index b0887ae46..33aea1f27 100644 --- a/doc/pub/week42/html/._week42-bs053.html +++ b/doc/pub/week42/html/._week42-bs053.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,15 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Analyzing the last results

    +

    The derivative of the Logistic funtion

    -

    This is an important expression. The second term on the right handside -measures how fast the cost function is changing as a function of the $j$th -output activation. If, for example, the cost function doesn't depend -much on a particular output node \( j \), then \( \delta_j^L \) will be small, -which is what we would expect. The first term on the right, measures -how fast the activation function \( f \) is changing at a given activation -value \( z_j^L \). +

    Looking at the logistic activation function, when inputs become large +(negative or positive), the function saturates at 0 or 1, with a +derivative extremely close to 0. Thus when backpropagation kicks in, +it has virtually no gradient to propagate back through the network, +and what little gradient exists keeps getting diluted as +backpropagation progresses down through the top layers, so there is +really nothing left for the lower layers. +

    + +

    In their paper, Glorot and Bengio propose a way to significantly +alleviate this problem. We need the signal to flow properly in both +directions: in the forward direction when making predictions, and in +the reverse direction when backpropagating gradients. We don’t want +the signal to die out, nor do we want it to explode and saturate. For +the signal to flow properly, the authors argue that we need the +variance of the outputs of each layer to be equal to the variance of +its inputs, and we also need the gradients to have equal variance +before and after flowing through a layer in the reverse direction.

    @@ -576,7 +504,7 @@ value \( z_j^L \).

  • 62
  • 63
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs054.html b/doc/pub/week42/html/._week42-bs054.html index bb8db8b5b..7f4ad52c1 100644 --- a/doc/pub/week42/html/._week42-bs054.html +++ b/doc/pub/week42/html/._week42-bs054.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,19 @@ MathJax.Hub.Config({

     

     

     

    -

    More considerations

    +

    Insights from the paper by Glorot and Bengio

    -

    Notice that everything in the above equations is easily computed. In -particular, we compute \( z_j^L \) while computing the behaviour of the -network, and it is only a small additional overhead to compute -\( \sigma'(z^L_j) \). The exact form of the derivative with respect to the -output depends on the form of the cost function. -However, provided the cost function is known there should be little -trouble in calculating +

    One of the insights in the 2010 paper by Glorot and Bengio was that +the vanishing/exploding gradients problems were in part due to a poor +choice of activation function. Until then most people had assumed that +if Nature had chosen to use roughly sigmoid activation functions in +biological neurons, they must be an excellent choice. But it turns out +that other activation functions behave much better in deep neural +networks, in particular the ReLU activation function, mostly because +it does not saturate for positive values (and also because it is quite +fast to compute).

    -$$ -\frac{\partial {\cal C}}{\partial (a_j^L)} -$$ - -

    With the definition of \( \delta_j^L \) we have a more compact definition of the derivative of the cost function in terms of the weights, namely

    -$$ -\frac{\partial{\cal C}}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. -$$ - -

    diff --git a/doc/pub/week42/html/._week42-bs055.html b/doc/pub/week42/html/._week42-bs055.html index 4fc7f3411..2f7f2bdcb 100644 --- a/doc/pub/week42/html/._week42-bs055.html +++ b/doc/pub/week42/html/._week42-bs055.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,20 +457,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivatives in terms of \( z_j^L \)

    +

    The RELU function family

    -

    It is also easy to see that our previous equation can be written as

    +

    The ReLU activation function suffers from a problem known as the dying +ReLUs: during training, some neurons effectively die, meaning they +stop outputting anything other than 0. +

    -$$ -\delta_j^L =\frac{\partial {\cal C}}{\partial z_j^L}= \frac{\partial {\cal C}}{\partial a_j^L}\frac{\partial a_j^L}{\partial z_j^L}, -$$ - -

    which can also be interpreted as the partial derivative of the cost function with respect to the biases \( b_j^L \), namely

    -$$ -\delta_j^L = \frac{\partial {\cal C}}{\partial b_j^L}\frac{\partial b_j^L}{\partial z_j^L}=\frac{\partial {\cal C}}{\partial b_j^L}, -$$ - -

    That is, the error \( \delta_j^L \) is exactly equal to the rate of change of the cost function as a function of the bias.

    +

    In some cases, you may find that half of your network’s neurons are +dead, especially if you used a large learning rate. During training, +if a neuron’s weights get updated such that the weighted sum of the +neuron’s inputs is negative, it will start outputting 0. When this +happen, the neuron is unlikely to come back to life since the gradient +of the ReLU function is 0 when its input is negative. +

    @@ -580,7 +497,7 @@ $$

  • 64
  • 65
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs056.html b/doc/pub/week42/html/._week42-bs056.html index db24dcbd0..a485f496a 100644 --- a/doc/pub/week42/html/._week42-bs056.html +++ b/doc/pub/week42/html/._week42-bs056.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,32 +457,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Bringing it together

    +

    ELU function

    -

    We have now three equations that are essential for the computations of the derivatives of the cost function at the output layer. These equations are needed to start the algorithm and they are

    +

    To solve this problem, nowadays practitioners use a variant of the +ReLU function, such as the leaky ReLU discussed above or the so-called +exponential linear unit (ELU) function +

    $$ -\begin{equation} -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}, -\tag{1} -\end{equation} -$$ - -

    and

    -$$ -\begin{equation} -\delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}, -\tag{2} -\end{equation} -$$ - -

    and

    - -$$ -\begin{equation} -\delta_j^L = \frac{\partial {\cal C}}{\partial b_j^L}, -\tag{3} -\end{equation} +ELU(z) = \left\{\begin{array}{cc} \alpha\left( \exp{(z)}-1\right) & z < 0,\\ z & z \ge 0.\end{array}\right. $$ @@ -594,7 +494,7 @@ $$
  • 65
  • 66
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs057.html b/doc/pub/week42/html/._week42-bs057.html index bb8aec8a2..d382d4721 100644 --- a/doc/pub/week42/html/._week42-bs057.html +++ b/doc/pub/week42/html/._week42-bs057.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,14 +457,21 @@ MathJax.Hub.Config({

     

     

     

    -

    Final back propagating equation

    +

    Which activation function should we use?

    -

    We have that (replacing \( L \) with a general layer \( l \))

    -$$ -\delta_j^l =\frac{\partial {\cal C}}{\partial z_j^l}. -$$ +

    In general it seems that the ELU activation function is better than +the leaky ReLU function (and its variants), which is better than +ReLU. ReLU performs better than \( \tanh \) which in turn performs better +than the logistic function. +

    -

    We want to express this in terms of the equations for layer \( l+1 \).

    +

    If runtime performance is an issue, then you may opt for the leaky +ReLU function over the ELU function If you don’t want to tweak yet +another hyperparameter, you may just use the default \( \alpha \) of +\( 0.01 \) for the leaky ReLU, and \( 1 \) for ELU. If you have spare time and +computing power, you can use cross-validation or bootstrap to evaluate +other activation functions. +

    @@ -574,7 +498,7 @@ $$

  • 66
  • 67
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs058.html b/doc/pub/week42/html/._week42-bs058.html index c2d3f8bd5..32bfb5c9e 100644 --- a/doc/pub/week42/html/._week42-bs058.html +++ b/doc/pub/week42/html/._week42-bs058.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Using the chain rule and summing over all \( k \) entries

    +

    More on activation functions, output layers

    -

    We obtain

    -$$ -\delta_j^l =\sum_k \frac{\partial {\cal C}}{\partial z_k^{l+1}}\frac{\partial z_k^{l+1}}{\partial z_j^{l}}=\sum_k \delta_k^{l+1}\frac{\partial z_k^{l+1}}{\partial z_j^{l}}, -$$ +

    In most cases you can use the ReLU activation function in the hidden +layers (or one of its variants). +

    -

    and recalling that

    -$$ -z_j^{l+1} = \sum_{i=1}^{M_{l}}w_{ij}^{l+1}a_i^{l}+b_j^{l+1}, -$$ +

    It is a bit faster to compute than other activation functions, and the +gradient descent optimization does in general not get stuck. +

    -

    with \( M_l \) being the number of nodes in layer \( l \), we obtain

    -$$ -\delta_j^l =\sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), -$$ - -

    This is our final equation.

    - -

    We are now ready to set up the algorithm for back propagation and learning the weights and biases.

    +For the output layer: +
      +
    • For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).
    • +
    • For regression tasks, you can simply use no activation function at all.
    • +

    diff --git a/doc/pub/week42/html/._week42-bs059.html b/doc/pub/week42/html/._week42-bs059.html index 232cee20f..d21745a7a 100644 --- a/doc/pub/week42/html/._week42-bs059.html +++ b/doc/pub/week42/html/._week42-bs059.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,23 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Setting up the back propagation algorithm

    +

    Batch Normalization

    -

    The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.

    - -

    First, we set up the input data \( \hat{x} \) and the activations -\( \hat{z}_1 \) of the input layer and compute the activation function and -the pertinent outputs \( \hat{a}^1 \). +

    Batch Normalization aims to address the vanishing/exploding gradients +problems, and more generally the problem that the distribution of each +layer’s inputs changes during training, as the parameters of the +previous layers change.

    -

    Secondly, we perform then the feed forward till we reach the output -layer and compute all \( \hat{z}_l \) of the input layer and compute the -activation function and the pertinent outputs \( \hat{a}^l \) for -\( l=1,2,3,\dots,L \). +

    The technique consists of adding an operation in the model just before +the activation function of each layer, simply zero-centering and +normalizing the inputs, then scaling and shifting the result using two +new parameters per layer (one for scaling, the other for shifting). In +other words, this operation lets the model learn the optimal scale and +mean of the inputs for each layer. In order to zero-center and +normalize the inputs, the algorithm needs to estimate the inputs’ mean +and standard deviation. It does so by evaluating the mean and standard +deviation of the inputs over the current mini-batch, from this the +name batch normalization.

    -

    Notation: The first hidden layer has \( l=1 \) as label and the final output layer has \( l=L \).

    -

      @@ -582,7 +502,7 @@ activation function and the pertinent outputs \( \hat{a}^l \) for
    • 68
    • 69
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs060.html b/doc/pub/week42/html/._week42-bs060.html index 309047120..a5815a79e 100644 --- a/doc/pub/week42/html/._week42-bs060.html +++ b/doc/pub/week42/html/._week42-bs060.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,18 +457,19 @@ MathJax.Hub.Config({

     

     

     

    -

    Setting up the back propagation algorithm, part 2

    +

    Dropout

    -

    Thereafter we compute the ouput error \( \hat{\delta}^L \) by computing all

    -$$ -\delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. -$$ - -

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    -$$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). -$$ +

    It is a fairly simple algorithm: at every training step, every neuron +(including the input neurons but excluding the output neurons) has a +probability \( p \) of being temporarily dropped out, meaning it will be +entirely ignored during this training step, but it may be active +during the next step. +

    +

    The hyperparameter \( p \) is called the dropout rate, and it is typically +set to 50%. After training, the neurons are not dropped anymore. It +is viewed as one of the most popular regularization techniques. +

    @@ -578,7 +496,7 @@ $$

  • 69
  • 70
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs061.html b/doc/pub/week42/html/._week42-bs061.html index 971569d0c..260bc5182 100644 --- a/doc/pub/week42/html/._week42-bs061.html +++ b/doc/pub/week42/html/._week42-bs061.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,23 +457,19 @@ MathJax.Hub.Config({

     

     

     

    -

    Setting up the Back propagation algorithm, part 3

    +

    Gradient Clipping

    -

    Finally, we update the weights and the biases using gradient descent -for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases -according to the rules +

    A popular technique to lessen the exploding gradients problem is to +simply clip the gradients during backpropagation so that they never +exceed some threshold (this is mostly useful for recurrent neural +networks).

    -$$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, -$$ +

    This technique is called Gradient Clipping.

    - -$$ -b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, -$$ - -

    with \( \eta \) being the learning rate.

    +

    In general however, Batch +Normalization is preferred. +

    @@ -583,7 +496,7 @@ $$

  • 70
  • 71
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs062.html b/doc/pub/week42/html/._week42-bs062.html index ba5368758..352febb6e 100644 --- a/doc/pub/week42/html/._week42-bs062.html +++ b/doc/pub/week42/html/._week42-bs062.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,25 +456,25 @@ MathJax.Hub.Config({

     

     

     

    - -

    Updating the gradients

    - -

    With the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    -$$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l), -$$ - -

    we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases according to the rules

    -$$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, -$$ - - -$$ -b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, -$$ + +

    A top-down perspective on Neural networks

    +

    The first thing we would like to do is divide the data into two or +three parts. A training set, a validation or dev (development) set, +and a test set. The test set is the data on which we want to make +predictions. The dev set is a subset of the training data we use to +check how well we are doing out-of-sample, after training the model on +the training dataset. We use the validation error as a proxy for the +test error in order to make tweaks to our model. It is crucial that we +do not use any of the test data to train the algorithm. This is a +cardinal sin in ML. Then: +

    +
      +
    1. Estimate optimal error rate
    2. +
    3. Minimize underfitting (bias) on training data set.
    4. +
    5. Make sure you are not overfitting.
    6. +

    diff --git a/doc/pub/week42/html/._week42-bs063.html b/doc/pub/week42/html/._week42-bs063.html index 2321b8a5d..076540ce0 100644 --- a/doc/pub/week42/html/._week42-bs063.html +++ b/doc/pub/week42/html/._week42-bs063.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,20 +457,29 @@ MathJax.Hub.Config({

     

     

     

    -

    Activation functions

    +

    More top-down perspectives

    -

    A property that characterizes a neural network, other than its -connectivity, is the choice of activation function(s). As described -in, the following restrictions are imposed on an activation function -for a FFNN to fulfill the universal approximation theorem +

    If the validation and test sets are drawn from the same distributions, +then a good performance on the validation set should lead to similarly +good performance on the test set. +

    + +

    However, sometimes +the training data and test data differ in subtle ways because, for +example, they are collected using slightly different methods, or +because it is cheaper to collect data in one way versus another. In +this case, there can be a mismatch between the training and test +data. This can lead to the neural network overfitting these small +differences between the test and training sets, and a poor performance +on the test set despite having a good performance on the validation +set. To rectify this, Andrew Ng suggests making two validation or dev +sets, one constructed from the training data and one constructed from +the test data. The difference between the performance of the algorithm +on these two validation sets quantifies the train-test mismatch. This +can serve as another important diagnostic when using DNNs for +supervised learning.

    -
      -
    • Non-constant
    • -
    • Bounded
    • -
    • Monotonically-increasing
    • -
    • Continuous
    • -

      @@ -579,7 +505,7 @@ for a FFNN to fulfill the universal approximation theorem
    • 72
    • 73
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs064.html b/doc/pub/week42/html/._week42-bs064.html index 8761996e1..d8df2b23a 100644 --- a/doc/pub/week42/html/._week42-bs064.html +++ b/doc/pub/week42/html/._week42-bs064.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,17 @@ MathJax.Hub.Config({

     

     

     

    -

    Activation functions, Logistic and Hyperbolic ones

    +

    Limitations of supervised learning with deep networks

    -

    The second requirement excludes all linear functions. Furthermore, in -a MLP with only linear activation functions, each layer simply -performs a linear transformation of its inputs. +

    Like all statistical methods, supervised learning using neural +networks has important limitations. This is especially important when +one seeks to apply these methods, especially to physics problems. Like +all tools, DNNs are not a universal solution. Often, the same or +better performance on a task can be achieved by using a few +hand-engineered features (or even a collection of random +features).

    -

    Regardless of the number of layers, the output of the NN will be -nothing but a linear function of the inputs. Thus we need to introduce -some kind of non-linearity to the NN to be able to fit non-linear -functions Typical examples are the logistic Sigmoid -

    - -$$ - f(x) = \frac{1}{1 + e^{-x}}, -$$ - -

    and the hyperbolic tangent function

    -$$ - f(x) = \tanh(x) -$$ - -

    diff --git a/doc/pub/week42/html/._week42-bs065.html b/doc/pub/week42/html/._week42-bs065.html index b355e4c7f..4c3c80ca4 100644 --- a/doc/pub/week42/html/._week42-bs065.html +++ b/doc/pub/week42/html/._week42-bs065.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,109 +457,14 @@ MathJax.Hub.Config({

     

     

     

    -

    Relevance

    - -

    The sigmoid function are more biologically plausible because the -output of inactive neurons are zero. Such activation function are -called one-sided. However, it has been shown that the hyperbolic -tangent performs better than the sigmoid for training MLPs. has -become the most popular for deep neural networks -

    - - - -
    -
    -
    -
    -
    -
    """The sigmoid function (or the logistic curve) is a 
    -function that takes any real number, z, and outputs a number (0,1).
    -It is useful in neural networks for assigning weights on a relative scale.
    -The value z is the weighted sum of parameters involved in the learning algorithm."""
    -
    -import numpy
    -import matplotlib.pyplot as plt
    -import math as mt
    -
    -z = numpy.arange(-5, 5, .1)
    -sigma_fn = numpy.vectorize(lambda z: 1/(1+numpy.exp(-z)))
    -sigma = sigma_fn(z)
    -
    -fig = plt.figure()
    -ax = fig.add_subplot(111)
    -ax.plot(z, sigma)
    -ax.set_ylim([-0.1, 1.1])
    -ax.set_xlim([-5,5])
    -ax.grid(True)
    -ax.set_xlabel('z')
    -ax.set_title('sigmoid function')
    -
    -plt.show()
    -
    -"""Step Function"""
    -z = numpy.arange(-5, 5, .02)
    -step_fn = numpy.vectorize(lambda z: 1.0 if z >= 0.0 else 0.0)
    -step = step_fn(z)
    -
    -fig = plt.figure()
    -ax = fig.add_subplot(111)
    -ax.plot(z, step)
    -ax.set_ylim([-0.5, 1.5])
    -ax.set_xlim([-5,5])
    -ax.grid(True)
    -ax.set_xlabel('z')
    -ax.set_title('step function')
    -
    -plt.show()
    -
    -"""Sine Function"""
    -z = numpy.arange(-2*mt.pi, 2*mt.pi, 0.1)
    -t = numpy.sin(z)
    -
    -fig = plt.figure()
    -ax = fig.add_subplot(111)
    -ax.plot(z, t)
    -ax.set_ylim([-1.0, 1.0])
    -ax.set_xlim([-2*mt.pi,2*mt.pi])
    -ax.grid(True)
    -ax.set_xlabel('z')
    -ax.set_title('sine function')
    -
    -plt.show()
    -
    -"""Plots a graph of the squashing function used by a rectified linear
    -unit"""
    -z = numpy.arange(-2, 2, .1)
    -zero = numpy.zeros(len(z))
    -y = numpy.max([zero, z], axis=0)
    -
    -fig = plt.figure()
    -ax = fig.add_subplot(111)
    -ax.plot(z, y)
    -ax.set_ylim([-2.0, 2.0])
    -ax.set_xlim([-2.0, 2.0])
    -ax.grid(True)
    -ax.set_xlabel('z')
    -ax.set_title('Rectified linear unit')
    -
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    Limitations of NNs

    +

    Here we list some of the important limitations of supervised neural network based models.

    +
      +
    • Need labeled data. All supervised learning methods, DNNs for supervised learning require labeled data. Often, labeled data is harder to acquire than unlabeled data (e.g. one must pay for human experts to label images).
    • +
    • Supervised neural networks are extremely data intensive. DNNs are data hungry. They perform best when data is plentiful. This is doubly so for supervised methods where the data must also be labeled. The utility of DNNs is extremely limited if data is hard to acquire or the datasets are small (hundreds to a few thousand samples). In this case, the performance of other methods that utilize hand-engineered features can exceed that of DNNs.
    • +

    diff --git a/doc/pub/week42/html/._week42-bs066.html b/doc/pub/week42/html/._week42-bs066.html index c4e576d48..a3bba4859 100644 --- a/doc/pub/week42/html/._week42-bs066.html +++ b/doc/pub/week42/html/._week42-bs066.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,10 @@ MathJax.Hub.Config({

     

     

     

    -

    Fine-tuning neural network hyperparameters

    - -

    The flexibility of neural networks is also one of their main -drawbacks: there are many hyperparameters to tweak. Not only can you -use any imaginable network topology (how neurons/nodes are -interconnected), but even in a simple FFNN you can change the number -of layers, the number of neurons per layer, the type of activation -function to use in each layer, the weight initialization logic, the -stochastic gradient optmized and much more. How do you know what -combination of hyperparameters is the best for your task? -

    +

    Homogeneous data

      -
    • You can use grid search with cross-validation to find the right hyperparameters.
    • -
    -

    However,since there are many hyperparameters to tune, and since -training a neural network on a large dataset takes a lot of time, you -will only be able to explore a tiny part of the hyperparameter space. -

    - -
      -
    • You can use randomized search.
    • -
    • Or use tools like Oscar, which implements more complex algorithms to help you find a good set of hyperparameters quickly.
    • +
    • Homogeneous data. Almost all DNNs deal with homogeneous data of one type. It is very hard to design architectures that mix and match data types (i.e. some continuous variables, some discrete variables, some time series). In applications beyond images, video, and language, this is often what is required. In contrast, ensemble models like random forests or gradient-boosted trees have no difficulty handling mixed data types.

    @@ -589,7 +487,7 @@ will only be able to explore a tiny part of the hyperparameter space.

  • 75
  • 76
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs067.html b/doc/pub/week42/html/._week42-bs067.html index 08586c529..866bc68ec 100644 --- a/doc/pub/week42/html/._week42-bs067.html +++ b/doc/pub/week42/html/._week42-bs067.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,25 +457,12 @@ MathJax.Hub.Config({

     

     

     

    -

    Hidden layers

    +

    More limitations

    -

    For many problems you can start with just one or two hidden layers and -it will work just fine. For the MNIST data set you ca easily get a -high accuracy using just one hidden layer with a few hundred neurons. -You can reach for this data set above 98% accuracy using two hidden -layers with the same total amount of neurons, in roughly the same -amount of training time. -

    - -

    For more complex problems, you can gradually ramp up the number of -hidden layers, until you start overfitting the training set. Very -complex tasks, such as large image classification or speech -recognition, typically require networks with dozens of layers and they -need a huge amount of training data. However, you will rarely have to -train such networks from scratch: it is much more common to reuse -parts of a pretrained state-of-the-art network that performs a similar -task. -

    +
      +
    • Many problems are not about prediction. In natural science we are often interested in learning something about the underlying distribution that generates the data. In this case, it is often difficult to cast these ideas in a supervised learning setting. While the problems are related, it is possible to make good predictions with a wrong model. The model might or might not be useful for understanding the underlying science.
    • +
    +

    Some of these remarks are particular to DNNs, others are shared by all supervised learning methods. This motivates the use of unsupervised methods which in part circumvent these problems.

    @@ -585,7 +489,7 @@ task.

  • 76
  • 77
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs068.html b/doc/pub/week42/html/._week42-bs068.html index 01648a0f8..fd594f43f 100644 --- a/doc/pub/week42/html/._week42-bs068.html +++ b/doc/pub/week42/html/._week42-bs068.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,21 +456,74 @@ MathJax.Hub.Config({

     

     

     

    - -

    Vanishing gradients

    + +

    Setting up the back-propagation algorithm

    -

    The Back propagation algorithm we derived above works by going from -the output layer to the input layer, propagating the error gradient on -the way. Once the algorithm has computed the gradient of the cost -function with regards to each parameter in the network, it uses these -gradients to update each parameter with a Gradient Descent (GD) step. +

    Let us write this out in the form of an algorithm.

    + +
    +
    + +

    First, we set up the input data \( \boldsymbol{x} \) and the activations +\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and +the pertinent outputs \( \boldsymbol{a}^1 \).

    +
    +
    -

    Unfortunately for us, the gradients often get smaller and smaller as -the algorithm progresses down to the first hidden layers. As a result, -the GD update leaves the lower layer connection weights virtually -unchanged, and training never converges to a good solution. This is -known in the literature as the vanishing gradients problem. + +

    +
    + +

    Secondly, we perform then the feed forward till we reach the output +layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the +activation function and the pertinent outputs \( \boldsymbol{a}^l \) for +\( l=2,3,\dots,L \). +

    +
    +
    + + +
    +
    + +

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

    +$$ +\delta_j^L = f'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. +$$ +
    +
    + + +
    +
    + +

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,2 \) as

    +$$ +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). +$$ +
    +
    + + +
    +
    + +

    Finally, we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,2 \) and update the weights and biases according to the rules

    +$$ +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, +$$ + + +$$ +b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, +$$ +
    +
    + + +

    The parameter \( \eta \) is the learning parameter discussed in connection with the gradient descent methods. +Here it is convenient to use stochastic gradient descent (see the examples below) with mini-batches with an outer loop that steps through multiple epochs of training.

    @@ -581,7 +551,7 @@ known in the literature as the vanishing gradients problem.

  • 77
  • 78
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs069.html b/doc/pub/week42/html/._week42-bs069.html index 7cd1c4691..c097eb7ae 100644 --- a/doc/pub/week42/html/._week42-bs069.html +++ b/doc/pub/week42/html/._week42-bs069.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,18 +456,43 @@ MathJax.Hub.Config({

     

     

     

    - -

    Exploding gradients

    + +

    Setting up a Multi-layer perceptron model for classification

    -

    In other cases, the opposite can happen, namely the the gradients can -grow bigger and bigger. The result is that many of the layers get -large updates of the weights the algorithm diverges. This is the -exploding gradients problem, which is mostly encountered in -recurrent neural networks. More generally, deep neural networks suffer -from unstable gradients, different layers may learn at widely -different speeds +

    We are now gong to develop an example based on the MNIST data +base. This is a classification problem and we need to use our +cross-entropy function we discussed in connection with logistic +regression. The cross-entropy defines our cost function for the +classificaton problems with neural networks.

    +

    In binary classification with two classes \( (0, 1) \) we define the +logistic/sigmoid function as the probability that a particular input +is in class \( 0 \) or \( 1 \). This is possible because the logistic +function takes any input from the real numbers and inputs a number +between 0 and 1, and can therefore be interpreted as a probability. It +also has other nice properties, such as a derivative that is simple to +calculate. +

    + +

    For an input \( \boldsymbol{a} \) from the hidden layer, the probability that the input \( \boldsymbol{x} \) +is in class 0 or 1 is just. We let \( \theta \) represent the unknown weights and biases to be adjusted by our equations). The variable \( x \) +represents our activation values \( z \). We have +

    +$$ +P(y = 0 \mid \boldsymbol{x}, \boldsymbol{\theta}) = \frac{1}{1 + \exp{(- \boldsymbol{x}})} , +$$ + +

    and

    +$$ +P(y = 1 \mid \boldsymbol{x}, \boldsymbol{\theta}) = 1 - P(y = 0 \mid \boldsymbol{x}, \boldsymbol{\theta}) , +$$ + +

    where \( y \in \{0, 1\} \) and \( \boldsymbol{\theta} \) represents the weights and biases +of our network. +

    + +

    diff --git a/doc/pub/week42/html/._week42-bs070.html b/doc/pub/week42/html/._week42-bs070.html index 8b1747f0b..3356c508b 100644 --- a/doc/pub/week42/html/._week42-bs070.html +++ b/doc/pub/week42/html/._week42-bs070.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,24 +456,58 @@ MathJax.Hub.Config({

     

     

     

    - -

    Is the Logistic activation function (Sigmoid) our choice?

    + +

    Defining the cost function

    -

    Although this unfortunate behavior has been empirically observed for -quite a while (it was one of the reasons why deep neural networks were -mostly abandoned for a long time), it is only around 2010 that -significant progress was made in understanding it. +

    Our cost function is given as (see the Logistic regression lectures)

    +$$ +\mathcal{C}(\boldsymbol{\theta}) = - \ln P(\mathcal{D} \mid \boldsymbol{\theta}) = - \sum_{i=1}^n +y_i \ln[P(y_i = 0)] + (1 - y_i) \ln [1 - P(y_i = 0)] = \sum_{i=1}^n \mathcal{L}_i(\boldsymbol{\theta}) . +$$ + +

    This last equality means that we can interpret our cost function as a sum over the loss function +for each point in the dataset \( \mathcal{L}_i(\boldsymbol{\theta}) \). +The negative sign is just so that we can think about our algorithm as minimizing a positive number, rather +than maximizing a negative number.

    -

    A paper titled Understanding the Difficulty of Training Deep -Feedforward Neural Networks by Xavier Glorot and Yoshua Bengio found that -the problems with the popular logistic -sigmoid activation function and the weight initialization technique -that was most popular at the time, namely random initialization using -a normal distribution with a mean of 0 and a standard deviation of -1. +

    In multiclass classification it is common to treat each integer label as a so called one-hot vector:

    + +

    \( y = 5 \quad \rightarrow \quad \boldsymbol{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) , \) and

    + +\( y = 1 \quad \rightarrow \quad \boldsymbol{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) , \) + +

    i.e. a binary bit string of length \( C \), where \( C = 10 \) is the number of classes in the MNIST dataset (numbers from \( 0 \) to \( 9 \))..

    + +

    If \( \boldsymbol{x}_i \) is the \( i \)-th input (image), \( y_{ic} \) refers to the \( c \)-th component of the \( i \)-th +output vector \( \boldsymbol{y}_i \). +The probability of \( \boldsymbol{x}_i \) being in class \( c \) will be given by the softmax function:

    +$$ +P(y_{ic} = 1 \mid \boldsymbol{x}_i, \boldsymbol{\theta}) = \frac{\exp{((\boldsymbol{a}_i^{hidden})^T \boldsymbol{w}_c)}} +{\sum_{c'=0}^{C-1} \exp{((\boldsymbol{a}_i^{hidden})^T \boldsymbol{w}_{c'})}} , +$$ + +

    which reduces to the logistic function in the binary case. +The likelihood of this \( C \)-class classifier +is now given as: +

    + +$$ +P(\mathcal{D} \mid \boldsymbol{\theta}) = \prod_{i=1}^n \prod_{c=0}^{C-1} [P(y_{ic} = 1)]^{y_{ic}} . +$$ + +

    Again we take the negative log-likelihood to define our cost function:

    + +$$ +\mathcal{C}(\boldsymbol{\theta}) = - \log{P(\mathcal{D} \mid \boldsymbol{\theta})}. +$$ + +

    See the logistic regression lectures for a full definition of the cost function.

    + +

    The back propagation equations need now only a small change, namely the definition of a new cost function. We are thus ready to use the same equations as before!

    +

      @@ -582,7 +533,7 @@ a normal distribution with a mean of 0 and a standard deviation of
    • 79
    • 80
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs071.html b/doc/pub/week42/html/._week42-bs071.html index 0a1a68b9a..6762e9eb5 100644 --- a/doc/pub/week42/html/._week42-bs071.html +++ b/doc/pub/week42/html/._week42-bs071.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,17 +457,50 @@ MathJax.Hub.Config({

     

     

     

    -

    Logistic function as the root of problems

    +

    Example: binary classification problem

    -

    They showed that with this activation function and this -initialization scheme, the variance of the outputs of each layer is -much greater than the variance of its inputs. Going forward in the -network, the variance keeps increasing after each layer until the -activation function saturates at the top layers. This is actually made -worse by the fact that the logistic function has a mean of 0.5, not 0 -(the hyperbolic tangent function has a mean of 0 and behaves slightly -better than the logistic function in deep networks). +

    As an example of the above, relevant for project 2 as well, let us consider a binary class. As discussed in our logistic regression lectures, we defined a cost function in terms of the parameters \( \beta \) as

    +$$ +\mathcal{C}(\boldsymbol{\beta}) = - \sum_{i=1}^n \left(y_i\log{p(y_i \vert x_i,\boldsymbol{\beta})}+(1-y_i)\log{1-p(y_i \vert x_i,\boldsymbol{\beta})}\right), +$$ + +

    where we had defined the logistic (sigmoid) function

    +$$ +p(y_i =1\vert x_i,\boldsymbol{\beta})=\frac{\exp{(\beta_0+\beta_1 x_i)}}{1+\exp{(\beta_0+\beta_1 x_i)}}, +$$ + +

    and

    +$$ +p(y_i =0\vert x_i,\boldsymbol{\beta})=1-p(y_i =1\vert x_i,\boldsymbol{\beta}). +$$ + +

    The parameters \( \boldsymbol{\beta} \) were defined using a minimization method like gradient descent or Newton-Raphson's method.

    + +

    Now we replace \( x_i \) with the activation \( z_i^l \) for a given layer \( l \) and the outputs as \( y_i=a_i^l=f(z_i^l) \), with \( z_i^l \) now being a function of the weights \( w_{ij}^l \) and biases \( b_i^l \). +We have then

    +$$ +a_i^l = y_i = \frac{\exp{(z_i^l)}}{1+\exp{(z_i^l)}}, +$$ + +

    with

    +$$ +z_i^l = \sum_{j}w_{ij}^l a_j^{l-1}+b_i^l, +$$ + +

    where the superscript \( l-1 \) indicates that these are the outputs from layer \( l-1 \). +Our cost function at the final layer \( l=L \) is now +

    +$$ +\mathcal{C}(\boldsymbol{W}) = - \sum_{i=1}^n \left(t_i\log{a_i^L}+(1-t_i)\log{(1-a_i^L)}\right), +$$ + +

    where we have defined the targets \( t_i \). The derivatives of the cost function with respect to the output \( a_i^L \) are then easily calculated and we get

    +$$ +\frac{\partial \mathcal{C}(\boldsymbol{W})}{\partial a_i^L} = \frac{a_i^L-t_i}{a_i^L(1-a_i^L)}. +$$ + +

    In case we use another activation function than the logistic one, we need to evaluate other derivatives.

    @@ -577,7 +527,7 @@ better than the logistic function in deep networks).

  • 80
  • 81
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs072.html b/doc/pub/week42/html/._week42-bs072.html index 7a0a3f350..03661dc1a 100644 --- a/doc/pub/week42/html/._week42-bs072.html +++ b/doc/pub/week42/html/._week42-bs072.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,27 +457,24 @@ MathJax.Hub.Config({

     

     

     

    -

    The derivative of the Logistic funtion

    +

    The Softmax function

    +

    In case we employ the more general case given by the Softmax equation, we need to evaluate the derivative of the activation function with respect to the activation \( z_i^l \), that is we need

    +$$ +\frac{\partial f(z_i^l)}{\partial w_{jk}^l} = +\frac{\partial f(z_i^l)}{\partial z_j^l} \frac{\partial z_j^l}{\partial w_{jk}^l}= \frac{\partial f(z_i^l)}{\partial z_j^l}a_k^{l-1}. +$$ -

    Looking at the logistic activation function, when inputs become large -(negative or positive), the function saturates at 0 or 1, with a -derivative extremely close to 0. Thus when backpropagation kicks in, -it has virtually no gradient to propagate back through the network, -and what little gradient exists keeps getting diluted as -backpropagation progresses down through the top layers, so there is -really nothing left for the lower layers. -

    +

    For the Softmax function we have

    +$$ +f(z_i^l) = \frac{\exp{(z_i^l)}}{\sum_{m=1}^K\exp{(z_m^l)}}. +$$ -

    In their paper, Glorot and Bengio propose a way to significantly -alleviate this problem. We need the signal to flow properly in both -directions: in the forward direction when making predictions, and in -the reverse direction when backpropagating gradients. We don’t want -the signal to die out, nor do we want it to explode and saturate. For -the signal to flow properly, the authors argue that we need the -variance of the outputs of each layer to be equal to the variance of -its inputs, and we also need the gradients to have equal variance -before and after flowing through a layer in the reverse direction. -

    +

    Its derivative with respect to \( z_j^l \) gives

    +$$ +\frac{\partial f(z_i^l)}{\partial z_j^l}= f(z_i^l)\left(\delta_{ij}-f(z_j^l)\right), +$$ + +

    which in case of the simply binary model reduces to having \( i=j \).

    @@ -587,7 +501,7 @@ before and after flowing through a layer in the reverse direction.

  • 81
  • 82
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs073.html b/doc/pub/week42/html/._week42-bs073.html index 485b30c35..2d2da4bb2 100644 --- a/doc/pub/week42/html/._week42-bs073.html +++ b/doc/pub/week42/html/._week42-bs073.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,20 +456,19 @@ MathJax.Hub.Config({

     

     

     

    - -

    Insights from the paper by Glorot and Bengio

    + +

    Developing a code for doing neural networks with back propagation

    -

    One of the insights in the 2010 paper by Glorot and Bengio was that -the vanishing/exploding gradients problems were in part due to a poor -choice of activation function. Until then most people had assumed that -if Nature had chosen to use roughly sigmoid activation functions in -biological neurons, they must be an excellent choice. But it turns out -that other activation functions behave much better in deep neural -networks, in particular the ReLU activation function, mostly because -it does not saturate for positive values (and also because it is quite -fast to compute). -

    +

    One can identify a set of key steps when using neural networks to solve supervised learning problems:

    +
      +
    1. Collect and pre-process data
    2. +
    3. Define model and architecture
    4. +
    5. Choose cost function and optimizer
    6. +
    7. Train the model
    8. +
    9. Evaluate model performance on test data
    10. +
    11. Adjust hyperparameters (if necessary, network architecture)
    12. +

    diff --git a/doc/pub/week42/html/._week42-bs074.html b/doc/pub/week42/html/._week42-bs074.html index 26787f4bb..499922228 100644 --- a/doc/pub/week42/html/._week42-bs074.html +++ b/doc/pub/week42/html/._week42-bs074.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,21 +457,117 @@ MathJax.Hub.Config({

     

     

     

    -

    The RELU function family

    +

    Collect and pre-process data

    -

    The ReLU activation function suffers from a problem known as the dying -ReLUs: during training, some neurons effectively die, meaning they -stop outputting anything other than 0. +

    Here we will be using the MNIST dataset, which is readily available through the scikit-learn +package. You may also find it for example here. +The MNIST (Modified National Institute of Standards and Technology) database is a large database +of handwritten digits that is commonly used for training various image processing systems. +The MNIST dataset consists of 70 000 images of size \( 28\times 28 \) pixels, each labeled from 0 to 9. +The scikit-learn dataset we will use consists of a selection of 1797 images of size \( 8\times 8 \) collected and processed from this database.

    -

    In some cases, you may find that half of your network’s neurons are -dead, especially if you used a large learning rate. During training, -if a neuron’s weights get updated such that the weighted sum of the -neuron’s inputs is negative, it will start outputting 0. When this -happen, the neuron is unlikely to come back to life since the gradient -of the ReLU function is 0 when its input is negative. +

    To feed data into a feed-forward neural network we need to represent +the inputs as a design/feature matrix \( X = (n_{inputs}, n_{features}) \). Each +row represents an input, in this case a handwritten digit, and +each column represents a feature, in this case a pixel. The +correct answers, also known as labels or targets are +represented as a 1D array of integers +\( Y = (n_{inputs}) = (5, 3, 1, 8,...) \).

    +

    As an example, say we want to build a neural network using supervised learning to predict Body-Mass Index (BMI) from +measurements of height (in m) +and weight (in kg). If we have measurements of 5 people the design/feature matrix could be for example: +

    + +

    $$ X = \begin{bmatrix} +1.85 & 81\\ +1.71 & 65\\ +1.95 & 103\\ +1.55 & 42\\ +1.63 & 56 +\end{bmatrix} ,$$ +

    + +

    and the targets would be:

    + +

    $$ Y = (23.7, 22.2, 27.1, 17.5, 21.1) $$

    + +

    Since each input image is a 2D matrix, we need to flatten the image +(i.e. "unravel" the 2D matrix into a 1D array) to turn the data into a +design/feature matrix. This means we lose all spatial information in the +image, such as locality and translational invariance. More complicated +architectures such as Convolutional Neural Networks can take advantage +of such information, and are most commonly applied when analyzing +images. +

    + + + +
    +
    +
    +
    +
    +
    # import necessary packages
    +import numpy as np
    +import matplotlib.pyplot as plt
    +from sklearn import datasets
    +
    +
    +# ensure the same random numbers appear every time
    +np.random.seed(0)
    +
    +# display images in notebook
    +%matplotlib inline
    +plt.rcParams['figure.figsize'] = (12,12)
    +
    +
    +# download MNIST dataset
    +digits = datasets.load_digits()
    +
    +# define inputs and labels
    +inputs = digits.images
    +labels = digits.target
    +
    +print("inputs = (n_inputs, pixel_width, pixel_height) = " + str(inputs.shape))
    +print("labels = (n_inputs) = " + str(labels.shape))
    +
    +
    +# flatten the image
    +# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64
    +n_inputs = len(inputs)
    +inputs = inputs.reshape(n_inputs, -1)
    +print("X = (n_inputs, n_features) = " + str(inputs.shape))
    +
    +
    +# choose some random images to display
    +indices = np.arange(n_inputs)
    +random_indices = np.random.choice(indices, size=5)
    +
    +for i, image in enumerate(digits.images[random_indices]):
    +    plt.subplot(1, 5, i+1)
    +    plt.axis('off')
    +    plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
    +    plt.title("Label: %d" % digits.target[random_indices[i]])
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

      @@ -580,7 +593,7 @@ of the ReLU function is 0 when its input is negative.
    • 83
    • 84
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs075.html b/doc/pub/week42/html/._week42-bs075.html index 1a813d834..1288b7b87 100644 --- a/doc/pub/week42/html/._week42-bs075.html +++ b/doc/pub/week42/html/._week42-bs075.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,16 +457,67 @@ MathJax.Hub.Config({

     

     

     

    -

    ELU function

    +

    Train and test datasets

    -

    To solve this problem, nowadays practitioners use a variant of the -ReLU function, such as the leaky ReLU discussed above or the so-called -exponential linear unit (ELU) function +

    Performing analysis before partitioning the dataset is a major error, that can lead to incorrect conclusions.

    + +

    We will reserve \( 80 \% \) of our dataset for training and \( 20 \% \) for testing.

    + +

    It is important that the train and test datasets are drawn randomly from our dataset, to ensure +no bias in the sampling. +Say you are taking measurements of weather data to predict the weather in the coming 5 days. +You don't want to train your model on measurements taken from the hours 00.00 to 12.00, and then test it on data +collected from 12.00 to 24.00.

    -$$ -ELU(z) = \left\{\begin{array}{cc} \alpha\left( \exp{(z)}-1\right) & z < 0,\\ z & z \ge 0.\end{array}\right. -$$ + + +
    +
    +
    +
    +
    +
    from sklearn.model_selection import train_test_split
    +
    +# one-liner from scikit-learn library
    +train_size = 0.8
    +test_size = 1 - train_size
    +X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
    +                                                    test_size=test_size)
    +
    +# equivalently in numpy
    +def train_test_split_numpy(inputs, labels, train_size, test_size):
    +    n_inputs = len(inputs)
    +    inputs_shuffled = inputs.copy()
    +    labels_shuffled = labels.copy()
    +    
    +    np.random.shuffle(inputs_shuffled)
    +    np.random.shuffle(labels_shuffled)
    +    
    +    train_end = int(n_inputs*train_size)
    +    X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]
    +    Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]
    +    
    +    return X_train, X_test, Y_train, Y_test
    +
    +#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)
    +
    +print("Number of training images: " + str(len(X_train)))
    +print("Number of test images: " + str(len(X_test)))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -577,7 +545,7 @@ $$

  • 84
  • 85
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs076.html b/doc/pub/week42/html/._week42-bs076.html index 12f31cddd..65ea8d04d 100644 --- a/doc/pub/week42/html/._week42-bs076.html +++ b/doc/pub/week42/html/._week42-bs076.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,22 +457,47 @@ MathJax.Hub.Config({

     

     

     

    -

    Which activation function should we use?

    +

    Define model and architecture

    -

    In general it seems that the ELU activation function is better than -the leaky ReLU function (and its variants), which is better than -ReLU. ReLU performs better than \( \tanh \) which in turn performs better -than the logistic function. +

    Our simple feed-forward neural network will consist of an input layer, a single hidden layer and an output layer. The activation \( y \) of each neuron is a weighted sum of inputs, passed through an activation function. In case of the simple perceptron model we have

    + +

    $$ z = \sum_{i=1}^n w_i a_i ,$$

    + +

    $$ y = f(z) ,$$

    + +

    where \( f \) is the activation function, \( a_i \) represents input from neuron \( i \) in the preceding layer +and \( w_i \) is the weight to input \( i \). +The activation of the neurons in the input layer is just the features (e.g. a pixel value).

    -

    If runtime performance is an issue, then you may opt for the leaky -ReLU function over the ELU function If you don’t want to tweak yet -another hyperparameter, you may just use the default \( \alpha \) of -\( 0.01 \) for the leaky ReLU, and \( 1 \) for ELU. If you have spare time and -computing power, you can use cross-validation or bootstrap to evaluate -other activation functions. +

    The simplest activation function for a neuron is the Heaviside function:

    + +

    $$ f(z) = +\begin{cases} +1, & z > 0\\ +0, & \text{otherwise} +\end{cases} +$$

    +

    A feed-forward neural network with this activation is known as a perceptron. +For a binary classifier (i.e. two classes, 0 or 1, dog or not-dog) we can also use this in our output layer. +This activation can be generalized to \( k \) classes (using e.g. the one-against-all strategy), +and we call these architectures multiclass perceptrons. +

    + +

    However, it is now common to use the terms Single Layer Perceptron (SLP) (1 hidden layer) and +Multilayer Perceptron (MLP) (2 or more hidden layers) to refer to feed-forward neural networks with any activation function. +

    + +

    Typical choices for activation functions include the sigmoid function, hyperbolic tangent, and Rectified Linear Unit (ReLU). +We will be using the sigmoid function \( \sigma(x) \): +

    + +

    $$ f(x) = \sigma(x) = \frac{1}{1 + e^{-x}} ,$$

    + +

    which is inspired by probability theory (see logistic regression) and was most commonly used until about 2011. See the discussion below concerning other activation functions.

    +

      @@ -581,7 +523,7 @@ other activation functions.
    • 85
    • 86
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs077.html b/doc/pub/week42/html/._week42-bs077.html index 5fbce2ef3..661d5e2c9 100644 --- a/doc/pub/week42/html/._week42-bs077.html +++ b/doc/pub/week42/html/._week42-bs077.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,23 +456,47 @@ MathJax.Hub.Config({

     

     

     

    - -

    More on activation functions, output layers

    - -

    In most cases you can use the ReLU activation function in the hidden -layers (or one of its variants). -

    - -

    It is a bit faster to compute than other activation functions, and the -gradient descent optimization does in general not get stuck. -

    - -For the output layer: + +

    Layers

      -
    • For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).
    • -
    • For regression tasks, you can simply use no activation function at all.
    • +
    • Input
    +

    Since each input image has 8x8 = 64 pixels or features, we have an input layer of 64 neurons.

    + +
      +
    • Hidden layer
    • +
    +

    We will use 50 neurons in the hidden layer receiving input from the neurons in the input layer. +Since each neuron in the hidden layer is connected to the 64 inputs we have 64x50 = 3200 weights to the hidden layer. +

    + +
      +
    • Output
    • +
    +

    If we were building a binary classifier, it would be sufficient with a single neuron in the output layer, +which could output 0 or 1 according to the Heaviside function. This would be an example of a hard classifier, meaning it outputs the class of the input directly. However, if we are dealing with noisy data it is often beneficial to use a soft classifier, which outputs the probability of being in class 0 or 1. +

    + +

    For a soft binary classifier, we could use a single neuron and interpret the output as either being the probability of being in class 0 or the probability of being in class 1. Alternatively we could use 2 neurons, and interpret each neuron as the probability of being in each class.

    + +

    Since we are doing multiclass classification, with 10 categories, it is natural to use 10 neurons in the output layer. We number the neurons \( j = 0,1,...,9 \). The activation of each output neuron \( j \) will be according to the softmax function:

    + +

    $$ P(\text{class \( j \)} \mid \text{input \( \boldsymbol{a} \)}) = \frac{\exp{(\boldsymbol{a}^T \boldsymbol{w}_j)}} +{\sum_{c=0}^{9} \exp{(\boldsymbol{a}^T \boldsymbol{w}_c)}} ,$$ +

    + +

    i.e. each neuron \( j \) outputs the probability of being in class \( j \) given an input from the hidden layer \( \boldsymbol{a} \), with \( \boldsymbol{w}_j \) the weights of neuron \( j \) to the inputs. +The denominator is a normalization factor to ensure the outputs (probabilities) sum up to 1. +The exponent is just the weighted sum of inputs as before: +

    + +

    $$ z_j = \sum_{i=1}^n w_ {ij} a_i+b_j.$$

    + +

    Since each neuron in the output layer is connected to the 50 inputs from the hidden layer we have 50x10 = 500 +weights to the output layer. +

    +

      @@ -581,7 +522,7 @@ gradient descent optimization does in general not get stuck.
    • 86
    • 87
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs078.html b/doc/pub/week42/html/._week42-bs078.html index a1e05b50f..c7264104f 100644 --- a/doc/pub/week42/html/._week42-bs078.html +++ b/doc/pub/week42/html/._week42-bs078.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,27 +456,58 @@ MathJax.Hub.Config({

     

     

     

    - -

    Batch Normalization

    + +

    Weights and biases

    -

    Batch Normalization aims to address the vanishing/exploding gradients -problems, and more generally the problem that the distribution of each -layer’s inputs changes during training, as the parameters of the -previous layers change. +

    Typically weights are initialized with small values distributed around zero, drawn from a uniform +or normal distribution. Setting all weights to zero means all neurons give the same output, making the network useless.

    -

    The technique consists of adding an operation in the model just before -the activation function of each layer, simply zero-centering and -normalizing the inputs, then scaling and shifting the result using two -new parameters per layer (one for scaling, the other for shifting). In -other words, this operation lets the model learn the optimal scale and -mean of the inputs for each layer. In order to zero-center and -normalize the inputs, the algorithm needs to estimate the inputs’ mean -and standard deviation. It does so by evaluating the mean and standard -deviation of the inputs over the current mini-batch, from this the -name batch normalization. +

    Adding a bias value to the weighted sum of inputs allows the neural network to represent a greater range +of values. Without it, any input with the value 0 will be mapped to zero (before being passed through the activation). The bias unit has an output of 1, and a weight to each neuron \( j \), \( b_j \):

    +

    $$ z_j = \sum_{i=1}^n w_ {ij} a_i + b_j.$$

    + +

    The bias weights \( \boldsymbol{b} \) are often initialized to zero, but a small value like \( 0.01 \) ensures all neurons have some output which can be backpropagated in the first training cycle.

    + + +
    +
    +
    +
    +
    +
    # building our neural network
    +
    +n_inputs, n_features = X_train.shape
    +n_hidden_neurons = 50
    +n_categories = 10
    +
    +# we make the weights normally distributed using numpy.random.randn
    +
    +# weights and bias in the hidden layer
    +hidden_weights = np.random.randn(n_features, n_hidden_neurons)
    +hidden_bias = np.zeros(n_hidden_neurons) + 0.01
    +
    +# weights and bias in the output layer
    +output_weights = np.random.randn(n_hidden_neurons, n_categories)
    +output_bias = np.zeros(n_categories) + 0.01
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

      @@ -585,7 +533,7 @@ name batch normalization.
    • 87
    • 88
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs079.html b/doc/pub/week42/html/._week42-bs079.html index cb9feac1c..beb29d2f5 100644 --- a/doc/pub/week42/html/._week42-bs079.html +++ b/doc/pub/week42/html/._week42-bs079.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,18 +457,26 @@ MathJax.Hub.Config({

     

     

     

    -

    Dropout

    +

    Feed-forward pass

    -

    It is a fairly simple algorithm: at every training step, every neuron -(including the input neurons but excluding the output neurons) has a -probability \( p \) of being temporarily dropped out, meaning it will be -entirely ignored during this training step, but it may be active -during the next step. +

    Denote \( F \) the number of features, \( H \) the number of hidden neurons and \( C \) the number of categories. +For each input image we calculate a weighted sum of input features (pixel values) to each neuron \( j \) in the hidden layer \( l \):

    -

    The hyperparameter \( p \) is called the dropout rate, and it is typically -set to 50%. After training, the neurons are not dropped anymore. It -is viewed as one of the most popular regularization techniques. +

    $$ z_{j}^{l} = \sum_{i=1}^{F} w_{ij}^{l} x_i + b_{j}^{l},$$

    + +

    this is then passed through our activation function

    + +

    $$ a_{j}^{l} = f(z_{j}^{l}) .$$

    + +

    We calculate a weighted sum of inputs (activations in the hidden layer) to each neuron \( j \) in the output layer:

    + +

    $$ z_{j}^{L} = \sum_{i=1}^{H} w_{ij}^{L} a_{i}^{l} + b_{j}^{L}.$$

    + +

    Finally we calculate the output of neuron \( j \) in the output layer using the softmax function:

    + +

    $$ a_{j}^{L} = \frac{\exp{(z_j^{L})}} +{\sum_{c=0}^{C-1} \exp{(z_c^{L})}} .$$

    @@ -579,7 +504,7 @@ is viewed as one of the most popular regularization techniques.

  • 88
  • 89
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs080.html b/doc/pub/week42/html/._week42-bs080.html index 7d7894487..d6899189d 100644 --- a/doc/pub/week42/html/._week42-bs080.html +++ b/doc/pub/week42/html/._week42-bs080.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,21 +456,96 @@ MathJax.Hub.Config({

     

     

     

    - -

    Gradient Clipping

    + +

    Matrix multiplications

    -

    A popular technique to lessen the exploding gradients problem is to -simply clip the gradients during backpropagation so that they never -exceed some threshold (this is mostly useful for recurrent neural -networks). +

    Since our data has the dimensions \( X = (n_{inputs}, n_{features}) \) and our weights to the hidden +layer have the dimensions +\( W_{hidden} = (n_{features}, n_{hidden}) \), +we can easily feed the network all our training data in one go by taking the matrix product

    -

    This technique is called Gradient Clipping.

    +

    $$ X W^{h} = (n_{inputs}, n_{hidden}),$$

    -

    In general however, Batch -Normalization is preferred. +

    and obtain a matrix that holds the weighted sum of inputs to the hidden layer +for each input image and each hidden neuron. +We also add the bias to obtain a matrix of weighted sums to the hidden layer \( Z^{h} \):

    +

    $$ \boldsymbol{z}^{l} = \boldsymbol{X} \boldsymbol{W}^{l} + \boldsymbol{b}^{l} ,$$

    + +

    meaning the same bias (1D array with size equal number of hidden neurons) is added to each input image. +This is then passed through the activation: +

    + +

    $$ \boldsymbol{a}^{l} = f(\boldsymbol{z}^l) .$$

    + +

    This is fed to the output layer:

    + +

    $$ \boldsymbol{z}^{L} = \boldsymbol{a}^{L} \boldsymbol{W}^{L} + \boldsymbol{b}^{L} .$$

    + +

    Finally we receive our output values for each image and each category by passing it through the softmax function:

    + +

    $$ output = softmax (\boldsymbol{z}^{L}) = (n_{inputs}, n_{categories}) .$$

    + + + +
    +
    +
    +
    +
    +
    # setup the feed-forward pass, subscript h = hidden layer
    +
    +def sigmoid(x):
    +    return 1/(1 + np.exp(-x))
    +
    +def feed_forward(X):
    +    # weighted sum of inputs to the hidden layer
    +    z_h = np.matmul(X, hidden_weights) + hidden_bias
    +    # activation in the hidden layer
    +    a_h = sigmoid(z_h)
    +    
    +    # weighted sum of inputs to the output layer
    +    z_o = np.matmul(a_h, output_weights) + output_bias
    +    # softmax output
    +    # axis 0 holds each input and axis 1 the probabilities of each category
    +    exp_term = np.exp(z_o)
    +    probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    +    
    +    return probabilities
    +
    +probabilities = feed_forward(X_train)
    +print("probabilities = (n_inputs, n_categories) = " + str(probabilities.shape))
    +print("probability that image 0 is in category 0,1,2,...,9 = \n" + str(probabilities[0]))
    +print("probabilities sum up to: " + str(probabilities[0].sum()))
    +print()
    +
    +# we obtain a prediction by taking the class with the highest likelihood
    +def predict(X):
    +    probabilities = feed_forward(X)
    +    return np.argmax(probabilities, axis=1)
    +
    +predictions = predict(X_train)
    +print("predictions = (n_inputs) = " + str(predictions.shape))
    +print("prediction for image 0: " + str(predictions[0]))
    +print("correct label for image 0: " + str(Y_train[0]))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

      @@ -579,7 +571,7 @@ Normalization is preferred.
    • 89
    • 90
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs081.html b/doc/pub/week42/html/._week42-bs081.html index 95fd8461e..722d2a04c 100644 --- a/doc/pub/week42/html/._week42-bs081.html +++ b/doc/pub/week42/html/._week42-bs081.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,25 +456,34 @@ MathJax.Hub.Config({

     

     

     

    - -

    A top-down perspective on Neural networks

    + +

    Choose cost function and optimizer

    -

    The first thing we would like to do is divide the data into two or -three parts. A training set, a validation or dev (development) set, -and a test set. The test set is the data on which we want to make -predictions. The dev set is a subset of the training data we use to -check how well we are doing out-of-sample, after training the model on -the training dataset. We use the validation error as a proxy for the -test error in order to make tweaks to our model. It is crucial that we -do not use any of the test data to train the algorithm. This is a -cardinal sin in ML. Then: +

    To measure how well our neural network is doing we need to introduce a cost function. +We will call the function that gives the error of a single sample output the loss function, and the function +that gives the total error of our network across all samples the cost function. +A typical choice for multiclass classification is the cross-entropy loss, also known as the negative log likelihood.

    -
      -
    1. Estimate optimal error rate
    2. -
    3. Minimize underfitting (bias) on training data set.
    4. -
    5. Make sure you are not overfitting.
    6. -
    +

    In multiclass classification it is common to treat each integer label as a so called one-hot vector:

    + +

    $$ y = 5 \quad \rightarrow \quad \boldsymbol{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$$

    + +

    $$ y = 1 \quad \rightarrow \quad \boldsymbol{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$$

    + +

    i.e. a binary bit string of length \( C \), where \( C = 10 \) is the number of classes in the MNIST dataset.

    + +

    Let \( y_{ic} \) denote the \( c \)-th component of the \( i \)-th one-hot vector. +We define the cost function \( \mathcal{C} \) as a sum over the cross-entropy loss for each point \( \boldsymbol{x}_i \) in the dataset. +

    + +

    In the one-hot representation only one of the terms in the loss function is non-zero, namely the +probability of the correct category \( c' \) +(i.e. the category \( c' \) such that \( y_{ic'} = 1 \)). This means that the cross entropy loss only punishes you for how wrong +you got the correct label. The probability of category \( c \) is given by the softmax function. The vector \( \boldsymbol{\theta} \) represents the parameters of our network, i.e. all the weights and biases. +

    + +

      @@ -583,7 +509,7 @@ cardinal sin in ML. Then:
    • 90
    • 91
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs082.html b/doc/pub/week42/html/._week42-bs082.html index 54b425784..4c89bad1b 100644 --- a/doc/pub/week42/html/._week42-bs082.html +++ b/doc/pub/week42/html/._week42-bs082.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,29 +457,40 @@ MathJax.Hub.Config({

     

     

     

    -

    More top-down perspectives

    +

    Optimizing the cost function

    -

    If the validation and test sets are drawn from the same distributions, -then a good performance on the validation set should lead to similarly -good performance on the test set. +

    The network is trained by finding the weights and biases that minimize the cost function. One of the most widely used classes of methods is gradient descent and its generalizations. The idea behind gradient descent +is simply to adjust the weights in the direction where the gradient of the cost function is large and negative. This ensures we flow toward a local minimum of the cost function. +Each parameter \( \theta \) is iteratively adjusted according to the rule

    -

    However, sometimes -the training data and test data differ in subtle ways because, for -example, they are collected using slightly different methods, or -because it is cheaper to collect data in one way versus another. In -this case, there can be a mismatch between the training and test -data. This can lead to the neural network overfitting these small -differences between the test and training sets, and a poor performance -on the test set despite having a good performance on the validation -set. To rectify this, Andrew Ng suggests making two validation or dev -sets, one constructed from the training data and one constructed from -the test data. The difference between the performance of the algorithm -on these two validation sets quantifies the train-test mismatch. This -can serve as another important diagnostic when using DNNs for -supervised learning. +

    $$ \theta_{i+1} = \theta_i - \eta \nabla \mathcal{C}(\theta_i) ,$$

    + +

    where \( \eta \) is known as the learning rate, which controls how big a step we take towards the minimum. +This update can be repeated for any number of iterations, or until we are satisfied with the result.

    +

    A simple and effective improvement is a variant called Batch Gradient Descent. +Instead of calculating the gradient on the whole dataset, we calculate an approximation of the gradient +on a subset of the data called a minibatch. +If there are \( N \) data points and we have a minibatch size of \( M \), the total number of batches +is \( N/M \). +We denote each minibatch \( B_k \), with \( k = 1, 2,...,N/M \). The gradient then becomes: +

    + +

    $$ \nabla \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \nabla \mathcal{L}_i(\theta) \quad \rightarrow \quad +\frac{1}{M} \sum_{i \in B_k} \nabla \mathcal{L}_i(\theta) ,$$ +

    + +

    i.e. instead of averaging the loss over the entire dataset, we average over a minibatch.

    + +

    This has two important benefits:

    +
      +
    1. Introducing stochasticity decreases the chance that the algorithm becomes stuck in a local minima.
    2. +
    3. It significantly speeds up the calculation, since we do not have to use the entire dataset to calculate the gradient.
    4. +
    +

    The various optmization methods, with codes and algorithms, are discussed in our lectures on Gradient descent approaches.

    +

    diff --git a/doc/pub/week42/html/._week42-bs083.html b/doc/pub/week42/html/._week42-bs083.html index 6b0eebbf6..ce9dca8a4 100644 --- a/doc/pub/week42/html/._week42-bs083.html +++ b/doc/pub/week42/html/._week42-bs083.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,16 +456,34 @@ MathJax.Hub.Config({

     

     

     

    - -

    Limitations of supervised learning with deep networks

    + +

    Regularization

    -

    Like all statistical methods, supervised learning using neural -networks has important limitations. This is especially important when -one seeks to apply these methods, especially to physics problems. Like -all tools, DNNs are not a universal solution. Often, the same or -better performance on a task can be achieved by using a few -hand-engineered features (or even a collection of random -features). +

    It is common to add an extra term to the cost function, proportional +to the size of the weights. This is equivalent to constraining the +size of the weights, so that they do not grow out of control. +Constraining the size of the weights means that the weights cannot +grow arbitrarily large to fit the training data, and in this way +reduces overfitting. +

    + +

    We will measure the size of the weights using the so called L2-norm, meaning our cost function becomes:

    + +

    $$ \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) \quad \rightarrow \quad +\frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) + \lambda \lvert \lvert \boldsymbol{w} \rvert \rvert_2^2 += \frac{1}{N} \sum_{i=1}^N \mathcal{L}(\theta) + \lambda \sum_{ij} w_{ij}^2,$$ +

    + +

    i.e. we sum up all the weights squared. The factor \( \lambda \) is known as a regularization parameter.

    + +

    In order to train the model, we need to calculate the derivative of +the cost function with respect to every bias and weight in the +network. In total our network has \( (64 + 1)\times 50=3250 \) weights in +the hidden layer and \( (50 + 1)\times 10=510 \) weights to the output +layer (\( +1 \) for the bias), and the gradient must be calculated for +every parameter. We use the backpropagation algorithm discussed +above. This is a clever use of the chain rule that allows us to +calculate the gradient efficently.

    @@ -576,7 +511,7 @@ features).

  • 92
  • 93
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs084.html b/doc/pub/week42/html/._week42-bs084.html index 7be951003..9eb737007 100644 --- a/doc/pub/week42/html/._week42-bs084.html +++ b/doc/pub/week42/html/._week42-bs084.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,14 +457,132 @@ MathJax.Hub.Config({

     

     

     

    -

    Limitations of NNs

    +

    Matrix multiplication

    + +

    To more efficently train our network these equations are implemented using matrix operations. +The error in the output layer is calculated simply as, with \( \boldsymbol{t} \) being our targets, +

    + +

    $$ \delta_L = \boldsymbol{t} - \boldsymbol{y} = (n_{inputs}, n_{categories}) .$$

    + +

    The gradient for the output weights is calculated as

    + +

    $$ \nabla W_{L} = \boldsymbol{a}^T \delta_L = (n_{hidden}, n_{categories}) ,$$

    + +

    where \( \boldsymbol{a} = (n_{inputs}, n_{hidden}) \). This simply means that we are summing up the gradients for each input. +Since we are going backwards we have to transpose the activation matrix. +

    + +

    The gradient with respect to the output bias is then

    + +

    $$ \nabla \boldsymbol{b}_{L} = \sum_{i=1}^{n_{inputs}} \delta_L = (n_{categories}) .$$

    + +

    The error in the hidden layer is

    + +

    $$ \Delta_h = \delta_L W_{L}^T \circ f'(z_{h}) = \delta_L W_{L}^T \circ a_{h} \circ (1 - a_{h}) = (n_{inputs}, n_{hidden}) ,$$

    + +

    where \( f'(a_{h}) \) is the derivative of the activation in the hidden layer. The matrix products mean +that we are summing up the products for each neuron in the output layer. The symbol \( \circ \) denotes +the Hadamard product, meaning element-wise multiplication. +

    + +

    This again gives us the gradients in the hidden layer:

    + +

    $$ \nabla W_{h} = X^T \delta_h = (n_{features}, n_{hidden}) ,$$

    + +

    $$ \nabla b_{h} = \sum_{i=1}^{n_{inputs}} \delta_h = (n_{hidden}) .$$

    + + + +
    +
    +
    +
    +
    +
    # to categorical turns our integer vector into a onehot representation
    +from sklearn.metrics import accuracy_score
    +
    +# one-hot in numpy
    +def to_categorical_numpy(integer_vector):
    +    n_inputs = len(integer_vector)
    +    n_categories = np.max(integer_vector) + 1
    +    onehot_vector = np.zeros((n_inputs, n_categories))
    +    onehot_vector[range(n_inputs), integer_vector] = 1
    +    
    +    return onehot_vector
    +
    +#Y_train_onehot, Y_test_onehot = to_categorical(Y_train), to_categorical(Y_test)
    +Y_train_onehot, Y_test_onehot = to_categorical_numpy(Y_train), to_categorical_numpy(Y_test)
    +
    +def feed_forward_train(X):
    +    # weighted sum of inputs to the hidden layer
    +    z_h = np.matmul(X, hidden_weights) + hidden_bias
    +    # activation in the hidden layer
    +    a_h = sigmoid(z_h)
    +    
    +    # weighted sum of inputs to the output layer
    +    z_o = np.matmul(a_h, output_weights) + output_bias
    +    # softmax output
    +    # axis 0 holds each input and axis 1 the probabilities of each category
    +    exp_term = np.exp(z_o)
    +    probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    +    
    +    # for backpropagation need activations in hidden and output layers
    +    return a_h, probabilities
    +
    +def backpropagation(X, Y):
    +    a_h, probabilities = feed_forward_train(X)
    +    
    +    # error in the output layer
    +    error_output = probabilities - Y
    +    # error in the hidden layer
    +    error_hidden = np.matmul(error_output, output_weights.T) * a_h * (1 - a_h)
    +    
    +    # gradients for the output layer
    +    output_weights_gradient = np.matmul(a_h.T, error_output)
    +    output_bias_gradient = np.sum(error_output, axis=0)
    +    
    +    # gradient for the hidden layer
    +    hidden_weights_gradient = np.matmul(X.T, error_hidden)
    +    hidden_bias_gradient = np.sum(error_hidden, axis=0)
    +
    +    return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient
    +
    +print("Old accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train)))
    +
    +eta = 0.01
    +lmbd = 0.01
    +for i in range(1000):
    +    # calculate gradients
    +    dWo, dBo, dWh, dBh = backpropagation(X_train, Y_train_onehot)
    +    
    +    # regularization term gradients
    +    dWo += lmbd * output_weights
    +    dWh += lmbd * hidden_weights
    +    
    +    # update weights and biases
    +    output_weights -= eta * dWo
    +    output_bias -= eta * dBo
    +    hidden_weights -= eta * dWh
    +    hidden_bias -= eta * dBh
    +
    +print("New accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train)))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    Here we list some of the important limitations of supervised neural network based models.

    -
      -
    • Need labeled data. All supervised learning methods, DNNs for supervised learning require labeled data. Often, labeled data is harder to acquire than unlabeled data (e.g. one must pay for human experts to label images).
    • -
    • Supervised neural networks are extremely data intensive. DNNs are data hungry. They perform best when data is plentiful. This is doubly so for supervised methods where the data must also be labeled. The utility of DNNs is extremely limited if data is hard to acquire or the datasets are small (hundreds to a few thousand samples). In this case, the performance of other methods that utilize hand-engineered features can exceed that of DNNs.
    • -

    diff --git a/doc/pub/week42/html/._week42-bs085.html b/doc/pub/week42/html/._week42-bs085.html index 24f254e8c..ef81256e4 100644 --- a/doc/pub/week42/html/._week42-bs085.html +++ b/doc/pub/week42/html/._week42-bs085.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,11 +457,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Homogeneous data

    +

    Improving performance

    + +

    As we can see the network does not seem to be learning at all. It seems to be just guessing the label for each image. +In order to obtain a network that does something useful, we will have to do a bit more work. +

    + +

    The choice of hyperparameters such as learning rate and regularization parameter is hugely influential for the performance of the network. Typically a grid-search is performed, wherein we test different hyperparameters separated by orders of magnitude. For example we could test the learning rates \( \eta = 10^{-6}, 10^{-5},...,10^{-1} \) with different regularization parameters \( \lambda = 10^{-6},...,10^{-0} \).

    + +

    Next, we haven't implemented minibatching yet, which introduces stochasticity and is though to act as an important regularizer on the weights. We call a feed-forward + backward pass with a minibatch an iteration, and a full training period +going through the entire dataset (\( n/M \) batches) an epoch. +

    + +

    If this does not improve network performance, you may want to consider altering the network architecture, adding more neurons or hidden layers. +Andrew Ng goes through some of these considerations in this video. You can find a summary of the video here. +

    -
      -
    • Homogeneous data. Almost all DNNs deal with homogeneous data of one type. It is very hard to design architectures that mix and match data types (i.e. some continuous variables, some discrete variables, some time series). In applications beyond images, video, and language, this is often what is required. In contrast, ensemble models like random forests or gradient-boosted trees have no difficulty handling mixed data types.
    • -

    diff --git a/doc/pub/week42/html/._week42-bs086.html b/doc/pub/week42/html/._week42-bs086.html index 173df97e9..3b0d16fa2 100644 --- a/doc/pub/week42/html/._week42-bs086.html +++ b/doc/pub/week42/html/._week42-bs086.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,12 +457,133 @@ MathJax.Hub.Config({

     

     

     

    -

    More limitations

    +

    Full object-oriented implementation

    + +

    It is very natural to think of the network as an object, with specific instances of the network +being realizations of this object with different hyperparameters. An implementation using Python classes provides a clean structure and interface, and the full implementation of our neural network is given below. +

    + + + +
    +
    +
    +
    +
    +
    class NeuralNetwork:
    +    def __init__(
    +            self,
    +            X_data,
    +            Y_data,
    +            n_hidden_neurons=50,
    +            n_categories=10,
    +            epochs=10,
    +            batch_size=100,
    +            eta=0.1,
    +            lmbd=0.0):
    +
    +        self.X_data_full = X_data
    +        self.Y_data_full = Y_data
    +
    +        self.n_inputs = X_data.shape[0]
    +        self.n_features = X_data.shape[1]
    +        self.n_hidden_neurons = n_hidden_neurons
    +        self.n_categories = n_categories
    +
    +        self.epochs = epochs
    +        self.batch_size = batch_size
    +        self.iterations = self.n_inputs // self.batch_size
    +        self.eta = eta
    +        self.lmbd = lmbd
    +
    +        self.create_biases_and_weights()
    +
    +    def create_biases_and_weights(self):
    +        self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)
    +        self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01
    +
    +        self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)
    +        self.output_bias = np.zeros(self.n_categories) + 0.01
    +
    +    def feed_forward(self):
    +        # feed-forward for training
    +        self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias
    +        self.a_h = sigmoid(self.z_h)
    +
    +        self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias
    +
    +        exp_term = np.exp(self.z_o)
    +        self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    +
    +    def feed_forward_out(self, X):
    +        # feed-forward for output
    +        z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias
    +        a_h = sigmoid(z_h)
    +
    +        z_o = np.matmul(a_h, self.output_weights) + self.output_bias
    +        
    +        exp_term = np.exp(z_o)
    +        probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    +        return probabilities
    +
    +    def backpropagation(self):
    +        error_output = self.probabilities - self.Y_data
    +        error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)
    +
    +        self.output_weights_gradient = np.matmul(self.a_h.T, error_output)
    +        self.output_bias_gradient = np.sum(error_output, axis=0)
    +
    +        self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)
    +        self.hidden_bias_gradient = np.sum(error_hidden, axis=0)
    +
    +        if self.lmbd > 0.0:
    +            self.output_weights_gradient += self.lmbd * self.output_weights
    +            self.hidden_weights_gradient += self.lmbd * self.hidden_weights
    +
    +        self.output_weights -= self.eta * self.output_weights_gradient
    +        self.output_bias -= self.eta * self.output_bias_gradient
    +        self.hidden_weights -= self.eta * self.hidden_weights_gradient
    +        self.hidden_bias -= self.eta * self.hidden_bias_gradient
    +
    +    def predict(self, X):
    +        probabilities = self.feed_forward_out(X)
    +        return np.argmax(probabilities, axis=1)
    +
    +    def predict_probabilities(self, X):
    +        probabilities = self.feed_forward_out(X)
    +        return probabilities
    +
    +    def train(self):
    +        data_indices = np.arange(self.n_inputs)
    +
    +        for i in range(self.epochs):
    +            for j in range(self.iterations):
    +                # pick datapoints with replacement
    +                chosen_datapoints = np.random.choice(
    +                    data_indices, size=self.batch_size, replace=False
    +                )
    +
    +                # minibatch training data
    +                self.X_data = self.X_data_full[chosen_datapoints]
    +                self.Y_data = self.Y_data_full[chosen_datapoints]
    +
    +                self.feed_forward()
    +                self.backpropagation()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -
      -
    • Many problems are not about prediction. In natural science we are often interested in learning something about the underlying distribution that generates the data. In this case, it is often difficult to cast these ideas in a supervised learning setting. While the problems are related, it is possible to make good predictions with a wrong model. The model might or might not be useful for understanding the underlying science.
    • -
    -

    Some of these remarks are particular to DNNs, others are shared by all supervised learning methods. This motivates the use of unsupervised methods which in part circumvent these problems.

    @@ -572,7 +610,7 @@ MathJax.Hub.Config({

  • 95
  • 96
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs087.html b/doc/pub/week42/html/._week42-bs087.html index d7e44139c..d09923748 100644 --- a/doc/pub/week42/html/._week42-bs087.html +++ b/doc/pub/week42/html/._week42-bs087.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,75 +457,56 @@ MathJax.Hub.Config({

     

     

     

    -

    Setting up the back-propagation algorithm

    +

    Evaluate model performance on test data

    -

    Let us write this out in the form of an algorithm.

    - -
    -
    - -

    First, we set up the input data \( \boldsymbol{x} \) and the activations -\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and -the pertinent outputs \( \boldsymbol{a}^1 \). +

    To measure the performance of our network we evaluate how well it does it data it has never seen before, i.e. the test data. +We measure the performance of the network using the accuracy score. +The accuracy is as you would expect just the number of images correctly labeled divided by the total number of images. A perfect classifier will have an accuracy score of \( 1 \).

    + +

    $$ \text{Accuracy} = \frac{\sum_{i=1}^n I(\tilde{y}_i = y_i)}{n} ,$$

    + +

    where \( I \) is the indicator function, \( 1 \) if \( \tilde{y}_i = y_i \) and \( 0 \) otherwise.

    + + + +
    +
    +
    +
    +
    +
    epochs = 100
    +batch_size = 100
    +
    +dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,
    +                    n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)
    +dnn.train()
    +test_predict = dnn.predict(X_test)
    +
    +# accuracy score from scikit library
    +print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))
    +
    +# equivalent in numpy
    +def accuracy_score_numpy(Y_test, Y_pred):
    +    return np.sum(Y_test == Y_pred) / len(Y_test)
    +
    +#print("Accuracy score on test set: ", accuracy_score_numpy(Y_test, test_predict))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    - -

    Secondly, we perform then the feed forward till we reach the output -layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the -activation function and the pertinent outputs \( \boldsymbol{a}^l \) for -\( l=2,3,\dots,L \). -

    -
    -
    - - -
    -
    - -

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

    -$$ -\delta_j^L = f'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. -$$ -
    -
    - - -
    -
    - -

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,2 \) as

    -$$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l). -$$ -
    -
    - - -
    -
    - -

    Finally, we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,2 \) and update the weights and biases according to the rules

    -$$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, -$$ - - -$$ -b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, -$$ -
    -
    - - -

    The parameter \( \eta \) is the learning parameter discussed in connection with the gradient descent methods. -Here it is convenient to use stochastic gradient descent (see the examples below) with mini-batches with an outer loop that steps through multiple epochs of training. -

    -

      @@ -634,7 +532,7 @@ Here it is convenient to use stochastic gradient descent (see the examples below
    • 96
    • 97
    • ...
    • -
    • 118
    • +
    • 99
    • »
    diff --git a/doc/pub/week42/html/._week42-bs088.html b/doc/pub/week42/html/._week42-bs088.html index e2d8ae55e..587e4a1cf 100644 --- a/doc/pub/week42/html/._week42-bs088.html +++ b/doc/pub/week42/html/._week42-bs088.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,41 +456,54 @@ MathJax.Hub.Config({

     

     

     

    - -

    Setting up a Multi-layer perceptron model for classification

    + +

    Adjust hyperparameters

    -

    We are now gong to develop an example based on the MNIST data -base. This is a classification problem and we need to use our -cross-entropy function we discussed in connection with logistic -regression. The cross-entropy defines our cost function for the -classificaton problems with neural networks. +

    We now perform a grid search to find the optimal hyperparameters for the network. +Note that we are only using 1 layer with 50 neurons, and human performance is estimated to be around \( 98\% \) (\( 2\% \) error rate).

    -

    In binary classification with two classes \( (0, 1) \) we define the -logistic/sigmoid function as the probability that a particular input -is in class \( 0 \) or \( 1 \). This is possible because the logistic -function takes any input from the real numbers and inputs a number -between 0 and 1, and can therefore be interpreted as a probability. It -also has other nice properties, such as a derivative that is simple to -calculate. -

    -

    For an input \( \boldsymbol{a} \) from the hidden layer, the probability that the input \( \boldsymbol{x} \) -is in class 0 or 1 is just. We let \( \theta \) represent the unknown weights and biases to be adjusted by our equations). The variable \( x \) -represents our activation values \( z \). We have -

    -$$ -P(y = 0 \mid \boldsymbol{x}, \boldsymbol{\theta}) = \frac{1}{1 + \exp{(- \boldsymbol{x}})} , -$$ + +
    +
    +
    +
    +
    +
    eta_vals = np.logspace(-5, 1, 7)
    +lmbd_vals = np.logspace(-5, 1, 7)
    +# store the models for later use
    +DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
     
    -

    and

    -$$ -P(y = 1 \mid \boldsymbol{x}, \boldsymbol{\theta}) = 1 - P(y = 0 \mid \boldsymbol{x}, \boldsymbol{\theta}) , -$$ - -

    where \( y \in \{0, 1\} \) and \( \boldsymbol{\theta} \) represents the weights and biases -of our network. -

    +# grid search +for i, eta in enumerate(eta_vals): + for j, lmbd in enumerate(lmbd_vals): + dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size, + n_hidden_neurons=n_hidden_neurons, n_categories=n_categories) + dnn.train() + + DNN_numpy[i][j] = dnn + + test_predict = dnn.predict(X_test) + + print("Learning rate = ", eta) + print("Lambda = ", lmbd) + print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict)) + print() +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -601,7 +531,7 @@ of our network.

  • 97
  • 98
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs089.html b/doc/pub/week42/html/._week42-bs089.html index 26b7532bd..498a32741 100644 --- a/doc/pub/week42/html/._week42-bs089.html +++ b/doc/pub/week42/html/._week42-bs089.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,56 +457,63 @@ MathJax.Hub.Config({

     

     

     

    -

    Defining the cost function

    +

    Visualization

    -

    Our cost function is given as (see the Logistic regression lectures)

    -$$ -\mathcal{C}(\boldsymbol{\theta}) = - \ln P(\mathcal{D} \mid \boldsymbol{\theta}) = - \sum_{i=1}^n -y_i \ln[P(y_i = 0)] + (1 - y_i) \ln [1 - P(y_i = 0)] = \sum_{i=1}^n \mathcal{L}_i(\boldsymbol{\theta}) . -$$ -

    This last equality means that we can interpret our cost function as a sum over the loss function -for each point in the dataset \( \mathcal{L}_i(\boldsymbol{\theta}) \). -The negative sign is just so that we can think about our algorithm as minimizing a positive number, rather -than maximizing a negative number. -

    + +
    +
    +
    +
    +
    +
    # visual representation of grid search
    +# uses seaborn heatmap, you can also do this with matplotlib imshow
    +import seaborn as sns
     
    -

    In multiclass classification it is common to treat each integer label as a so called one-hot vector:

    +sns.set() -

    \( y = 5 \quad \rightarrow \quad \boldsymbol{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) , \) and

    +train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) -\( y = 1 \quad \rightarrow \quad \boldsymbol{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) , \) +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + dnn = DNN_numpy[i][j] + + train_pred = dnn.predict(X_train) + test_pred = dnn.predict(X_test) -

    i.e. a binary bit string of length \( C \), where \( C = 10 \) is the number of classes in the MNIST dataset (numbers from \( 0 \) to \( 9 \))..

    + train_accuracy[i][j] = accuracy_score(Y_train, train_pred) + test_accuracy[i][j] = accuracy_score(Y_test, test_pred) -

    If \( \boldsymbol{x}_i \) is the \( i \)-th input (image), \( y_{ic} \) refers to the \( c \)-th component of the \( i \)-th -output vector \( \boldsymbol{y}_i \). -The probability of \( \boldsymbol{x}_i \) being in class \( c \) will be given by the softmax function: -

    + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Training Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() -$$ -P(y_{ic} = 1 \mid \boldsymbol{x}_i, \boldsymbol{\theta}) = \frac{\exp{((\boldsymbol{a}_i^{hidden})^T \boldsymbol{w}_c)}} -{\sum_{c'=0}^{C-1} \exp{((\boldsymbol{a}_i^{hidden})^T \boldsymbol{w}_{c'})}} , -$$ +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    which reduces to the logistic function in the binary case. -The likelihood of this \( C \)-class classifier -is now given as: -

    - -$$ -P(\mathcal{D} \mid \boldsymbol{\theta}) = \prod_{i=1}^n \prod_{c=0}^{C-1} [P(y_{ic} = 1)]^{y_{ic}} . -$$ - -

    Again we take the negative log-likelihood to define our cost function:

    - -$$ -\mathcal{C}(\boldsymbol{\theta}) = - \log{P(\mathcal{D} \mid \boldsymbol{\theta})}. -$$ - -

    See the logistic regression lectures for a full definition of the cost function.

    - -

    The back propagation equations need now only a small change, namely the definition of a new cost function. We are thus ready to use the same equations as before!

    @@ -615,8 +539,6 @@ $$

  • 97
  • 98
  • 99
  • -
  • ...
  • -
  • 118
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs090.html b/doc/pub/week42/html/._week42-bs090.html index 0661e4cb0..812db220c 100644 --- a/doc/pub/week42/html/._week42-bs090.html +++ b/doc/pub/week42/html/._week42-bs090.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,50 +457,60 @@ MathJax.Hub.Config({

     

     

     

    -

    Example: binary classification problem

    +

    scikit-learn implementation

    -

    As an example of the above, relevant for project 2 as well, let us consider a binary class. As discussed in our logistic regression lectures, we defined a cost function in terms of the parameters \( \beta \) as

    -$$ -\mathcal{C}(\boldsymbol{\beta}) = - \sum_{i=1}^n \left(y_i\log{p(y_i \vert x_i,\boldsymbol{\beta})}+(1-y_i)\log{1-p(y_i \vert x_i,\boldsymbol{\beta})}\right), -$$ - -

    where we had defined the logistic (sigmoid) function

    -$$ -p(y_i =1\vert x_i,\boldsymbol{\beta})=\frac{\exp{(\beta_0+\beta_1 x_i)}}{1+\exp{(\beta_0+\beta_1 x_i)}}, -$$ - -

    and

    -$$ -p(y_i =0\vert x_i,\boldsymbol{\beta})=1-p(y_i =1\vert x_i,\boldsymbol{\beta}). -$$ - -

    The parameters \( \boldsymbol{\beta} \) were defined using a minimization method like gradient descent or Newton-Raphson's method.

    - -

    Now we replace \( x_i \) with the activation \( z_i^l \) for a given layer \( l \) and the outputs as \( y_i=a_i^l=f(z_i^l) \), with \( z_i^l \) now being a function of the weights \( w_{ij}^l \) and biases \( b_i^l \). -We have then +

    scikit-learn focuses more +on traditional machine learning methods, such as regression, +clustering, decision trees, etc. As such, it has only two types of +neural networks: Multi Layer Perceptron outputting continuous values, +MPLRegressor, and Multi Layer Perceptron outputting labels, +MLPClassifier. We will see how simple it is to use these classes.

    -$$ -a_i^l = y_i = \frac{\exp{(z_i^l)}}{1+\exp{(z_i^l)}}, -$$ -

    with

    -$$ -z_i^l = \sum_{j}w_{ij}^l a_j^{l-1}+b_i^l, -$$ - -

    where the superscript \( l-1 \) indicates that these are the outputs from layer \( l-1 \). -Our cost function at the final layer \( l=L \) is now +

    scikit-learn implements a few improvements from our neural network, +such as early stopping, a varying learning rate, different +optimization methods, etc. We would therefore expect a better +performance overall.

    -$$ -\mathcal{C}(\boldsymbol{W}) = - \sum_{i=1}^n \left(t_i\log{a_i^L}+(1-t_i)\log{(1-a_i^L)}\right), -$$ -

    where we have defined the targets \( t_i \). The derivatives of the cost function with respect to the output \( a_i^L \) are then easily calculated and we get

    -$$ -\frac{\partial \mathcal{C}(\boldsymbol{W})}{\partial a_i^L} = \frac{a_i^L-t_i}{a_i^L(1-a_i^L)}. -$$ -

    In case we use another activation function than the logistic one, we need to evaluate other derivatives.

    + +
    +
    +
    +
    +
    +
    from sklearn.neural_network import MLPClassifier
    +# store models for later use
    +DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
    +
    +for i, eta in enumerate(eta_vals):
    +    for j, lmbd in enumerate(lmbd_vals):
    +        dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic',
    +                            alpha=lmbd, learning_rate_init=eta, max_iter=epochs)
    +        dnn.fit(X_train, Y_train)
    +        
    +        DNN_scikit[i][j] = dnn
    +        
    +        print("Learning rate  = ", eta)
    +        print("Lambda = ", lmbd)
    +        print("Accuracy score on test set: ", dnn.score(X_test, Y_test))
    +        print()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -608,9 +535,6 @@ $$

  • 97
  • 98
  • 99
  • -
  • 100
  • -
  • ...
  • -
  • 118
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs091.html b/doc/pub/week42/html/._week42-bs091.html index a88014bcf..f3aaad163 100644 --- a/doc/pub/week42/html/._week42-bs091.html +++ b/doc/pub/week42/html/._week42-bs091.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -540,24 +457,63 @@ MathJax.Hub.Config({

     

     

     

    -

    The Softmax function

    -

    In case we employ the more general case given by the Softmax equation, we need to evaluate the derivative of the activation function with respect to the activation \( z_i^l \), that is we need

    -$$ -\frac{\partial f(z_i^l)}{\partial w_{jk}^l} = -\frac{\partial f(z_i^l)}{\partial z_j^l} \frac{\partial z_j^l}{\partial w_{jk}^l}= \frac{\partial f(z_i^l)}{\partial z_j^l}a_k^{l-1}. -$$ +

    Visualization

    -

    For the Softmax function we have

    -$$ -f(z_i^l) = \frac{\exp{(z_i^l)}}{\sum_{m=1}^K\exp{(z_m^l)}}. -$$ + +
    +
    +
    +
    +
    +
    # optional
    +# visual representation of grid search
    +# uses seaborn heatmap, could probably do this in matplotlib
    +import seaborn as sns
     
    -

    Its derivative with respect to \( z_j^l \) gives

    -$$ -\frac{\partial f(z_i^l)}{\partial z_j^l}= f(z_i^l)\left(\delta_{ij}-f(z_j^l)\right), -$$ +sns.set() + +train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) + +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + dnn = DNN_scikit[i][j] + + train_pred = dnn.predict(X_train) + test_pred = dnn.predict(X_test) + + train_accuracy[i][j] = accuracy_score(Y_train, train_pred) + test_accuracy[i][j] = accuracy_score(Y_test, test_pred) + + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Training Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    which in case of the simply binary model reduces to having \( i=j \).

    @@ -581,10 +537,6 @@ $$

  • 97
  • 98
  • 99
  • -
  • 100
  • -
  • 101
  • -
  • ...
  • -
  • 118
  • »
  • diff --git a/doc/pub/week42/html/._week42-bs092.html b/doc/pub/week42/html/._week42-bs092.html index 073026f78..178749b7f 100644 --- a/doc/pub/week42/html/._week42-bs092.html +++ b/doc/pub/week42/html/._week42-bs092.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -539,19 +456,19 @@ MathJax.Hub.Config({

     

     

     

    - -

    Developing a code for doing neural networks with back propagation

    + +

    Building neural networks in Tensorflow and Keras

    -

    One can identify a set of key steps when using neural networks to solve supervised learning problems:

    +

    Now we want to build on the experience gained from our neural network implementation in NumPy and scikit-learn +and use it to construct a neural network in Tensorflow. Once we have constructed a neural network in NumPy +and Tensorflow, building one in Keras is really quite trivial, though the performance may suffer. +

    + +

    In our previous example we used only one hidden layer, and in this we will use two. From this it should be quite +clear how to build one using an arbitrary number of hidden layers, using data structures such as Python lists or +NumPy arrays. +

    -
      -
    1. Collect and pre-process data
    2. -
    3. Define model and architecture
    4. -
    5. Choose cost function and optimizer
    6. -
    7. Train the model
    8. -
    9. Evaluate model performance on test data
    10. -
    11. Adjust hyperparameters (if necessary, network architecture)
    12. -

    diff --git a/doc/pub/week42/html/week42-bs.html b/doc/pub/week42/html/week42-bs.html index 9992218e0..dddce8a8e 100644 --- a/doc/pub/week42/html/week42-bs.html +++ b/doc/pub/week42/html/week42-bs.html @@ -55,62 +55,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -132,10 +76,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -160,10 +100,6 @@ doconce format html week42.do.txt --html_style=bootstrap --pygments_html_style=d None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -412,123 +348,104 @@ MathJax.Hub.Config({
  • Mathematics of deep learning
  • Reminder on books with hands-on material and codes
  • Reading recommendations
  • -
  • Simpler examples first, and automatic differentiation
  • -
  • Reminder on the chain rule and gradients
  • -
  • Multivariable functions
  • -
  • Automatic differentiation through examples
  • -
  • Simple example
  • -
  • Smarter way of evaluating the above function
  • -
  • Reducing the number of operations
  • -
  • Chain rule, forward and reverse modes
  • -
  • Forward and reverse modes
  • -
  • More complicated function
  • -
  • Counting the number of floating point operations
  • -
  • Defining intermediate operations
  • -
  • New expression for the derivative
  • -
  • Final derivatives
  • -
  • In general not this simple
  • -
  • Automatic differentiation
  • -
  • Chain rule
  • -
  • First network example, simple percepetron with one input
  • -
  • Layout of a simple neural network with no hidden layer
  • -
  • Optimizing the parameters
  • -
  • Adding a hidden layer
  • -
  • Layout of a simple neural network with one hidden layer
  • -
  • The derivatives
  • -
  • Important observations
  • -
  • The training
  • -
  • Code example
  • -
  • Exercise 1: Including more data
  • -
  • Simple neural network and the back propagation equations
  • -
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • -
  • The ouput layer
  • -
  • Compact expressions
  • -
  • Output layer
  • -
  • Explicit derivatives
  • -
  • Derivatives of the hidden layer
  • -
  • Final expression
  • -
  • Completing the list
  • -
  • Final expressions for the biases of the hidden layer
  • -
  • Gradient expressions
  • -
  • Exercise 2: Extended program
  • -
  • Setting up the equations for a neural network
  • -
  • Layout of a neural network with three hidden layers
  • -
  • Definitions
  • -
  • Inputs to the activation function
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • The back propagation equations for a neural network
  • -
  • Analyzing the last results
  • -
  • More considerations
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Using the chain rule and summing over all \( k \) entries
  • -
  • Setting up the back propagation algorithm
  • -
  • Setting up the back propagation algorithm, part 2
  • -
  • Setting up the Back propagation algorithm, part 3
  • -
  • Updating the gradients
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • Fine-tuning neural network hyperparameters
  • -
  • Hidden layers
  • -
  • Vanishing gradients
  • -
  • Exploding gradients
  • -
  • Is the Logistic activation function (Sigmoid) our choice?
  • -
  • Logistic function as the root of problems
  • -
  • The derivative of the Logistic funtion
  • -
  • Insights from the paper by Glorot and Bengio
  • -
  • The RELU function family
  • -
  • ELU function
  • -
  • Which activation function should we use?
  • -
  • More on activation functions, output layers
  • -
  • Batch Normalization
  • -
  • Dropout
  • -
  • Gradient Clipping
  • -
  • A top-down perspective on Neural networks
  • -
  • More top-down perspectives
  • -
  • Limitations of supervised learning with deep networks
  • -
  • Limitations of NNs
  • -
  • Homogeneous data
  • -
  • More limitations
  • -
  • Setting up the back-propagation algorithm
  • -
  • Setting up a Multi-layer perceptron model for classification
  • -
  • Defining the cost function
  • -
  • Example: binary classification problem
  • -
  • The Softmax function
  • -
  • Developing a code for doing neural networks with back propagation
  • -
  • Collect and pre-process data
  • -
  • Train and test datasets
  • -
  • Define model and architecture
  • -
  • Layers
  • -
  • Weights and biases
  • -
  • Feed-forward pass
  • -
  • Matrix multiplications
  • -
  • Choose cost function and optimizer
  • -
  • Optimizing the cost function
  • -
  • Regularization
  • -
  • Matrix multiplication
  • -
  • Improving performance
  • -
  • Full object-oriented implementation
  • -
  • Evaluate model performance on test data
  • -
  • Adjust hyperparameters
  • -
  • Visualization
  • -
  • scikit-learn implementation
  • -
  • Visualization
  • -
  • Building neural networks in Tensorflow and Keras
  • -
  • Tensorflow
  • -
  • Using Keras
  • -
  • Collect and pre-process data
  • -
  • The Breast Cancer Data, now with Keras
  • -
  • Building a neural network code
  • -
  •    Learning rate methods
  • -
  •    Usage of the above learning rate schedulers
  • -
  •    Cost functions
  • -
  •    Activation functions
  • -
  •    The Neural Network
  • -
  •    Multiclass classification
  • -
  • Testing the XOR gate and other gates
  • +
  • First network example, simple percepetron with one input
  • +
  • Layout of a simple neural network with no hidden layer
  • +
  • Optimizing the parameters
  • +
  • Adding a hidden layer
  • +
  • Layout of a simple neural network with one hidden layer
  • +
  • The derivatives
  • +
  • Important observations
  • +
  • The training
  • +
  • Code example
  • +
  • Simple neural network and the back propagation equations
  • +
  • Layout of a simple neural network with two input nodes, one hidden layer and one output node
  • +
  • The ouput layer
  • +
  • Compact expressions
  • +
  • Output layer
  • +
  • Explicit derivatives
  • +
  • Derivatives of the hidden layer
  • +
  • Final expression
  • +
  • Completing the list
  • +
  • Final expressions for the biases of the hidden layer
  • +
  • Gradient expressions
  • +
  • Setting up the equations for a neural network
  • +
  • Layout of a neural network with three hidden layers
  • +
  • Definitions
  • +
  • Inputs to the activation function
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • The back propagation equations for a neural network
  • +
  • Analyzing the last results
  • +
  • More considerations
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Using the chain rule and summing over all \( k \) entries
  • +
  • Setting up the back propagation algorithm
  • +
  • Setting up the back propagation algorithm, part 2
  • +
  • Setting up the Back propagation algorithm, part 3
  • +
  • Updating the gradients
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • Fine-tuning neural network hyperparameters
  • +
  • Hidden layers
  • +
  • Vanishing gradients
  • +
  • Exploding gradients
  • +
  • Is the Logistic activation function (Sigmoid) our choice?
  • +
  • Logistic function as the root of problems
  • +
  • The derivative of the Logistic funtion
  • +
  • Insights from the paper by Glorot and Bengio
  • +
  • The RELU function family
  • +
  • ELU function
  • +
  • Which activation function should we use?
  • +
  • More on activation functions, output layers
  • +
  • Batch Normalization
  • +
  • Dropout
  • +
  • Gradient Clipping
  • +
  • A top-down perspective on Neural networks
  • +
  • More top-down perspectives
  • +
  • Limitations of supervised learning with deep networks
  • +
  • Limitations of NNs
  • +
  • Homogeneous data
  • +
  • More limitations
  • +
  • Setting up the back-propagation algorithm
  • +
  • Setting up a Multi-layer perceptron model for classification
  • +
  • Defining the cost function
  • +
  • Example: binary classification problem
  • +
  • The Softmax function
  • +
  • Developing a code for doing neural networks with back propagation
  • +
  • Collect and pre-process data
  • +
  • Train and test datasets
  • +
  • Define model and architecture
  • +
  • Layers
  • +
  • Weights and biases
  • +
  • Feed-forward pass
  • +
  • Matrix multiplications
  • +
  • Choose cost function and optimizer
  • +
  • Optimizing the cost function
  • +
  • Regularization
  • +
  • Matrix multiplication
  • +
  • Improving performance
  • +
  • Full object-oriented implementation
  • +
  • Evaluate model performance on test data
  • +
  • Adjust hyperparameters
  • +
  • Visualization
  • +
  • scikit-learn implementation
  • +
  • Visualization
  • +
  • Building neural networks in Tensorflow and Keras
  • +
  • Tensorflow
  • +
  • Using Keras
  • +
  • Collect and pre-process data
  • +
  • The Breast Cancer Data, now with Keras
  • +
  • Building a neural network code
  • +
  •    Learning rate methods
  • +
  •    Usage of the above learning rate schedulers
  • +
  •    Cost functions
  • +
  •    Activation functions
  • +
  •    The Neural Network
  • +
  •    Multiclass classification
  • +
  • Testing the XOR gate and other gates
  • @@ -583,7 +500,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 118
  • +
  • 99
  • »
  • diff --git a/doc/pub/week42/html/week42-reveal.html b/doc/pub/week42/html/week42-reveal.html index 3e02ea1c4..4ff08534e 100644 --- a/doc/pub/week42/html/week42-reveal.html +++ b/doc/pub/week42/html/week42-reveal.html @@ -201,19 +201,22 @@ MathJax.Hub.Config({

    1. Building our own Feed-forward Neural Network and discussion of project 2
    2. -

    3. Readings and Videos: -
        -

      1. These lecture notes +
      +
    + +
    +Readings and videos +

    +

      +

    1. These lecture notes
    2. -

    3. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
    4. +

    5. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
    6. Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
    7. -

    8. Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
    9. -

    10. Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
    11. -

    12. Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
    13. -
    -

    +

  • Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
  • +

  • Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
  • +

  • Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
  • I also recommend Michael Nielsen's intuitive approach to the neural networks and the universal approximation theorem, see the slides at http://neuralnetworksanddeeplearning.com/chap4.html.

    @@ -232,6 +235,8 @@ MathJax.Hub.Config({

  • Discussion of project 2
  • + +

    Note: some of the codes will also be discussed next week in connection with the solution of differential equations.

    @@ -240,7 +245,7 @@ MathJax.Hub.Config({

    Last week we discussed the basics of neural networks and deep learning and the basics of automatic differentiation. We looked also at examples on how compute the parameters of a simple network with scalar -inputs and ouputs and no or just one hiden layers. +inputs and ouputs and no or just one hidden layers.

    We ended our discussions with the derivation of the equations for a @@ -282,474 +287,6 @@ hidden nodes but only one output node.

    -
    -

    Simpler examples first, and automatic differentiation

    - -

    In order to understand the back propagation algorithm and its -derivation (an implementation of the chain rule), let us first digress -with some simple examples. These examples are also meant to motivate -the link with back propagation and automatic differentiation. -

    -
    - -
    -

    Reminder on the chain rule and gradients

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t) \) and \( y=y(t) \) are functions of a variable \( t \), we have that the gradient of \( f \) with respect to \( t \) (without the explicit unit vector components)

    -

     
    -$$ -\frac{df}{dt} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial t} \end{bmatrix}=\frac{\partial f}{\partial x} \frac{\partial x}{\partial t} +\frac{\partial f}{\partial y} \frac{\partial y}{\partial t}. -$$ -

     
    -

    - -
    -

    Multivariable functions

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t,s) \) and \( y=y(t,s) \) are functions of the variables \( t \) and \( s \), we have that the partial derivatives

    -

     
    -$$ -\frac{\partial f}{\partial s}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial s}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial s}, -$$ -

     
    - -

    and

    -

     
    -$$ -\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}. -$$ -

     
    - -

    the gradient of \( f \) with respect to \( t \) and \( s \) (without the explicit unit vector components)

    -

     
    -$$ -\frac{df}{d(s,t)} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial s} &\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial s} & \frac{\partial y}{\partial t} \end{bmatrix}. -$$ -

     
    -

    - -
    -

    Automatic differentiation through examples

    - -

    A great introduction to automatic differentiation is given by Baydin et al., see https://arxiv.org/abs/1502.05767.

    - -

    Automatic differentiation is a represented by a repeated application -of the chain rule on well-known functions and allows for the -calculation of derivatives to numerical precision. It is not the same -as the calculation of symbolic derivatives via for example SymPy, nor -does it use approximative formulae based on Taylor-expansions of a -function around a given value. The latter are error prone due to -truncation errors and values of the step size \( \Delta \). -

    -
    - -
    -

    Simple example

    - -

    Our first example is rather simple,

    -

     
    -$$ -f(x) =\exp{x^2}, -$$ -

     
    - -

    with derivative

    -

     
    -$$ -f'(x) =2x\exp{x^2}. -$$ -

     
    - -

    We can use SymPy to extract the pertinent lines of Python code through the following simple example

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = exp(x*x)
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Smarter way of evaluating the above function

    -

    If we study this function, we note that we can reduce the number of operations by introducing an intermediate variable

    -

     
    -$$ -a = x^2, -$$ -

     
    - -

    leading to

    -

     
    -$$ -f(x) = f(a(x)) = b= \exp{a}. -$$ -

     
    - -

    We now assume that all operations can be counted in terms of equal -floating point operations. This means that in order to calculate -\( f(x) \) we need first to square \( x \) and then compute the exponential. We -have thus two floating point operations only. -

    -
    - -
    -

    Reducing the number of operations

    - -

    With the introduction of a precalculated quantity \( a \) and thereby \( f(x) \) we have that the derivative can be written as

    - -

     
    -$$ -f'(x) = 2xb, -$$ -

     
    - -

    which reduces the number of operations from four in the orginal -expression to two. This means that if we need to compute \( f(x) \) and -its derivative (a common task in optimizations), we have reduced the -number of operations from six to four in total. -

    - -

    Note that the usage of a symbolic software like SymPy does not -include such simplifications and the calculations of the function and -the derivatives yield in general more floating point operations. -

    -
    - -
    -

    Chain rule, forward and reverse modes

    - -

    In the above example we have introduced the variables \( a \) and \( b \), and our function is

    -

     
    -$$ -f(x) = f(a(x)) = b= \exp{a}, -$$ -

     
    - -

    with \( a=x^2 \). We can decompose the derivative of \( f \) with respect to \( x \) as

    -

     
    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}. -$$ -

     
    - -

    We note that since \( b=f(x) \) that

    -

     
    -$$ -\frac{df}{db}=1, -$$ -

     
    - -

    leading to

    -

     
    -$$ -\frac{df}{dx}=\frac{db}{da}\frac{da}{dx}=2x\exp{x^2}, -$$ -

     
    - -

    as before.

    -
    - -
    -

    Forward and reverse modes

    - -

    We have that

    -

     
    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}, -$$ -

     
    - -

    which we can rewrite either as

    -

     
    -$$ -\frac{df}{dx}=\left[\frac{df}{db}\frac{db}{da}\right]\frac{da}{dx}, -$$ -

     
    - -

    or

    -

     
    -$$ -\frac{df}{dx}=\frac{df}{db}\left[\frac{db}{da}\frac{da}{dx}\right]. -$$ -

     
    - -

    The first expression is called reverse mode (or back propagation) -since we start by evaluating the derivatives at the end point and then -propagate backwards. This is the standard way of evaluating -derivatives (gradients) when optimizing the parameters of a neural -network. In the context of deep learning this is computationally -more efficient since the output of a neural network consists of either -one or some few other output variables. -

    - -

    The second equation defines the so-called forward mode.

    -
    - -
    -

    More complicated function

    - -

    We increase our ambitions and introduce a slightly more complicated function

    -

     
    -$$ -f(x) =\sqrt{x^2+exp{x^2}}, -$$ -

     
    - -

    with derivative

    -

     
    -$$ -f'(x) =\frac{x(1+\exp{x^2})}{\sqrt{x^2+exp{x^2}}}. -$$ -

     
    - -

    The corresponding SymPy code reads

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = sqrt(x*x+exp(x*x))
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Counting the number of floating point operations

    - -

    A simple count of operations shows that we need five operations for -the function itself and ten for the derivative. Fifteen operations in total if we wish to proceed with the above codes. -

    - -

    Can we reduce this to -say half the number of operations? -

    -
    - -
    -

    Defining intermediate operations

    - -

    We can indeed reduce the number of operation to half of those listed in the brute force approach above. -We define the following quantities -

    -

     
    -$$ -a = x^2, -$$ -

     
    - -

    and

    -

     
    -$$ -b = \exp{x^2} = \exp{a}, -$$ -

     
    - -

    and

    -

     
    -$$ -c= a+b, -$$ -

     
    - -

    and

    -

     
    -$$ -d=f(x)=\sqrt{c}. -$$ -

     
    -

    - -
    -

    New expression for the derivative

    - -

    With these definitions we obtain the following partial derivatives

    -

     
    -$$ -\frac{\partial a}{\partial x} = 2x, -$$ -

     
    - -

    and

    -

     
    -$$ -\frac{\partial b}{\partial a} = \exp{a}, -$$ -

     
    - -

    and

    -

     
    -$$ -\frac{\partial c}{\partial a} = 1, -$$ -

     
    - -

    and

    -

     
    -$$ -\frac{\partial c}{\partial b} = 1, -$$ -

     
    - -

    and

    -

     
    -$$ -\frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ -

     
    - -

    and finally

    -

     
    -$$ -\frac{\partial f}{\partial d} = 1. -$$ -

     
    -

    - -
    -

    Final derivatives

    -

    Our final derivatives are thus

    -

     
    -$$ -\frac{\partial f}{\partial c} = \frac{\partial f}{\partial d} \frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ -

     
    - -

     
    -$$ -\frac{\partial f}{\partial b} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial b} = \frac{1}{2\sqrt{c}}, -$$ -

     
    - -

     
    -$$ -\frac{\partial f}{\partial a} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial a}+ -\frac{\partial f}{\partial b} \frac{\partial b}{\partial a} = \frac{1+\exp{a}}{2\sqrt{c}}, -$$ -

     
    - -

    and finally

    -

     
    -$$ -\frac{\partial f}{\partial x} = \frac{\partial f}{\partial a} \frac{\partial a}{\partial x} = \frac{x(1+\exp{a})}{\sqrt{c}}, -$$ -

     
    - -

    which is just

    -

     
    -$$ -\frac{\partial f}{\partial x} = \frac{x(1+b)}{d}, -$$ -

     
    - -

    and requires only three operations if we can reuse all intermediate variables.

    -
    - -
    -

    In general not this simple

    - -

    In general, see the generalization below, unless we can obtain simple -analytical expressions which we can simplify further, the final -implementation of automatic differentiation involves repeated -calculations (and thereby operations) of derivatives of elementary -functions. -

    -
    - -
    -

    Automatic differentiation

    - -

    We can make this example more formal. Automatic differentiation is a -formalization of the previous example (see graph). -

    - -

    We define \( \boldsymbol{x}\in x_1,\dots, x_l \) input variables to a given function \( f(\boldsymbol{x}) \) and \( x_{l+1},\dots, x_L \) intermediate variables.

    - -

    In the above example we have only one input variable, \( l=1 \) and four intermediate variables, that is

    -

     
    -$$ -\begin{bmatrix} x_1=x & x_2 = x^2=a & x_3 =\exp{a}= b & x_4=c=a+b & x_5 = \sqrt{c}=d \end{bmatrix}. -$$ -

     
    - -

    Furthemore, for \( i=l+1, \dots, L \) (here \( i=2,3,4,5 \) and \( f=x_L=d \)), we -define the elementary functions \( g_i(x_{Pa(x_i)}) \) where \( x_{Pa(x_i)} \) are the parent nodes of the variable \( x_i \). -

    - -

    In our case, we have for example for \( x_3=g_3(x_{Pa(x_i)})=\exp{a} \), that \( g_3=\exp{()} \) and \( x_{Pa(x_3)}=a \).

    -
    - -
    -

    Chain rule

    - -

    We can now compute the gradients by back-propagating the derivatives using the chain rule. -We have defined -

    -

     
    -$$ -\frac{\partial f}{\partial x_L} = 1, -$$ -

     
    - -

    which allows us to find the derivatives of the various variables \( x_i \) as

    -

     
    -$$ -\frac{\partial f}{\partial x_i} = \sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial x_j}{\partial x_i}=\sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial g_j}{\partial x_i}. -$$ -

     
    - -

    Whenever we have a function which can be expressed as a computation -graph and the various functions can be expressed in terms of -elementary functions that are differentiable, then automatic -differentiation works. The functions may not need to be elementary -functions, they could also be computer programs, although not all -programs can be automatically differentiated. -

    -
    -

    First network example, simple percepetron with one input

    @@ -1038,23 +575,6 @@ eta = 0.1

    We see that after some few iterations (the results do depend on the learning rate however), we get an error which is rather small.

    -
    - - -

    Exercise 1: Including more data

    - -

    Try to increase the amount of input and -target/output data. Try also to perform calculations for more values -of the learning rates. Feel free to add either hyperparameters with an -\( l_1 \) norm or an \( l_2 \) norm and discuss your results. -Discuss your results as functions of the amount of training data and various learning rates. -

    - -

    Challenge: Try to change the activation functions and replace the hard-coded analytical expressions with automatic derivation via either autograd or JAX.

    - - -
    -

    Simple neural network and the back propagation equations

    @@ -1118,7 +638,7 @@ The inputs to the first hidden layer are

     
    $$ -\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, +\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\left(\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\right)^{T}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, $$

     
    @@ -1310,34 +830,6 @@ $$

    where \( \eta \) is the learning rate.

    -
    - - -

    Exercise 2: Extended program

    - -

    We extend our simple code to a function which depends on two variable \( x_0 \) and \( x_1 \), that is

    -

     
    -$$ -y=f(x_0,x_1)=x_0^2+3x_0x_1+x_1^2+5. -$$ -

     
    - -

    We feed our network with \( n=100 \) entries \( x_0 \) and \( x_1 \). We have thus two features represented by these variable and an input matrix/design matrix \( \boldsymbol{X}\in \mathbf{R}^{n\times 2} \)

    -

     
    -$$ -\boldsymbol{X}=\begin{bmatrix} x_{00} & x_{01} \\ x_{00} & x_{01} \\ x_{10} & x_{11} \\ x_{20} & x_{21} \\ \dots & \dots \\ \dots & \dots \\ x_{n-20} & x_{n-21} \\ x_{n-10} & x_{n-11} \end{bmatrix}. -$$ -

     
    - -

    Write a code, based on the previous code examples, which takes as input these data and fit the above function. -You can extend your code to include automatic differentiation. -

    - -

    With these examples, we are now ready to embark upon the writing of more a general code for neural networks.

    - - -
    -

    Setting up the equations for a neural network

    @@ -1380,7 +872,7 @@ network \( \boldsymbol{\tilde{y}} \) and the inputs \( \boldsymbol{x} \) we define now the activation \( z_j^l \) of node/neuron/unit \( j \) of the \( l \)-th layer as a function of the bias, the weights which add up from the previous layer \( l-1 \) and the forward passes/outputs -\( \hat{a}^{l-1} \) from the previous layer as +\( \boldsymbol{a}^{l-1} \) from the previous layer as

     
    @@ -1397,7 +889,7 @@ compact form as the matrix-vector products we discussed earlier,

     
    $$ -\hat{z}^l = \left(\hat{W}^l\right)^T\hat{a}^{l-1}+\hat{b}^l. +\boldsymbol{z}^l = \left(\boldsymbol{W}^l\right)^T\boldsymbol{a}^{l-1}+\boldsymbol{b}^l. $$

     

    @@ -1406,9 +898,9 @@ $$

    Inputs to the activation function

    With the activation values \( \boldsymbol{z}^l \) we can in turn define the -output of layer \( l \) as \( \boldsymbol{a}^l = f(\boldsymbol{z}^l) \) where \( f \) is our +output of layer \( l \) as \( \boldsymbol{a}^l = \sigma(\boldsymbol{z}^l) \) where \( \sigma \) is our activation function. In the examples here we will use the sigmoid -function discussed in our logistic regression lectures. We will also use the same activation function \( f \) for all layers +function discussed in our logistic regression lectures. We will also use the same activation function \( \sigma \) for all layers and their nodes. It means we have

    @@ -1422,7 +914,7 @@ $$

    Derivatives and the chain rule

    -

    From the definition of the activation \( z_j^l \) we have

    +

    From the definition of the input variable to the activation function, that is \( z_j^l \) we have

     
    $$ \frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, @@ -1460,14 +952,14 @@ $$

     
    $$ -\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{L}}, +\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{ij}^{L}}, $$

     

    The last partial derivative can easily be computed and reads (by applying the chain rule)

     
    $$ -\frac{\partial a_j^L}{\partial w_{jk}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{jk}^{L}}=a_j^L(1-a_j^L)a_k^{L-1}. +\frac{\partial a_j^L}{\partial w_{ij}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{ij}^{L}}=a_j^L(1-a_j^L)a_i^{L-1}. $$

     

    @@ -1478,7 +970,7 @@ $$

    We have thus

     
    $$ -\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_k^{L-1}, +\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_i^{L-1}, $$

     
    @@ -1492,7 +984,7 @@ $$

    and using the Hadamard product of two vectors we can write this as

     
    $$ -\boldsymbol{\delta}^L = \sigma'(\hat{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. +\boldsymbol{\delta}^L = \sigma'(\boldsymbol{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. $$

     
    @@ -1531,7 +1023,7 @@ $$

    With the definition of \( \delta_j^L \) we have a more compact definition of the derivative of the cost function in terms of the weights, namely

     
    $$ -\frac{\partial{\cal C}}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +\frac{\partial{\cal C}}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}. $$

     
    @@ -1565,7 +1057,7 @@ $$

     
    $$ \begin{equation} -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}, +\frac{\partial{\cal C}(\boldsymbol{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, \tag{1} \end{equation} $$ @@ -1640,14 +1132,14 @@ $$

    The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.

    -

    First, we set up the input data \( \hat{x} \) and the activations -\( \hat{z}_1 \) of the input layer and compute the activation function and -the pertinent outputs \( \hat{a}^1 \). +

    First, we set up the input data \( \boldsymbol{x} \) and the activations +\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and +the pertinent outputs \( \boldsymbol{a}^1 \).

    Secondly, we perform then the feed forward till we reach the output -layer and compute all \( \hat{z}_l \) of the input layer and compute the -activation function and the pertinent outputs \( \hat{a}^l \) for +layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the +activation function and the pertinent outputs \( \boldsymbol{a}^l \) for \( l=1,2,3,\dots,L \).

    @@ -1657,7 +1149,7 @@ activation function and the pertinent outputs \( \hat{a}^l \) for

    Setting up the back propagation algorithm, part 2

    -

    Thereafter we compute the ouput error \( \hat{\delta}^L \) by computing all

    +

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

     
    $$ \delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. @@ -1676,13 +1168,13 @@ $$

    Setting up the Back propagation algorithm, part 3

    Finally, we update the weights and the biases using gradient descent -for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases +for each \( l=L-1,L-2,\dots,1 \) (the first hidden layer) and update the weights and biases according to the rules

     
    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$

     
    @@ -1701,14 +1193,14 @@ $$

    With the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

     
    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l), +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), $$

     

    we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases according to the rules

     
    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$

     
    @@ -1756,14 +1248,14 @@ functions Typical examples are the logistic Sigmoid

     
    $$ - f(x) = \frac{1}{1 + e^{-x}}, + \sigma(x) = \frac{1}{1 + e^{-x}}, $$

     

    and the hyperbolic tangent function

     
    $$ - f(x) = \tanh(x) + \sigma(x) = \tanh(x) $$

     

    @@ -2280,7 +1772,7 @@ $$

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,2 \) as

     
    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l). +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). $$

     

    @@ -2292,7 +1784,7 @@ $$

    Finally, we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,2 \) and update the weights and biases according to the rules

     
    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$

     
    diff --git a/doc/pub/week42/html/week42-solarized.html b/doc/pub/week42/html/week42-solarized.html index b3c730694..100d78c42 100644 --- a/doc/pub/week42/html/week42-solarized.html +++ b/doc/pub/week42/html/week42-solarized.html @@ -82,62 +82,6 @@ div.toc p,a { None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -159,10 +103,6 @@ div.toc p,a { ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -187,10 +127,6 @@ div.toc p,a { None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -447,17 +383,21 @@ MathJax.Hub.Config({

    1. Building our own Feed-forward Neural Network and discussion of project 2
    2. -
    3. Readings and Videos: -
        -
      1. These lecture notes +
      +
    + +
    +Readings and videos +

    +

      +
    1. These lecture notes
    2. -
    3. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
    4. -
    5. Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
    6. -
    7. Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
    8. -
    9. Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
    10. -
    11. Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
    12. -
    +
  • For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
  • +
  • Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
  • +
  • Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
  • +
  • Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
  • +
  • Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
  • I also recommend Michael Nielsen's intuitive approach to the neural networks and the universal approximation theorem, see the slides at http://neuralnetworksanddeeplearning.com/chap4.html.

    @@ -473,7 +413,9 @@ MathJax.Hub.Config({
  • Discussion of project 2
  • - + + +

    Note: some of the codes will also be discussed next week in connection with the solution of differential equations.











    Writing a code which implements a feed-forward neural network

    @@ -481,7 +423,7 @@ MathJax.Hub.Config({

    Last week we discussed the basics of neural networks and deep learning and the basics of automatic differentiation. We looked also at examples on how compute the parameters of a simple network with scalar -inputs and ouputs and no or just one hiden layers. +inputs and ouputs and no or just one hidden layers.

    We ended our discussions with the derivation of the equations for a @@ -520,391 +462,6 @@ hidden nodes but only one output node.

  • Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub
  • Goodfellow et al, chapter 6 and 7 contain most of the neural network background.
  • -









    -

    Simpler examples first, and automatic differentiation

    - -

    In order to understand the back propagation algorithm and its -derivation (an implementation of the chain rule), let us first digress -with some simple examples. These examples are also meant to motivate -the link with back propagation and automatic differentiation. -

    - -









    -

    Reminder on the chain rule and gradients

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t) \) and \( y=y(t) \) are functions of a variable \( t \), we have that the gradient of \( f \) with respect to \( t \) (without the explicit unit vector components)

    -$$ -\frac{df}{dt} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial t} \end{bmatrix}=\frac{\partial f}{\partial x} \frac{\partial x}{\partial t} +\frac{\partial f}{\partial y} \frac{\partial y}{\partial t}. -$$ - - -









    -

    Multivariable functions

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t,s) \) and \( y=y(t,s) \) are functions of the variables \( t \) and \( s \), we have that the partial derivatives

    -$$ -\frac{\partial f}{\partial s}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial s}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial s}, -$$ - -

    and

    -$$ -\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}. -$$ - -

    the gradient of \( f \) with respect to \( t \) and \( s \) (without the explicit unit vector components)

    -$$ -\frac{df}{d(s,t)} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial s} &\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial s} & \frac{\partial y}{\partial t} \end{bmatrix}. -$$ - - -









    -

    Automatic differentiation through examples

    - -

    A great introduction to automatic differentiation is given by Baydin et al., see https://arxiv.org/abs/1502.05767.

    - -

    Automatic differentiation is a represented by a repeated application -of the chain rule on well-known functions and allows for the -calculation of derivatives to numerical precision. It is not the same -as the calculation of symbolic derivatives via for example SymPy, nor -does it use approximative formulae based on Taylor-expansions of a -function around a given value. The latter are error prone due to -truncation errors and values of the step size \( \Delta \). -

    - -









    -

    Simple example

    - -

    Our first example is rather simple,

    -$$ -f(x) =\exp{x^2}, -$$ - -

    with derivative

    -$$ -f'(x) =2x\exp{x^2}. -$$ - -

    We can use SymPy to extract the pertinent lines of Python code through the following simple example

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = exp(x*x)
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Smarter way of evaluating the above function

    -

    If we study this function, we note that we can reduce the number of operations by introducing an intermediate variable

    -$$ -a = x^2, -$$ - -

    leading to

    -$$ -f(x) = f(a(x)) = b= \exp{a}. -$$ - -

    We now assume that all operations can be counted in terms of equal -floating point operations. This means that in order to calculate -\( f(x) \) we need first to square \( x \) and then compute the exponential. We -have thus two floating point operations only. -

    - -









    -

    Reducing the number of operations

    - -

    With the introduction of a precalculated quantity \( a \) and thereby \( f(x) \) we have that the derivative can be written as

    - -$$ -f'(x) = 2xb, -$$ - -

    which reduces the number of operations from four in the orginal -expression to two. This means that if we need to compute \( f(x) \) and -its derivative (a common task in optimizations), we have reduced the -number of operations from six to four in total. -

    - -

    Note that the usage of a symbolic software like SymPy does not -include such simplifications and the calculations of the function and -the derivatives yield in general more floating point operations. -

    - -









    -

    Chain rule, forward and reverse modes

    - -

    In the above example we have introduced the variables \( a \) and \( b \), and our function is

    -$$ -f(x) = f(a(x)) = b= \exp{a}, -$$ - -

    with \( a=x^2 \). We can decompose the derivative of \( f \) with respect to \( x \) as

    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}. -$$ - -

    We note that since \( b=f(x) \) that

    -$$ -\frac{df}{db}=1, -$$ - -

    leading to

    -$$ -\frac{df}{dx}=\frac{db}{da}\frac{da}{dx}=2x\exp{x^2}, -$$ - -

    as before.

    - -









    -

    Forward and reverse modes

    - -

    We have that

    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}, -$$ - -

    which we can rewrite either as

    -$$ -\frac{df}{dx}=\left[\frac{df}{db}\frac{db}{da}\right]\frac{da}{dx}, -$$ - -

    or

    -$$ -\frac{df}{dx}=\frac{df}{db}\left[\frac{db}{da}\frac{da}{dx}\right]. -$$ - -

    The first expression is called reverse mode (or back propagation) -since we start by evaluating the derivatives at the end point and then -propagate backwards. This is the standard way of evaluating -derivatives (gradients) when optimizing the parameters of a neural -network. In the context of deep learning this is computationally -more efficient since the output of a neural network consists of either -one or some few other output variables. -

    - -

    The second equation defines the so-called forward mode.

    - -









    -

    More complicated function

    - -

    We increase our ambitions and introduce a slightly more complicated function

    -$$ -f(x) =\sqrt{x^2+exp{x^2}}, -$$ - -

    with derivative

    -$$ -f'(x) =\frac{x(1+\exp{x^2})}{\sqrt{x^2+exp{x^2}}}. -$$ - -

    The corresponding SymPy code reads

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = sqrt(x*x+exp(x*x))
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Counting the number of floating point operations

    - -

    A simple count of operations shows that we need five operations for -the function itself and ten for the derivative. Fifteen operations in total if we wish to proceed with the above codes. -

    - -

    Can we reduce this to -say half the number of operations? -

    - -









    -

    Defining intermediate operations

    - -

    We can indeed reduce the number of operation to half of those listed in the brute force approach above. -We define the following quantities -

    -$$ -a = x^2, -$$ - -

    and

    -$$ -b = \exp{x^2} = \exp{a}, -$$ - -

    and

    -$$ -c= a+b, -$$ - -

    and

    -$$ -d=f(x)=\sqrt{c}. -$$ - - -









    -

    New expression for the derivative

    - -

    With these definitions we obtain the following partial derivatives

    -$$ -\frac{\partial a}{\partial x} = 2x, -$$ - -

    and

    -$$ -\frac{\partial b}{\partial a} = \exp{a}, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial a} = 1, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial b} = 1, -$$ - -

    and

    -$$ -\frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial d} = 1. -$$ - - -









    -

    Final derivatives

    -

    Our final derivatives are thus

    -$$ -\frac{\partial f}{\partial c} = \frac{\partial f}{\partial d} \frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ - -$$ -\frac{\partial f}{\partial b} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial b} = \frac{1}{2\sqrt{c}}, -$$ - -$$ -\frac{\partial f}{\partial a} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial a}+ -\frac{\partial f}{\partial b} \frac{\partial b}{\partial a} = \frac{1+\exp{a}}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial x} = \frac{\partial f}{\partial a} \frac{\partial a}{\partial x} = \frac{x(1+\exp{a})}{\sqrt{c}}, -$$ - -

    which is just

    -$$ -\frac{\partial f}{\partial x} = \frac{x(1+b)}{d}, -$$ - -

    and requires only three operations if we can reuse all intermediate variables.

    - -









    -

    In general not this simple

    - -

    In general, see the generalization below, unless we can obtain simple -analytical expressions which we can simplify further, the final -implementation of automatic differentiation involves repeated -calculations (and thereby operations) of derivatives of elementary -functions. -

    - -









    -

    Automatic differentiation

    - -

    We can make this example more formal. Automatic differentiation is a -formalization of the previous example (see graph). -

    - -

    We define \( \boldsymbol{x}\in x_1,\dots, x_l \) input variables to a given function \( f(\boldsymbol{x}) \) and \( x_{l+1},\dots, x_L \) intermediate variables.

    - -

    In the above example we have only one input variable, \( l=1 \) and four intermediate variables, that is

    -$$ -\begin{bmatrix} x_1=x & x_2 = x^2=a & x_3 =\exp{a}= b & x_4=c=a+b & x_5 = \sqrt{c}=d \end{bmatrix}. -$$ - -

    Furthemore, for \( i=l+1, \dots, L \) (here \( i=2,3,4,5 \) and \( f=x_L=d \)), we -define the elementary functions \( g_i(x_{Pa(x_i)}) \) where \( x_{Pa(x_i)} \) are the parent nodes of the variable \( x_i \). -

    - -

    In our case, we have for example for \( x_3=g_3(x_{Pa(x_i)})=\exp{a} \), that \( g_3=\exp{()} \) and \( x_{Pa(x_3)}=a \).

    - -









    -

    Chain rule

    - -

    We can now compute the gradients by back-propagating the derivatives using the chain rule. -We have defined -

    -$$ -\frac{\partial f}{\partial x_L} = 1, -$$ - -

    which allows us to find the derivatives of the various variables \( x_i \) as

    -$$ -\frac{\partial f}{\partial x_i} = \sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial x_j}{\partial x_i}=\sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial g_j}{\partial x_i}. -$$ - -

    Whenever we have a function which can be expressed as a computation -graph and the various functions can be expressed in terms of -elementary functions that are differentiable, then automatic -differentiation works. The functions may not need to be elementary -functions, they could also be computer programs, although not all -programs can be automatically differentiated. -

    -









    First network example, simple percepetron with one input

    @@ -1157,22 +714,6 @@ eta = 0.1

    We see that after some few iterations (the results do depend on the learning rate however), we get an error which is rather small.

    -









    - - -

    Exercise 1: Including more data

    - -

    Try to increase the amount of input and -target/output data. Try also to perform calculations for more values -of the learning rates. Feel free to add either hyperparameters with an -\( l_1 \) norm or an \( l_2 \) norm and discuss your results. -Discuss your results as functions of the amount of training data and various learning rates. -

    - -

    Challenge: Try to change the activation functions and replace the hard-coded analytical expressions with automatic derivation via either autograd or JAX.

    - - -









    Simple neural network and the back propagation equations

    @@ -1226,7 +767,7 @@ $$ The inputs to the first hidden layer are

    $$ -\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, +\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\left(\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\right)^{T}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, $$

    with outputs

    @@ -1373,29 +914,6 @@ $$

    where \( \eta \) is the learning rate.

    -









    - - -

    Exercise 2: Extended program

    - -

    We extend our simple code to a function which depends on two variable \( x_0 \) and \( x_1 \), that is

    -$$ -y=f(x_0,x_1)=x_0^2+3x_0x_1+x_1^2+5. -$$ - -

    We feed our network with \( n=100 \) entries \( x_0 \) and \( x_1 \). We have thus two features represented by these variable and an input matrix/design matrix \( \boldsymbol{X}\in \mathbf{R}^{n\times 2} \)

    -$$ -\boldsymbol{X}=\begin{bmatrix} x_{00} & x_{01} \\ x_{00} & x_{01} \\ x_{10} & x_{11} \\ x_{20} & x_{21} \\ \dots & \dots \\ \dots & \dots \\ x_{n-20} & x_{n-21} \\ x_{n-10} & x_{n-11} \end{bmatrix}. -$$ - -

    Write a code, based on the previous code examples, which takes as input these data and fit the above function. -You can extend your code to include automatic differentiation. -

    - -

    With these examples, we are now ready to embark upon the writing of more a general code for neural networks.

    - - -









    Setting up the equations for a neural network

    @@ -1434,7 +952,7 @@ network \( \boldsymbol{\tilde{y}} \) and the inputs \( \boldsymbol{x} \) we define now the activation \( z_j^l \) of node/neuron/unit \( j \) of the \( l \)-th layer as a function of the bias, the weights which add up from the previous layer \( l-1 \) and the forward passes/outputs -\( \hat{a}^{l-1} \) from the previous layer as +\( \boldsymbol{a}^{l-1} \) from the previous layer as

    $$ @@ -1448,7 +966,7 @@ compact form as the matrix-vector products we discussed earlier,

    $$ -\hat{z}^l = \left(\hat{W}^l\right)^T\hat{a}^{l-1}+\hat{b}^l. +\boldsymbol{z}^l = \left(\boldsymbol{W}^l\right)^T\boldsymbol{a}^{l-1}+\boldsymbol{b}^l. $$ @@ -1456,9 +974,9 @@ $$

    Inputs to the activation function

    With the activation values \( \boldsymbol{z}^l \) we can in turn define the -output of layer \( l \) as \( \boldsymbol{a}^l = f(\boldsymbol{z}^l) \) where \( f \) is our +output of layer \( l \) as \( \boldsymbol{a}^l = \sigma(\boldsymbol{z}^l) \) where \( \sigma \) is our activation function. In the examples here we will use the sigmoid -function discussed in our logistic regression lectures. We will also use the same activation function \( f \) for all layers +function discussed in our logistic regression lectures. We will also use the same activation function \( \sigma \) for all layers and their nodes. It means we have

    @@ -1470,7 +988,7 @@ $$









    Derivatives and the chain rule

    -

    From the definition of the activation \( z_j^l \) we have

    +

    From the definition of the input variable to the activation function, that is \( z_j^l \) we have

    $$ \frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, $$ @@ -1499,12 +1017,12 @@ $$

    The derivative of this function with respect to the weights is

    $$ -\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{L}}, +\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{ij}^{L}}, $$

    The last partial derivative can easily be computed and reads (by applying the chain rule)

    $$ -\frac{\partial a_j^L}{\partial w_{jk}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{jk}^{L}}=a_j^L(1-a_j^L)a_k^{L-1}. +\frac{\partial a_j^L}{\partial w_{ij}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{ij}^{L}}=a_j^L(1-a_j^L)a_i^{L-1}. $$ @@ -1513,7 +1031,7 @@ $$

    We have thus

    $$ -\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_k^{L-1}, +\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_i^{L-1}, $$

    Defining

    @@ -1523,7 +1041,7 @@ $$

    and using the Hadamard product of two vectors we can write this as

    $$ -\boldsymbol{\delta}^L = \sigma'(\hat{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. +\boldsymbol{\delta}^L = \sigma'(\boldsymbol{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. $$ @@ -1557,7 +1075,7 @@ $$

    With the definition of \( \delta_j^L \) we have a more compact definition of the derivative of the cost function in terms of the weights, namely

    $$ -\frac{\partial{\cal C}}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +\frac{\partial{\cal C}}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}. $$ @@ -1584,7 +1102,7 @@ $$ $$ \begin{equation} -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}, +\frac{\partial{\cal C}(\boldsymbol{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, \label{_auto1} \end{equation} $$ @@ -1644,14 +1162,14 @@ $$

    The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.

    -

    First, we set up the input data \( \hat{x} \) and the activations -\( \hat{z}_1 \) of the input layer and compute the activation function and -the pertinent outputs \( \hat{a}^1 \). +

    First, we set up the input data \( \boldsymbol{x} \) and the activations +\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and +the pertinent outputs \( \boldsymbol{a}^1 \).

    Secondly, we perform then the feed forward till we reach the output -layer and compute all \( \hat{z}_l \) of the input layer and compute the -activation function and the pertinent outputs \( \hat{a}^l \) for +layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the +activation function and the pertinent outputs \( \boldsymbol{a}^l \) for \( l=1,2,3,\dots,L \).

    @@ -1660,7 +1178,7 @@ activation function and the pertinent outputs \( \hat{a}^l \) for









    Setting up the back propagation algorithm, part 2

    -

    Thereafter we compute the ouput error \( \hat{\delta}^L \) by computing all

    +

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

    $$ \delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. $$ @@ -1675,12 +1193,12 @@ $$

    Setting up the Back propagation algorithm, part 3

    Finally, we update the weights and the biases using gradient descent -for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases +for each \( l=L-1,L-2,\dots,1 \) (the first hidden layer) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ @@ -1695,12 +1213,12 @@ $$

    With the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l), +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), $$

    we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ @@ -1739,12 +1257,12 @@ functions Typical examples are the logistic Sigmoid

    $$ - f(x) = \frac{1}{1 + e^{-x}}, + \sigma(x) = \frac{1}{1 + e^{-x}}, $$

    and the hyperbolic tangent function

    $$ - f(x) = \tanh(x) + \sigma(x) = \tanh(x) $$ @@ -2228,7 +1746,7 @@ $$

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,2 \) as

    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l). +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). $$
    @@ -2238,7 +1756,7 @@ $$

    Finally, we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,2 \) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ diff --git a/doc/pub/week42/html/week42.html b/doc/pub/week42/html/week42.html index 4a4e742bb..483203b5c 100644 --- a/doc/pub/week42/html/week42.html +++ b/doc/pub/week42/html/week42.html @@ -159,62 +159,6 @@ div.toc p,a { None, 'reminder-on-books-with-hands-on-material-and-codes'), ('Reading recommendations', 2, None, 'reading-recommendations'), - ('Simpler examples first, and automatic differentiation', - 2, - None, - 'simpler-examples-first-and-automatic-differentiation'), - ('Reminder on the chain rule and gradients', - 2, - None, - 'reminder-on-the-chain-rule-and-gradients'), - ('Multivariable functions', 2, None, 'multivariable-functions'), - ('Automatic differentiation through examples', - 2, - None, - 'automatic-differentiation-through-examples'), - ('Simple example', 2, None, 'simple-example'), - ('Smarter way of evaluating the above function', - 2, - None, - 'smarter-way-of-evaluating-the-above-function'), - ('Reducing the number of operations', - 2, - None, - 'reducing-the-number-of-operations'), - ('Chain rule, forward and reverse modes', - 2, - None, - 'chain-rule-forward-and-reverse-modes'), - ('Forward and reverse modes', - 2, - None, - 'forward-and-reverse-modes'), - ('More complicated function', - 2, - None, - 'more-complicated-function'), - ('Counting the number of floating point operations', - 2, - None, - 'counting-the-number-of-floating-point-operations'), - ('Defining intermediate operations', - 2, - None, - 'defining-intermediate-operations'), - ('New expression for the derivative', - 2, - None, - 'new-expression-for-the-derivative'), - ('Final derivatives', 2, None, 'final-derivatives'), - ('In general not this simple', - 2, - None, - 'in-general-not-this-simple'), - ('Automatic differentiation', - 2, - None, - 'automatic-differentiation'), - ('Chain rule', 2, None, 'chain-rule'), ('First network example, simple percepetron with one input', 2, None, @@ -236,10 +180,6 @@ div.toc p,a { ('Important observations', 2, None, 'important-observations'), ('The training', 2, None, 'the-training'), ('Code example', 2, None, 'code-example'), - ('Exercise 1: Including more data', - 2, - None, - 'exercise-1-including-more-data'), ('Simple neural network and the back propagation equations', 2, None, @@ -264,10 +204,6 @@ div.toc p,a { None, 'final-expressions-for-the-biases-of-the-hidden-layer'), ('Gradient expressions', 2, None, 'gradient-expressions'), - ('Exercise 2: Extended program', - 2, - None, - 'exercise-2-extended-program'), ('Setting up the equations for a neural network', 2, None, @@ -524,17 +460,21 @@ MathJax.Hub.Config({

    1. Building our own Feed-forward Neural Network and discussion of project 2
    2. -
    3. Readings and Videos: -
        -
      1. These lecture notes +
      +
    + +
    +Readings and videos +

    +

      +
    1. These lecture notes
    2. -
    3. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
    4. -
    5. Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
    6. -
    7. Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
    8. -
    9. Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
    10. -
    11. Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
    12. -
    +
  • For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7.
  • +
  • Neural Networks demystified at https://www.youtube.com/watch?v=bxe2T-V8XRs&list=PLiaHhY2iBX9hdHaRr6b7XevZtgZRa1PoU&ab_channel=WelchLabs
  • +
  • Building Neural Networks from scratch at https://www.youtube.com/watch?v=Wo5dMEP_BbI&list=PLQVvvaa0QuDcjD5BAw2DxE6OF2tius3V3&ab_channel=sentdex
  • +
  • Video on Neural Networks at https://www.youtube.com/watch?v=CqOfi41LfDw
  • +
  • Video on the back propagation algorithm at https://www.youtube.com/watch?v=Ilg3gGewQ5U
  • I also recommend Michael Nielsen's intuitive approach to the neural networks and the universal approximation theorem, see the slides at http://neuralnetworksanddeeplearning.com/chap4.html.

    @@ -550,7 +490,9 @@ MathJax.Hub.Config({
  • Discussion of project 2
  • - + + +

    Note: some of the codes will also be discussed next week in connection with the solution of differential equations.











    Writing a code which implements a feed-forward neural network

    @@ -558,7 +500,7 @@ MathJax.Hub.Config({

    Last week we discussed the basics of neural networks and deep learning and the basics of automatic differentiation. We looked also at examples on how compute the parameters of a simple network with scalar -inputs and ouputs and no or just one hiden layers. +inputs and ouputs and no or just one hidden layers.

    We ended our discussions with the derivation of the equations for a @@ -597,391 +539,6 @@ hidden nodes but only one output node.

  • Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub
  • Goodfellow et al, chapter 6 and 7 contain most of the neural network background.
  • -









    -

    Simpler examples first, and automatic differentiation

    - -

    In order to understand the back propagation algorithm and its -derivation (an implementation of the chain rule), let us first digress -with some simple examples. These examples are also meant to motivate -the link with back propagation and automatic differentiation. -

    - -









    -

    Reminder on the chain rule and gradients

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t) \) and \( y=y(t) \) are functions of a variable \( t \), we have that the gradient of \( f \) with respect to \( t \) (without the explicit unit vector components)

    -$$ -\frac{df}{dt} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial t} \end{bmatrix}=\frac{\partial f}{\partial x} \frac{\partial x}{\partial t} +\frac{\partial f}{\partial y} \frac{\partial y}{\partial t}. -$$ - - -









    -

    Multivariable functions

    - -

    If we have a multivariate function \( f(x,y) \) where \( x=x(t,s) \) and \( y=y(t,s) \) are functions of the variables \( t \) and \( s \), we have that the partial derivatives

    -$$ -\frac{\partial f}{\partial s}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial s}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial s}, -$$ - -

    and

    -$$ -\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}. -$$ - -

    the gradient of \( f \) with respect to \( t \) and \( s \) (without the explicit unit vector components)

    -$$ -\frac{df}{d(s,t)} = \begin{bmatrix}\frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \end{bmatrix} \begin{bmatrix}\frac{\partial x}{\partial s} &\frac{\partial x}{\partial t} \\ \frac{\partial y}{\partial s} & \frac{\partial y}{\partial t} \end{bmatrix}. -$$ - - -









    -

    Automatic differentiation through examples

    - -

    A great introduction to automatic differentiation is given by Baydin et al., see https://arxiv.org/abs/1502.05767.

    - -

    Automatic differentiation is a represented by a repeated application -of the chain rule on well-known functions and allows for the -calculation of derivatives to numerical precision. It is not the same -as the calculation of symbolic derivatives via for example SymPy, nor -does it use approximative formulae based on Taylor-expansions of a -function around a given value. The latter are error prone due to -truncation errors and values of the step size \( \Delta \). -

    - -









    -

    Simple example

    - -

    Our first example is rather simple,

    -$$ -f(x) =\exp{x^2}, -$$ - -

    with derivative

    -$$ -f'(x) =2x\exp{x^2}. -$$ - -

    We can use SymPy to extract the pertinent lines of Python code through the following simple example

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = exp(x*x)
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Smarter way of evaluating the above function

    -

    If we study this function, we note that we can reduce the number of operations by introducing an intermediate variable

    -$$ -a = x^2, -$$ - -

    leading to

    -$$ -f(x) = f(a(x)) = b= \exp{a}. -$$ - -

    We now assume that all operations can be counted in terms of equal -floating point operations. This means that in order to calculate -\( f(x) \) we need first to square \( x \) and then compute the exponential. We -have thus two floating point operations only. -

    - -









    -

    Reducing the number of operations

    - -

    With the introduction of a precalculated quantity \( a \) and thereby \( f(x) \) we have that the derivative can be written as

    - -$$ -f'(x) = 2xb, -$$ - -

    which reduces the number of operations from four in the orginal -expression to two. This means that if we need to compute \( f(x) \) and -its derivative (a common task in optimizations), we have reduced the -number of operations from six to four in total. -

    - -

    Note that the usage of a symbolic software like SymPy does not -include such simplifications and the calculations of the function and -the derivatives yield in general more floating point operations. -

    - -









    -

    Chain rule, forward and reverse modes

    - -

    In the above example we have introduced the variables \( a \) and \( b \), and our function is

    -$$ -f(x) = f(a(x)) = b= \exp{a}, -$$ - -

    with \( a=x^2 \). We can decompose the derivative of \( f \) with respect to \( x \) as

    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}. -$$ - -

    We note that since \( b=f(x) \) that

    -$$ -\frac{df}{db}=1, -$$ - -

    leading to

    -$$ -\frac{df}{dx}=\frac{db}{da}\frac{da}{dx}=2x\exp{x^2}, -$$ - -

    as before.

    - -









    -

    Forward and reverse modes

    - -

    We have that

    -$$ -\frac{df}{dx}=\frac{df}{db}\frac{db}{da}\frac{da}{dx}, -$$ - -

    which we can rewrite either as

    -$$ -\frac{df}{dx}=\left[\frac{df}{db}\frac{db}{da}\right]\frac{da}{dx}, -$$ - -

    or

    -$$ -\frac{df}{dx}=\frac{df}{db}\left[\frac{db}{da}\frac{da}{dx}\right]. -$$ - -

    The first expression is called reverse mode (or back propagation) -since we start by evaluating the derivatives at the end point and then -propagate backwards. This is the standard way of evaluating -derivatives (gradients) when optimizing the parameters of a neural -network. In the context of deep learning this is computationally -more efficient since the output of a neural network consists of either -one or some few other output variables. -

    - -

    The second equation defines the so-called forward mode.

    - -









    -

    More complicated function

    - -

    We increase our ambitions and introduce a slightly more complicated function

    -$$ -f(x) =\sqrt{x^2+exp{x^2}}, -$$ - -

    with derivative

    -$$ -f'(x) =\frac{x(1+\exp{x^2})}{\sqrt{x^2+exp{x^2}}}. -$$ - -

    The corresponding SymPy code reads

    - - -
    -
    -
    -
    -
    -
    from __future__ import division
    -from sympy import *
    -x = symbols('x')
    -expr = sqrt(x*x+exp(x*x))
    -simplify(expr)
    -derivative = diff(expr,x)
    -print(python(expr))
    -print(python(derivative))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Counting the number of floating point operations

    - -

    A simple count of operations shows that we need five operations for -the function itself and ten for the derivative. Fifteen operations in total if we wish to proceed with the above codes. -

    - -

    Can we reduce this to -say half the number of operations? -

    - -









    -

    Defining intermediate operations

    - -

    We can indeed reduce the number of operation to half of those listed in the brute force approach above. -We define the following quantities -

    -$$ -a = x^2, -$$ - -

    and

    -$$ -b = \exp{x^2} = \exp{a}, -$$ - -

    and

    -$$ -c= a+b, -$$ - -

    and

    -$$ -d=f(x)=\sqrt{c}. -$$ - - -









    -

    New expression for the derivative

    - -

    With these definitions we obtain the following partial derivatives

    -$$ -\frac{\partial a}{\partial x} = 2x, -$$ - -

    and

    -$$ -\frac{\partial b}{\partial a} = \exp{a}, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial a} = 1, -$$ - -

    and

    -$$ -\frac{\partial c}{\partial b} = 1, -$$ - -

    and

    -$$ -\frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial d} = 1. -$$ - - -









    -

    Final derivatives

    -

    Our final derivatives are thus

    -$$ -\frac{\partial f}{\partial c} = \frac{\partial f}{\partial d} \frac{\partial d}{\partial c} = \frac{1}{2\sqrt{c}}, -$$ - -$$ -\frac{\partial f}{\partial b} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial b} = \frac{1}{2\sqrt{c}}, -$$ - -$$ -\frac{\partial f}{\partial a} = \frac{\partial f}{\partial c} \frac{\partial c}{\partial a}+ -\frac{\partial f}{\partial b} \frac{\partial b}{\partial a} = \frac{1+\exp{a}}{2\sqrt{c}}, -$$ - -

    and finally

    -$$ -\frac{\partial f}{\partial x} = \frac{\partial f}{\partial a} \frac{\partial a}{\partial x} = \frac{x(1+\exp{a})}{\sqrt{c}}, -$$ - -

    which is just

    -$$ -\frac{\partial f}{\partial x} = \frac{x(1+b)}{d}, -$$ - -

    and requires only three operations if we can reuse all intermediate variables.

    - -









    -

    In general not this simple

    - -

    In general, see the generalization below, unless we can obtain simple -analytical expressions which we can simplify further, the final -implementation of automatic differentiation involves repeated -calculations (and thereby operations) of derivatives of elementary -functions. -

    - -









    -

    Automatic differentiation

    - -

    We can make this example more formal. Automatic differentiation is a -formalization of the previous example (see graph). -

    - -

    We define \( \boldsymbol{x}\in x_1,\dots, x_l \) input variables to a given function \( f(\boldsymbol{x}) \) and \( x_{l+1},\dots, x_L \) intermediate variables.

    - -

    In the above example we have only one input variable, \( l=1 \) and four intermediate variables, that is

    -$$ -\begin{bmatrix} x_1=x & x_2 = x^2=a & x_3 =\exp{a}= b & x_4=c=a+b & x_5 = \sqrt{c}=d \end{bmatrix}. -$$ - -

    Furthemore, for \( i=l+1, \dots, L \) (here \( i=2,3,4,5 \) and \( f=x_L=d \)), we -define the elementary functions \( g_i(x_{Pa(x_i)}) \) where \( x_{Pa(x_i)} \) are the parent nodes of the variable \( x_i \). -

    - -

    In our case, we have for example for \( x_3=g_3(x_{Pa(x_i)})=\exp{a} \), that \( g_3=\exp{()} \) and \( x_{Pa(x_3)}=a \).

    - -









    -

    Chain rule

    - -

    We can now compute the gradients by back-propagating the derivatives using the chain rule. -We have defined -

    -$$ -\frac{\partial f}{\partial x_L} = 1, -$$ - -

    which allows us to find the derivatives of the various variables \( x_i \) as

    -$$ -\frac{\partial f}{\partial x_i} = \sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial x_j}{\partial x_i}=\sum_{x_j:x_i\in Pa(x_j)}\frac{\partial f}{\partial x_j} \frac{\partial g_j}{\partial x_i}. -$$ - -

    Whenever we have a function which can be expressed as a computation -graph and the various functions can be expressed in terms of -elementary functions that are differentiable, then automatic -differentiation works. The functions may not need to be elementary -functions, they could also be computer programs, although not all -programs can be automatically differentiated. -

    -









    First network example, simple percepetron with one input

    @@ -1234,22 +791,6 @@ eta = 0.1We see that after some few iterations (the results do depend on the learning rate however), we get an error which is rather small.

    -









    - - -

    Exercise 1: Including more data

    - -

    Try to increase the amount of input and -target/output data. Try also to perform calculations for more values -of the learning rates. Feel free to add either hyperparameters with an -\( l_1 \) norm or an \( l_2 \) norm and discuss your results. -Discuss your results as functions of the amount of training data and various learning rates. -

    - -

    Challenge: Try to change the activation functions and replace the hard-coded analytical expressions with automatic derivation via either autograd or JAX.

    - - -









    Simple neural network and the back propagation equations

    @@ -1303,7 +844,7 @@ $$ The inputs to the first hidden layer are

    $$ -\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, +\begin{bmatrix}z_0^{(1)} \\ z_1^{(1)} \end{bmatrix}=\left(\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\ w_{10}^{(1)} &w_{11}^{(1)} \end{bmatrix}\right)^{T}\begin{bmatrix}a_0^{(0)} \\ a_1^{(0)} \end{bmatrix}+\begin{bmatrix}b_0^{(1)} \\ b_1^{(1)} \end{bmatrix}, $$

    with outputs

    @@ -1450,29 +991,6 @@ $$

    where \( \eta \) is the learning rate.

    -









    - - -

    Exercise 2: Extended program

    - -

    We extend our simple code to a function which depends on two variable \( x_0 \) and \( x_1 \), that is

    -$$ -y=f(x_0,x_1)=x_0^2+3x_0x_1+x_1^2+5. -$$ - -

    We feed our network with \( n=100 \) entries \( x_0 \) and \( x_1 \). We have thus two features represented by these variable and an input matrix/design matrix \( \boldsymbol{X}\in \mathbf{R}^{n\times 2} \)

    -$$ -\boldsymbol{X}=\begin{bmatrix} x_{00} & x_{01} \\ x_{00} & x_{01} \\ x_{10} & x_{11} \\ x_{20} & x_{21} \\ \dots & \dots \\ \dots & \dots \\ x_{n-20} & x_{n-21} \\ x_{n-10} & x_{n-11} \end{bmatrix}. -$$ - -

    Write a code, based on the previous code examples, which takes as input these data and fit the above function. -You can extend your code to include automatic differentiation. -

    - -

    With these examples, we are now ready to embark upon the writing of more a general code for neural networks.

    - - -









    Setting up the equations for a neural network

    @@ -1511,7 +1029,7 @@ network \( \boldsymbol{\tilde{y}} \) and the inputs \( \boldsymbol{x} \) we define now the activation \( z_j^l \) of node/neuron/unit \( j \) of the \( l \)-th layer as a function of the bias, the weights which add up from the previous layer \( l-1 \) and the forward passes/outputs -\( \hat{a}^{l-1} \) from the previous layer as +\( \boldsymbol{a}^{l-1} \) from the previous layer as

    $$ @@ -1525,7 +1043,7 @@ compact form as the matrix-vector products we discussed earlier,

    $$ -\hat{z}^l = \left(\hat{W}^l\right)^T\hat{a}^{l-1}+\hat{b}^l. +\boldsymbol{z}^l = \left(\boldsymbol{W}^l\right)^T\boldsymbol{a}^{l-1}+\boldsymbol{b}^l. $$ @@ -1533,9 +1051,9 @@ $$

    Inputs to the activation function

    With the activation values \( \boldsymbol{z}^l \) we can in turn define the -output of layer \( l \) as \( \boldsymbol{a}^l = f(\boldsymbol{z}^l) \) where \( f \) is our +output of layer \( l \) as \( \boldsymbol{a}^l = \sigma(\boldsymbol{z}^l) \) where \( \sigma \) is our activation function. In the examples here we will use the sigmoid -function discussed in our logistic regression lectures. We will also use the same activation function \( f \) for all layers +function discussed in our logistic regression lectures. We will also use the same activation function \( \sigma \) for all layers and their nodes. It means we have

    @@ -1547,7 +1065,7 @@ $$









    Derivatives and the chain rule

    -

    From the definition of the activation \( z_j^l \) we have

    +

    From the definition of the input variable to the activation function, that is \( z_j^l \) we have

    $$ \frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, $$ @@ -1576,12 +1094,12 @@ $$

    The derivative of this function with respect to the weights is

    $$ -\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{L}}, +\frac{\partial{\cal C}(\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)\frac{\partial a_j^L}{\partial w_{ij}^{L}}, $$

    The last partial derivative can easily be computed and reads (by applying the chain rule)

    $$ -\frac{\partial a_j^L}{\partial w_{jk}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{jk}^{L}}=a_j^L(1-a_j^L)a_k^{L-1}. +\frac{\partial a_j^L}{\partial w_{ij}^{L}} = \frac{\partial a_j^L}{\partial z_{j}^{L}}\frac{\partial z_j^L}{\partial w_{ij}^{L}}=a_j^L(1-a_j^L)a_i^{L-1}. $$ @@ -1590,7 +1108,7 @@ $$

    We have thus

    $$ -\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{jk}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_k^{L-1}, +\frac{\partial{\cal C}((\boldsymbol{\Theta}^L)}{\partial w_{ij}^L} = \left(a_j^L - y_j\right)a_j^L(1-a_j^L)a_i^{L-1}, $$

    Defining

    @@ -1600,7 +1118,7 @@ $$

    and using the Hadamard product of two vectors we can write this as

    $$ -\boldsymbol{\delta}^L = \sigma'(\hat{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. +\boldsymbol{\delta}^L = \sigma'(\boldsymbol{z}^L)\circ\frac{\partial {\cal C}}{\partial (\boldsymbol{a}^L)}. $$ @@ -1634,7 +1152,7 @@ $$

    With the definition of \( \delta_j^L \) we have a more compact definition of the derivative of the cost function in terms of the weights, namely

    $$ -\frac{\partial{\cal C}}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +\frac{\partial{\cal C}}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}. $$ @@ -1661,7 +1179,7 @@ $$ $$ \begin{equation} -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}, +\frac{\partial{\cal C}(\boldsymbol{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, \label{_auto1} \end{equation} $$ @@ -1721,14 +1239,14 @@ $$

    The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.

    -

    First, we set up the input data \( \hat{x} \) and the activations -\( \hat{z}_1 \) of the input layer and compute the activation function and -the pertinent outputs \( \hat{a}^1 \). +

    First, we set up the input data \( \boldsymbol{x} \) and the activations +\( \boldsymbol{z}_1 \) of the input layer and compute the activation function and +the pertinent outputs \( \boldsymbol{a}^1 \).

    Secondly, we perform then the feed forward till we reach the output -layer and compute all \( \hat{z}_l \) of the input layer and compute the -activation function and the pertinent outputs \( \hat{a}^l \) for +layer and compute all \( \boldsymbol{z}_l \) of the input layer and compute the +activation function and the pertinent outputs \( \boldsymbol{a}^l \) for \( l=1,2,3,\dots,L \).

    @@ -1737,7 +1255,7 @@ activation function and the pertinent outputs \( \hat{a}^l \) for









    Setting up the back propagation algorithm, part 2

    -

    Thereafter we compute the ouput error \( \hat{\delta}^L \) by computing all

    +

    Thereafter we compute the ouput error \( \boldsymbol{\delta}^L \) by computing all

    $$ \delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. $$ @@ -1752,12 +1270,12 @@ $$

    Setting up the Back propagation algorithm, part 3

    Finally, we update the weights and the biases using gradient descent -for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases +for each \( l=L-1,L-2,\dots,1 \) (the first hidden layer) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ @@ -1772,12 +1290,12 @@ $$

    With the back propagate error for each \( l=L-1,L-2,\dots,1 \) as

    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l), +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), $$

    we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,1 \) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ @@ -1816,12 +1334,12 @@ functions Typical examples are the logistic Sigmoid

    $$ - f(x) = \frac{1}{1 + e^{-x}}, + \sigma(x) = \frac{1}{1 + e^{-x}}, $$

    and the hyperbolic tangent function

    $$ - f(x) = \tanh(x) + \sigma(x) = \tanh(x) $$ @@ -2305,7 +1823,7 @@ $$

    Then we compute the back propagate error for each \( l=L-1,L-2,\dots,2 \) as

    $$ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l). +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). $$
    @@ -2315,7 +1833,7 @@ $$

    Finally, we update the weights and the biases using gradient descent for each \( l=L-1,L-2,\dots,2 \) and update the weights and biases according to the rules

    $$ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, $$ diff --git a/doc/pub/week42/ipynb/ipynb-week42-src.tar.gz b/doc/pub/week42/ipynb/ipynb-week42-src.tar.gz index cb3696078cab622435536232ccf61d8a7fc40842..98f4815985557b58c8d890ad9aa88754242fc675 100644 GIT binary patch delta 59 zcmWN_IRSt$5CB2mCA=2!kqT=RTj2u-$hej&VqnTCkxOLuD^*9FNG*-D(n&A>43cD& MNoHAOec0an0|_+`!TvG6l4?oBGc@_hNGqN6GRP?ZOcG?4 MMON8lzd7FP0~5Xv`Tzg` diff --git a/doc/pub/week42/ipynb/week42.ipynb b/doc/pub/week42/ipynb/week42.ipynb index 60a70664a..209f12073 100644 --- a/doc/pub/week42/ipynb/week42.ipynb +++ b/doc/pub/week42/ipynb/week42.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "b8404683", + "id": "71143de3", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "d90f9b43", + "id": "35db3d31", "metadata": { "editable": true }, @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "b7beb0d3", + "id": "3a41a07e", "metadata": { "editable": true }, @@ -35,28 +35,28 @@ "## Lecture October 14, 2024\n", "1. Building our own Feed-forward Neural Network and discussion of project 2\n", "\n", - "2. Readings and Videos:\n", + "**Readings and videos.**\n", "\n", - "a. These lecture notes\n", + "1. These lecture notes\n", "\n", "\n", "\n", - "b. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7. \n", + "2. For a more in depth discussion on neural networks we recommend Goodfellow et al chapters 6 and 7. \n", "\n", - "c. Neural Networks demystified at \n", + "3. Neural Networks demystified at \n", "\n", - "d. Building Neural Networks from scratch at \n", + "4. Building Neural Networks from scratch at \n", "\n", - "e. Video on Neural Networks at \n", + "5. Video on Neural Networks at \n", "\n", - "f. Video on the back propagation algorithm at \n", + "6. Video on the back propagation algorithm at \n", "\n", "I also recommend Michael Nielsen's intuitive approach to the neural networks and the universal approximation theorem, see the slides at ." ] }, { "cell_type": "markdown", - "id": "5f026849", + "id": "e4274067", "metadata": { "editable": true }, @@ -64,12 +64,16 @@ "## Material for the active learning sessions on Tuesday and Wednesday\n", " * Exercise on starting to write a code for neural networks, feed forward part. We will also continue ur discussions of gradient descent methods from last week. If you have time, start considering the back-propagation part as well (exercises for next week)\n", "\n", - " * Discussion of project 2" + " * Discussion of project 2\n", + "\n", + " \n", + "\n", + "**Note**: some of the codes will also be discussed next week in connection with the solution of differential equations." ] }, { "cell_type": "markdown", - "id": "2ccf44a4", + "id": "38ccf7d0", "metadata": { "editable": true }, @@ -79,7 +83,7 @@ "Last week we discussed the basics of neural networks and deep learning\n", "and the basics of automatic differentiation. We looked also at\n", "examples on how compute the parameters of a simple network with scalar\n", - "inputs and ouputs and no or just one hiden layers.\n", + "inputs and ouputs and no or just one hidden layers.\n", "\n", "We ended our discussions with the derivation of the equations for a\n", "neural network with one hidden layers and two input variables and two\n", @@ -88,7 +92,7 @@ }, { "cell_type": "markdown", - "id": "7010858f", + "id": "bf1932a3", "metadata": { "editable": true }, @@ -104,7 +108,7 @@ }, { "cell_type": "markdown", - "id": "a8353cd2", + "id": "1cb1eb45", "metadata": { "editable": true }, @@ -115,7 +119,7 @@ }, { "cell_type": "markdown", - "id": "816db5f5", + "id": "0f07a5df", "metadata": { "editable": true }, @@ -129,1034 +133,7 @@ }, { "cell_type": "markdown", - "id": "dc0da88a", - "metadata": { - "editable": true - }, - "source": [ - "## Simpler examples first, and automatic differentiation\n", - "\n", - "In order to understand the back propagation algorithm and its\n", - "derivation (an implementation of the chain rule), let us first digress\n", - "with some simple examples. These examples are also meant to motivate\n", - "the link with back propagation and [automatic differentiation](https://en.wikipedia.org/wiki/Automatic_differentiation)." - ] - }, - { - "cell_type": "markdown", - "id": "5c7caa0a", - "metadata": { - "editable": true - }, - "source": [ - "## Reminder on the chain rule and gradients\n", - "\n", - "If we have a multivariate function $f(x,y)$ where $x=x(t)$ and $y=y(t)$ are functions of a variable $t$, we have that the gradient of $f$ with respect to $t$ (without the explicit unit vector components)" - ] - }, - { - "cell_type": "markdown", - "id": "dc0f549a", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dt} = \\begin{bmatrix}\\frac{\\partial f}{\\partial x} & \\frac{\\partial f}{\\partial y} \\end{bmatrix} \\begin{bmatrix}\\frac{\\partial x}{\\partial t} \\\\ \\frac{\\partial y}{\\partial t} \\end{bmatrix}=\\frac{\\partial f}{\\partial x} \\frac{\\partial x}{\\partial t} +\\frac{\\partial f}{\\partial y} \\frac{\\partial y}{\\partial t}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "30ccb31b", - "metadata": { - "editable": true - }, - "source": [ - "## Multivariable functions\n", - "\n", - "If we have a multivariate function $f(x,y)$ where $x=x(t,s)$ and $y=y(t,s)$ are functions of the variables $t$ and $s$, we have that the partial derivatives" - ] - }, - { - "cell_type": "markdown", - "id": "256e4139", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial s}=\\frac{\\partial f}{\\partial x}\\frac{\\partial x}{\\partial s}+\\frac{\\partial f}{\\partial y}\\frac{\\partial y}{\\partial s},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "9079b87a", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "1a717e8d", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial t}=\\frac{\\partial f}{\\partial x}\\frac{\\partial x}{\\partial t}+\\frac{\\partial f}{\\partial y}\\frac{\\partial y}{\\partial t}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "47893372", - "metadata": { - "editable": true - }, - "source": [ - "the gradient of $f$ with respect to $t$ and $s$ (without the explicit unit vector components)" - ] - }, - { - "cell_type": "markdown", - "id": "91752210", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{d(s,t)} = \\begin{bmatrix}\\frac{\\partial f}{\\partial x} & \\frac{\\partial f}{\\partial y} \\end{bmatrix} \\begin{bmatrix}\\frac{\\partial x}{\\partial s} &\\frac{\\partial x}{\\partial t} \\\\ \\frac{\\partial y}{\\partial s} & \\frac{\\partial y}{\\partial t} \\end{bmatrix}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "6ca55956", - "metadata": { - "editable": true - }, - "source": [ - "## Automatic differentiation through examples\n", - "\n", - "A great introduction to automatic differentiation is given by Baydin et al., see .\n", - "\n", - "Automatic differentiation is a represented by a repeated application\n", - "of the chain rule on well-known functions and allows for the\n", - "calculation of derivatives to numerical precision. It is not the same\n", - "as the calculation of symbolic derivatives via for example SymPy, nor\n", - "does it use approximative formulae based on Taylor-expansions of a\n", - "function around a given value. The latter are error prone due to\n", - "truncation errors and values of the step size $\\Delta$." - ] - }, - { - "cell_type": "markdown", - "id": "fcf25d6f", - "metadata": { - "editable": true - }, - "source": [ - "## Simple example\n", - "\n", - "Our first example is rather simple," - ] - }, - { - "cell_type": "markdown", - "id": "72a1c091", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f(x) =\\exp{x^2},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "f22d546b", - "metadata": { - "editable": true - }, - "source": [ - "with derivative" - ] - }, - { - "cell_type": "markdown", - "id": "40547d67", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f'(x) =2x\\exp{x^2}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "fa0a8b6a", - "metadata": { - "editable": true - }, - "source": [ - "We can use SymPy to extract the pertinent lines of Python code through the following simple example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "ec6abf69", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from __future__ import division\n", - "from sympy import *\n", - "x = symbols('x')\n", - "expr = exp(x*x)\n", - "simplify(expr)\n", - "derivative = diff(expr,x)\n", - "print(python(expr))\n", - "print(python(derivative))" - ] - }, - { - "cell_type": "markdown", - "id": "4055ea35", - "metadata": { - "editable": true - }, - "source": [ - "## Smarter way of evaluating the above function\n", - "If we study this function, we note that we can reduce the number of operations by introducing an intermediate variable" - ] - }, - { - "cell_type": "markdown", - "id": "db1f0a3d", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "a = x^2,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "02593878", - "metadata": { - "editable": true - }, - "source": [ - "leading to" - ] - }, - { - "cell_type": "markdown", - "id": "d9e1008c", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f(x) = f(a(x)) = b= \\exp{a}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "b7cdf9a3", - "metadata": { - "editable": true - }, - "source": [ - "We now assume that all operations can be counted in terms of equal\n", - "floating point operations. This means that in order to calculate\n", - "$f(x)$ we need first to square $x$ and then compute the exponential. We\n", - "have thus two floating point operations only." - ] - }, - { - "cell_type": "markdown", - "id": "6c9da5de", - "metadata": { - "editable": true - }, - "source": [ - "## Reducing the number of operations\n", - "\n", - "With the introduction of a precalculated quantity $a$ and thereby $f(x)$ we have that the derivative can be written as" - ] - }, - { - "cell_type": "markdown", - "id": "3bf90e55", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f'(x) = 2xb,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "f817bc95", - "metadata": { - "editable": true - }, - "source": [ - "which reduces the number of operations from four in the orginal\n", - "expression to two. This means that if we need to compute $f(x)$ and\n", - "its derivative (a common task in optimizations), we have reduced the\n", - "number of operations from six to four in total.\n", - "\n", - "**Note** that the usage of a symbolic software like SymPy does not\n", - "include such simplifications and the calculations of the function and\n", - "the derivatives yield in general more floating point operations." - ] - }, - { - "cell_type": "markdown", - "id": "75bdf5ab", - "metadata": { - "editable": true - }, - "source": [ - "## Chain rule, forward and reverse modes\n", - "\n", - "In the above example we have introduced the variables $a$ and $b$, and our function is" - ] - }, - { - "cell_type": "markdown", - "id": "3dd6ec80", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f(x) = f(a(x)) = b= \\exp{a},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "c0e8f2af", - "metadata": { - "editable": true - }, - "source": [ - "with $a=x^2$. We can decompose the derivative of $f$ with respect to $x$ as" - ] - }, - { - "cell_type": "markdown", - "id": "4fef9651", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dx}=\\frac{df}{db}\\frac{db}{da}\\frac{da}{dx}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "0cba430c", - "metadata": { - "editable": true - }, - "source": [ - "We note that since $b=f(x)$ that" - ] - }, - { - "cell_type": "markdown", - "id": "0537374a", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{db}=1,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "71539c2c", - "metadata": { - "editable": true - }, - "source": [ - "leading to" - ] - }, - { - "cell_type": "markdown", - "id": "59a1eeb0", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dx}=\\frac{db}{da}\\frac{da}{dx}=2x\\exp{x^2},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "4b446c57", - "metadata": { - "editable": true - }, - "source": [ - "as before." - ] - }, - { - "cell_type": "markdown", - "id": "426f0459", - "metadata": { - "editable": true - }, - "source": [ - "## Forward and reverse modes\n", - "\n", - "We have that" - ] - }, - { - "cell_type": "markdown", - "id": "4183f4a8", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dx}=\\frac{df}{db}\\frac{db}{da}\\frac{da}{dx},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "7c8ea7e4", - "metadata": { - "editable": true - }, - "source": [ - "which we can rewrite either as" - ] - }, - { - "cell_type": "markdown", - "id": "61849a08", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dx}=\\left[\\frac{df}{db}\\frac{db}{da}\\right]\\frac{da}{dx},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "d08f76cb", - "metadata": { - "editable": true - }, - "source": [ - "or" - ] - }, - { - "cell_type": "markdown", - "id": "dbac7ae2", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{df}{dx}=\\frac{df}{db}\\left[\\frac{db}{da}\\frac{da}{dx}\\right].\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "df0fe647", - "metadata": { - "editable": true - }, - "source": [ - "The first expression is called reverse mode (or back propagation)\n", - "since we start by evaluating the derivatives at the end point and then\n", - "propagate backwards. This is the standard way of evaluating\n", - "derivatives (gradients) when optimizing the parameters of a neural\n", - "network. In the context of deep learning this is computationally\n", - "more efficient since the output of a neural network consists of either\n", - "one or some few other output variables.\n", - "\n", - "The second equation defines the so-called **forward mode**." - ] - }, - { - "cell_type": "markdown", - "id": "a3fc71d8", - "metadata": { - "editable": true - }, - "source": [ - "## More complicated function\n", - "\n", - "We increase our ambitions and introduce a slightly more complicated function" - ] - }, - { - "cell_type": "markdown", - "id": "cba65c92", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f(x) =\\sqrt{x^2+exp{x^2}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "297f00cf", - "metadata": { - "editable": true - }, - "source": [ - "with derivative" - ] - }, - { - "cell_type": "markdown", - "id": "1451d563", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f'(x) =\\frac{x(1+\\exp{x^2})}{\\sqrt{x^2+exp{x^2}}}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "64c8fe94", - "metadata": { - "editable": true - }, - "source": [ - "The corresponding SymPy code reads" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "641df3cc", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from __future__ import division\n", - "from sympy import *\n", - "x = symbols('x')\n", - "expr = sqrt(x*x+exp(x*x))\n", - "simplify(expr)\n", - "derivative = diff(expr,x)\n", - "print(python(expr))\n", - "print(python(derivative))" - ] - }, - { - "cell_type": "markdown", - "id": "9410a73d", - "metadata": { - "editable": true - }, - "source": [ - "## Counting the number of floating point operations\n", - "\n", - "A simple count of operations shows that we need five operations for\n", - "the function itself and ten for the derivative. Fifteen operations in total if we wish to proceed with the above codes.\n", - "\n", - "Can we reduce this to\n", - "say half the number of operations?" - ] - }, - { - "cell_type": "markdown", - "id": "3983257f", - "metadata": { - "editable": true - }, - "source": [ - "## Defining intermediate operations\n", - "\n", - "We can indeed reduce the number of operation to half of those listed in the brute force approach above.\n", - "We define the following quantities" - ] - }, - { - "cell_type": "markdown", - "id": "992ff2fe", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "a = x^2,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "46e78b2a", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "c221fbb2", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "b = \\exp{x^2} = \\exp{a},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "27a1dcf2", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "3df28423", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "c= a+b,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "196a55e0", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "f70c9b44", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "d=f(x)=\\sqrt{c}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "ff733144", - "metadata": { - "editable": true - }, - "source": [ - "## New expression for the derivative\n", - "\n", - "With these definitions we obtain the following partial derivatives" - ] - }, - { - "cell_type": "markdown", - "id": "7b11e617", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial a}{\\partial x} = 2x,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "4719f40b", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "235de4d9", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial b}{\\partial a} = \\exp{a},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "68fd3b11", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "f6725c05", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial c}{\\partial a} = 1,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "912ea9a8", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "12cbfea1", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial c}{\\partial b} = 1,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "4894a8ba", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "6f500a0d", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial d}{\\partial c} = \\frac{1}{2\\sqrt{c}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "e88f0ca2", - "metadata": { - "editable": true - }, - "source": [ - "and finally" - ] - }, - { - "cell_type": "markdown", - "id": "fc557b9c", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial d} = 1.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "e3186049", - "metadata": { - "editable": true - }, - "source": [ - "## Final derivatives\n", - "Our final derivatives are thus" - ] - }, - { - "cell_type": "markdown", - "id": "e8bbf2a0", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial c} = \\frac{\\partial f}{\\partial d} \\frac{\\partial d}{\\partial c} = \\frac{1}{2\\sqrt{c}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "bf0a315a", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial b} = \\frac{\\partial f}{\\partial c} \\frac{\\partial c}{\\partial b} = \\frac{1}{2\\sqrt{c}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "e8925569", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial a} = \\frac{\\partial f}{\\partial c} \\frac{\\partial c}{\\partial a}+\n", - "\\frac{\\partial f}{\\partial b} \\frac{\\partial b}{\\partial a} = \\frac{1+\\exp{a}}{2\\sqrt{c}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "ae48f9b7", - "metadata": { - "editable": true - }, - "source": [ - "and finally" - ] - }, - { - "cell_type": "markdown", - "id": "f25ad00a", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial x} = \\frac{\\partial f}{\\partial a} \\frac{\\partial a}{\\partial x} = \\frac{x(1+\\exp{a})}{\\sqrt{c}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "9cb6b76c", - "metadata": { - "editable": true - }, - "source": [ - "which is just" - ] - }, - { - "cell_type": "markdown", - "id": "51715c24", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial x} = \\frac{x(1+b)}{d},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "710883c4", - "metadata": { - "editable": true - }, - "source": [ - "and requires only three operations if we can reuse all intermediate variables." - ] - }, - { - "cell_type": "markdown", - "id": "40f09d3a", - "metadata": { - "editable": true - }, - "source": [ - "## In general not this simple\n", - "\n", - "In general, see the generalization below, unless we can obtain simple\n", - "analytical expressions which we can simplify further, the final\n", - "implementation of automatic differentiation involves repeated\n", - "calculations (and thereby operations) of derivatives of elementary\n", - "functions." - ] - }, - { - "cell_type": "markdown", - "id": "4f2717d8", - "metadata": { - "editable": true - }, - "source": [ - "## Automatic differentiation\n", - "\n", - "We can make this example more formal. Automatic differentiation is a\n", - "formalization of the previous example (see graph).\n", - "\n", - "We define $\\boldsymbol{x}\\in x_1,\\dots, x_l$ input variables to a given function $f(\\boldsymbol{x})$ and $x_{l+1},\\dots, x_L$ intermediate variables.\n", - "\n", - "In the above example we have only one input variable, $l=1$ and four intermediate variables, that is" - ] - }, - { - "cell_type": "markdown", - "id": "917f00fc", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\begin{bmatrix} x_1=x & x_2 = x^2=a & x_3 =\\exp{a}= b & x_4=c=a+b & x_5 = \\sqrt{c}=d \\end{bmatrix}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "39d343f4", - "metadata": { - "editable": true - }, - "source": [ - "Furthemore, for $i=l+1, \\dots, L$ (here $i=2,3,4,5$ and $f=x_L=d$), we\n", - "define the elementary functions $g_i(x_{Pa(x_i)})$ where $x_{Pa(x_i)}$ are the parent nodes of the variable $x_i$.\n", - "\n", - "In our case, we have for example for $x_3=g_3(x_{Pa(x_i)})=\\exp{a}$, that $g_3=\\exp{()}$ and $x_{Pa(x_3)}=a$." - ] - }, - { - "cell_type": "markdown", - "id": "25202003", - "metadata": { - "editable": true - }, - "source": [ - "## Chain rule\n", - "\n", - "We can now compute the gradients by back-propagating the derivatives using the chain rule.\n", - "We have defined" - ] - }, - { - "cell_type": "markdown", - "id": "f4e1d250", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial x_L} = 1,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "3394d9ca", - "metadata": { - "editable": true - }, - "source": [ - "which allows us to find the derivatives of the various variables $x_i$ as" - ] - }, - { - "cell_type": "markdown", - "id": "68b77e31", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f}{\\partial x_i} = \\sum_{x_j:x_i\\in Pa(x_j)}\\frac{\\partial f}{\\partial x_j} \\frac{\\partial x_j}{\\partial x_i}=\\sum_{x_j:x_i\\in Pa(x_j)}\\frac{\\partial f}{\\partial x_j} \\frac{\\partial g_j}{\\partial x_i}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "6aefb595", - "metadata": { - "editable": true - }, - "source": [ - "Whenever we have a function which can be expressed as a computation\n", - "graph and the various functions can be expressed in terms of\n", - "elementary functions that are differentiable, then automatic\n", - "differentiation works. The functions may not need to be elementary\n", - "functions, they could also be computer programs, although not all\n", - "programs can be automatically differentiated." - ] - }, - { - "cell_type": "markdown", - "id": "c43c7643", + "id": "8671fb13", "metadata": { "editable": true }, @@ -1171,7 +148,7 @@ }, { "cell_type": "markdown", - "id": "8c286d5b", + "id": "12ed4396", "metadata": { "editable": true }, @@ -1183,7 +160,7 @@ }, { "cell_type": "markdown", - "id": "828655d4", + "id": "c1516595", "metadata": { "editable": true }, @@ -1197,7 +174,7 @@ }, { "cell_type": "markdown", - "id": "e11a3ad5", + "id": "2949b61a", "metadata": { "editable": true }, @@ -1209,7 +186,7 @@ }, { "cell_type": "markdown", - "id": "fbdcd6b5", + "id": "46e01f35", "metadata": { "editable": true }, @@ -1225,7 +202,7 @@ }, { "cell_type": "markdown", - "id": "4e578e76", + "id": "9c6ea29d", "metadata": { "editable": true }, @@ -1241,7 +218,7 @@ }, { "cell_type": "markdown", - "id": "75e19502", + "id": "6c66c7ee", "metadata": { "editable": true }, @@ -1253,7 +230,7 @@ }, { "cell_type": "markdown", - "id": "dfb1775a", + "id": "f8846711", "metadata": { "editable": true }, @@ -1263,7 +240,7 @@ }, { "cell_type": "markdown", - "id": "7ec2961d", + "id": "e4b9e408", "metadata": { "editable": true }, @@ -1275,7 +252,7 @@ }, { "cell_type": "markdown", - "id": "66546b1c", + "id": "b8f62859", "metadata": { "editable": true }, @@ -1285,7 +262,7 @@ }, { "cell_type": "markdown", - "id": "66e2057d", + "id": "f2ec677d", "metadata": { "editable": true }, @@ -1297,7 +274,7 @@ }, { "cell_type": "markdown", - "id": "26507b17", + "id": "31099b72", "metadata": { "editable": true }, @@ -1307,7 +284,7 @@ }, { "cell_type": "markdown", - "id": "a98808ba", + "id": "cc6de265", "metadata": { "editable": true }, @@ -1319,7 +296,7 @@ }, { "cell_type": "markdown", - "id": "0fc506c3", + "id": "de05db8e", "metadata": { "editable": true }, @@ -1335,7 +312,7 @@ }, { "cell_type": "markdown", - "id": "a934b2b5", + "id": "a5fcef62", "metadata": { "editable": true }, @@ -1347,7 +324,7 @@ }, { "cell_type": "markdown", - "id": "09510c55", + "id": "38f87147", "metadata": { "editable": true }, @@ -1359,7 +336,7 @@ }, { "cell_type": "markdown", - "id": "660f75bb", + "id": "92822d7d", "metadata": { "editable": true }, @@ -1369,7 +346,7 @@ }, { "cell_type": "markdown", - "id": "704edb0f", + "id": "7d08d013", "metadata": { "editable": true }, @@ -1381,7 +358,7 @@ }, { "cell_type": "markdown", - "id": "573cbc6f", + "id": "8ca04a0a", "metadata": { "editable": true }, @@ -1391,7 +368,7 @@ }, { "cell_type": "markdown", - "id": "ddb8e512", + "id": "cd2b820f", "metadata": { "editable": true }, @@ -1407,7 +384,7 @@ }, { "cell_type": "markdown", - "id": "58d304a3", + "id": "74a4bf55", "metadata": { "editable": true }, @@ -1419,7 +396,7 @@ }, { "cell_type": "markdown", - "id": "6eb36ca9", + "id": "b6a6ea2c", "metadata": { "editable": true }, @@ -1431,7 +408,7 @@ }, { "cell_type": "markdown", - "id": "df10327b", + "id": "f569e2c4", "metadata": { "editable": true }, @@ -1443,7 +420,7 @@ }, { "cell_type": "markdown", - "id": "81ebed72", + "id": "11dd5f28", "metadata": { "editable": true }, @@ -1455,7 +432,7 @@ }, { "cell_type": "markdown", - "id": "3aa5db4a", + "id": "e79bd0c6", "metadata": { "editable": true }, @@ -1467,7 +444,7 @@ }, { "cell_type": "markdown", - "id": "9cf5e367", + "id": "0994dc8a", "metadata": { "editable": true }, @@ -1477,7 +454,7 @@ }, { "cell_type": "markdown", - "id": "330737b6", + "id": "a5fb5850", "metadata": { "editable": true }, @@ -1493,7 +470,7 @@ }, { "cell_type": "markdown", - "id": "d804d9f1", + "id": "75ef56f2", "metadata": { "editable": true }, @@ -1505,7 +482,7 @@ }, { "cell_type": "markdown", - "id": "f2b96485", + "id": "2cba4793", "metadata": { "editable": true }, @@ -1517,7 +494,7 @@ }, { "cell_type": "markdown", - "id": "e54f647d", + "id": "002f872b", "metadata": { "editable": true }, @@ -1527,7 +504,7 @@ }, { "cell_type": "markdown", - "id": "9991b3b5", + "id": "ca9db79a", "metadata": { "editable": true }, @@ -1539,7 +516,7 @@ }, { "cell_type": "markdown", - "id": "7f82973f", + "id": "91c832ea", "metadata": { "editable": true }, @@ -1553,7 +530,7 @@ }, { "cell_type": "markdown", - "id": "8a0303f0", + "id": "497597b5", "metadata": { "editable": true }, @@ -1570,8 +547,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "e8944e19", + "execution_count": 1, + "id": "31785b91", "metadata": { "collapsed": false, "editable": true @@ -1644,7 +621,7 @@ }, { "cell_type": "markdown", - "id": "f8c6fb49", + "id": "fb3ba38a", "metadata": { "editable": true }, @@ -1654,25 +631,7 @@ }, { "cell_type": "markdown", - "id": "9070cd99", - "metadata": { - "editable": true - }, - "source": [ - "## Exercise 1: Including more data\n", - "\n", - "Try to increase the amount of input and\n", - "target/output data. Try also to perform calculations for more values\n", - "of the learning rates. Feel free to add either hyperparameters with an\n", - "$l_1$ norm or an $l_2$ norm and discuss your results.\n", - "Discuss your results as functions of the amount of training data and various learning rates.\n", - "\n", - "**Challenge:** Try to change the activation functions and replace the hard-coded analytical expressions with automatic derivation via either **autograd** or **JAX**." - ] - }, - { - "cell_type": "markdown", - "id": "f3fe6647", + "id": "f39aa22a", "metadata": { "editable": true }, @@ -1689,7 +648,7 @@ }, { "cell_type": "markdown", - "id": "8d3ed6ab", + "id": "07786f01", "metadata": { "editable": true }, @@ -1701,7 +660,7 @@ }, { "cell_type": "markdown", - "id": "5f94f722", + "id": "855ae860", "metadata": { "editable": true }, @@ -1711,7 +670,7 @@ }, { "cell_type": "markdown", - "id": "e8b3b05c", + "id": "f982b39a", "metadata": { "editable": true }, @@ -1723,7 +682,7 @@ }, { "cell_type": "markdown", - "id": "e405d62e", + "id": "5b0b9a6a", "metadata": { "editable": true }, @@ -1739,7 +698,7 @@ }, { "cell_type": "markdown", - "id": "30f3f534", + "id": "f74b7c7d", "metadata": { "editable": true }, @@ -1751,7 +710,7 @@ }, { "cell_type": "markdown", - "id": "a7c28be8", + "id": "dbaa42b5", "metadata": { "editable": true }, @@ -1763,7 +722,7 @@ }, { "cell_type": "markdown", - "id": "97242057", + "id": "8f7dc89c", "metadata": { "editable": true }, @@ -1774,7 +733,7 @@ }, { "cell_type": "markdown", - "id": "b4129a79", + "id": "adfec9e2", "metadata": { "editable": true }, @@ -1786,7 +745,7 @@ }, { "cell_type": "markdown", - "id": "17ffe76c", + "id": "1a91248a", "metadata": { "editable": true }, @@ -1799,19 +758,19 @@ }, { "cell_type": "markdown", - "id": "18a5a8d6", + "id": "f8dd5dde", "metadata": { "editable": true }, "source": [ "$$\n", - "\\begin{bmatrix}z_0^{(1)} \\\\ z_1^{(1)} \\end{bmatrix}=\\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\\\ w_{10}^{(1)} &w_{11}^{(1)} \\end{bmatrix}\\begin{bmatrix}a_0^{(0)} \\\\ a_1^{(0)} \\end{bmatrix}+\\begin{bmatrix}b_0^{(1)} \\\\ b_1^{(1)} \\end{bmatrix},\n", + "\\begin{bmatrix}z_0^{(1)} \\\\ z_1^{(1)} \\end{bmatrix}=\\left(\\begin{bmatrix}w_{00}^{(1)} & w_{01}^{(1)}\\\\ w_{10}^{(1)} &w_{11}^{(1)} \\end{bmatrix}\\right)^{T}\\begin{bmatrix}a_0^{(0)} \\\\ a_1^{(0)} \\end{bmatrix}+\\begin{bmatrix}b_0^{(1)} \\\\ b_1^{(1)} \\end{bmatrix},\n", "$$" ] }, { "cell_type": "markdown", - "id": "d10f3b85", + "id": "806e1970", "metadata": { "editable": true }, @@ -1821,7 +780,7 @@ }, { "cell_type": "markdown", - "id": "4a9fc607", + "id": "887c1cc5", "metadata": { "editable": true }, @@ -1833,7 +792,7 @@ }, { "cell_type": "markdown", - "id": "746900d9", + "id": "4bf40527", "metadata": { "editable": true }, @@ -1845,7 +804,7 @@ }, { "cell_type": "markdown", - "id": "ffcc4a36", + "id": "a5d878ba", "metadata": { "editable": true }, @@ -1857,7 +816,7 @@ }, { "cell_type": "markdown", - "id": "8c24c5fb", + "id": "318c3664", "metadata": { "editable": true }, @@ -1867,7 +826,7 @@ }, { "cell_type": "markdown", - "id": "c4bc4918", + "id": "c4fc9951", "metadata": { "editable": true }, @@ -1879,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "9d1025e8", + "id": "3d187d65", "metadata": { "editable": true }, @@ -1895,7 +854,7 @@ }, { "cell_type": "markdown", - "id": "e3ebae58", + "id": "24ebe80e", "metadata": { "editable": true }, @@ -1907,7 +866,7 @@ }, { "cell_type": "markdown", - "id": "d9c5a0cd", + "id": "640153c7", "metadata": { "editable": true }, @@ -1917,7 +876,7 @@ }, { "cell_type": "markdown", - "id": "0eae55df", + "id": "9f00a103", "metadata": { "editable": true }, @@ -1929,7 +888,7 @@ }, { "cell_type": "markdown", - "id": "ba62d201", + "id": "c313a954", "metadata": { "editable": true }, @@ -1939,7 +898,7 @@ }, { "cell_type": "markdown", - "id": "e2ab3774", + "id": "8f9899f9", "metadata": { "editable": true }, @@ -1951,7 +910,7 @@ }, { "cell_type": "markdown", - "id": "558b25d9", + "id": "fe894efa", "metadata": { "editable": true }, @@ -1963,7 +922,7 @@ }, { "cell_type": "markdown", - "id": "2dd9bb8c", + "id": "ff3f394f", "metadata": { "editable": true }, @@ -1976,7 +935,7 @@ }, { "cell_type": "markdown", - "id": "97650d61", + "id": "91783800", "metadata": { "editable": true }, @@ -1986,7 +945,7 @@ }, { "cell_type": "markdown", - "id": "66d50c1c", + "id": "b9199d44", "metadata": { "editable": true }, @@ -1998,7 +957,7 @@ }, { "cell_type": "markdown", - "id": "cd1f5497", + "id": "0cc20449", "metadata": { "editable": true }, @@ -2008,7 +967,7 @@ }, { "cell_type": "markdown", - "id": "9d87ee5f", + "id": "a376f16a", "metadata": { "editable": true }, @@ -2020,7 +979,7 @@ }, { "cell_type": "markdown", - "id": "7abecf51", + "id": "9cf47847", "metadata": { "editable": true }, @@ -2031,7 +990,7 @@ }, { "cell_type": "markdown", - "id": "dbacdc21", + "id": "c1bd9901", "metadata": { "editable": true }, @@ -2043,7 +1002,7 @@ }, { "cell_type": "markdown", - "id": "835726a3", + "id": "addef0ec", "metadata": { "editable": true }, @@ -2053,7 +1012,7 @@ }, { "cell_type": "markdown", - "id": "82362fdf", + "id": "a5b267fc", "metadata": { "editable": true }, @@ -2065,7 +1024,7 @@ }, { "cell_type": "markdown", - "id": "83caeae4", + "id": "53d64a33", "metadata": { "editable": true }, @@ -2075,7 +1034,7 @@ }, { "cell_type": "markdown", - "id": "6c0bbe31", + "id": "765d3576", "metadata": { "editable": true }, @@ -2087,7 +1046,7 @@ }, { "cell_type": "markdown", - "id": "0865efe1", + "id": "680e6d32", "metadata": { "editable": true }, @@ -2099,7 +1058,7 @@ }, { "cell_type": "markdown", - "id": "c1f268d8", + "id": "6b5a3f94", "metadata": { "editable": true }, @@ -2111,7 +1070,7 @@ }, { "cell_type": "markdown", - "id": "45088efc", + "id": "c0b94fbc", "metadata": { "editable": true }, @@ -2121,7 +1080,7 @@ }, { "cell_type": "markdown", - "id": "1ba9351f", + "id": "a8bc0cb4", "metadata": { "editable": true }, @@ -2133,7 +1092,7 @@ }, { "cell_type": "markdown", - "id": "cc013086", + "id": "fc5ba87a", "metadata": { "editable": true }, @@ -2143,7 +1102,7 @@ }, { "cell_type": "markdown", - "id": "53b308b8", + "id": "d7928417", "metadata": { "editable": true }, @@ -2155,7 +1114,7 @@ }, { "cell_type": "markdown", - "id": "b94074b1", + "id": "38fcd712", "metadata": { "editable": true }, @@ -2167,7 +1126,7 @@ }, { "cell_type": "markdown", - "id": "5517734b", + "id": "a68a28b5", "metadata": { "editable": true }, @@ -2179,7 +1138,7 @@ }, { "cell_type": "markdown", - "id": "e04b8d89", + "id": "81b5762d", "metadata": { "editable": true }, @@ -2189,7 +1148,7 @@ }, { "cell_type": "markdown", - "id": "3254a4b0", + "id": "6485ea35", "metadata": { "editable": true }, @@ -2201,7 +1160,7 @@ }, { "cell_type": "markdown", - "id": "0a264c25", + "id": "56f15a69", "metadata": { "editable": true }, @@ -2211,7 +1170,7 @@ }, { "cell_type": "markdown", - "id": "c6972d01", + "id": "7f3597fa", "metadata": { "editable": true }, @@ -2224,7 +1183,7 @@ }, { "cell_type": "markdown", - "id": "c3dd017f", + "id": "f3af219f", "metadata": { "editable": true }, @@ -2236,7 +1195,7 @@ }, { "cell_type": "markdown", - "id": "4ac3aa27", + "id": "7a21d5ea", "metadata": { "editable": true }, @@ -2246,7 +1205,7 @@ }, { "cell_type": "markdown", - "id": "6019c5b1", + "id": "d0c3898f", "metadata": { "editable": true }, @@ -2258,7 +1217,7 @@ }, { "cell_type": "markdown", - "id": "4f05d88b", + "id": "34325b5c", "metadata": { "editable": true }, @@ -2268,7 +1227,7 @@ }, { "cell_type": "markdown", - "id": "d2060955", + "id": "918bb1fa", "metadata": { "editable": true }, @@ -2280,7 +1239,7 @@ }, { "cell_type": "markdown", - "id": "70ef11a0", + "id": "894b36e6", "metadata": { "editable": true }, @@ -2290,7 +1249,7 @@ }, { "cell_type": "markdown", - "id": "badd3ddf", + "id": "55f20c6b", "metadata": { "editable": true }, @@ -2302,7 +1261,7 @@ }, { "cell_type": "markdown", - "id": "e62f42f0", + "id": "0d783805", "metadata": { "editable": true }, @@ -2312,66 +1271,7 @@ }, { "cell_type": "markdown", - "id": "0c4976fa", - "metadata": { - "editable": true - }, - "source": [ - "## Exercise 2: Extended program\n", - "\n", - "We extend our simple code to a function which depends on two variable $x_0$ and $x_1$, that is" - ] - }, - { - "cell_type": "markdown", - "id": "7732e898", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "y=f(x_0,x_1)=x_0^2+3x_0x_1+x_1^2+5.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "3f2764c3", - "metadata": { - "editable": true - }, - "source": [ - "We feed our network with $n=100$ entries $x_0$ and $x_1$. We have thus two features represented by these variable and an input matrix/design matrix $\\boldsymbol{X}\\in \\mathbf{R}^{n\\times 2}$" - ] - }, - { - "cell_type": "markdown", - "id": "c9edb27a", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\boldsymbol{X}=\\begin{bmatrix} x_{00} & x_{01} \\\\ x_{00} & x_{01} \\\\ x_{10} & x_{11} \\\\ x_{20} & x_{21} \\\\ \\dots & \\dots \\\\ \\dots & \\dots \\\\ x_{n-20} & x_{n-21} \\\\ x_{n-10} & x_{n-11} \\end{bmatrix}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "abe6c1c9", - "metadata": { - "editable": true - }, - "source": [ - "Write a code, based on the previous code examples, which takes as input these data and fit the above function.\n", - "You can extend your code to include automatic differentiation.\n", - "\n", - "With these examples, we are now ready to embark upon the writing of more a general code for neural networks." - ] - }, - { - "cell_type": "markdown", - "id": "2ac4f62f", + "id": "f64324de", "metadata": { "editable": true }, @@ -2388,7 +1288,7 @@ }, { "cell_type": "markdown", - "id": "bd6427c2", + "id": "c860274d", "metadata": { "editable": true }, @@ -2400,7 +1300,7 @@ }, { "cell_type": "markdown", - "id": "c7cd035e", + "id": "266ed951", "metadata": { "editable": true }, @@ -2412,7 +1312,7 @@ }, { "cell_type": "markdown", - "id": "84e35960", + "id": "e3597760", "metadata": { "editable": true }, @@ -2428,7 +1328,7 @@ }, { "cell_type": "markdown", - "id": "87c017b2", + "id": "29ddf471", "metadata": { "editable": true }, @@ -2440,12 +1340,12 @@ "define now the activation $z_j^l$ of node/neuron/unit $j$ of the\n", "$l$-th layer as a function of the bias, the weights which add up from\n", "the previous layer $l-1$ and the forward passes/outputs\n", - "$\\hat{a}^{l-1}$ from the previous layer as" + "$\\boldsymbol{a}^{l-1}$ from the previous layer as" ] }, { "cell_type": "markdown", - "id": "4a878aa2", + "id": "7e290342", "metadata": { "editable": true }, @@ -2457,7 +1357,7 @@ }, { "cell_type": "markdown", - "id": "6d0d9972", + "id": "c16f6b07", "metadata": { "editable": true }, @@ -2470,19 +1370,19 @@ }, { "cell_type": "markdown", - "id": "14634565", + "id": "67289b7d", "metadata": { "editable": true }, "source": [ "$$\n", - "\\hat{z}^l = \\left(\\hat{W}^l\\right)^T\\hat{a}^{l-1}+\\hat{b}^l.\n", + "\\boldsymbol{z}^l = \\left(\\boldsymbol{W}^l\\right)^T\\boldsymbol{a}^{l-1}+\\boldsymbol{b}^l.\n", "$$" ] }, { "cell_type": "markdown", - "id": "1a4514f2", + "id": "035f7467", "metadata": { "editable": true }, @@ -2490,15 +1390,15 @@ "## Inputs to the activation function\n", "\n", "With the activation values $\\boldsymbol{z}^l$ we can in turn define the\n", - "output of layer $l$ as $\\boldsymbol{a}^l = f(\\boldsymbol{z}^l)$ where $f$ is our\n", + "output of layer $l$ as $\\boldsymbol{a}^l = \\sigma(\\boldsymbol{z}^l)$ where $\\sigma$ is our\n", "activation function. In the examples here we will use the sigmoid\n", - "function discussed in our logistic regression lectures. We will also use the same activation function $f$ for all layers\n", + "function discussed in our logistic regression lectures. We will also use the same activation function $\\sigma$ for all layers\n", "and their nodes. It means we have" ] }, { "cell_type": "markdown", - "id": "94bcfdfd", + "id": "0c867ff6", "metadata": { "editable": true }, @@ -2510,19 +1410,19 @@ }, { "cell_type": "markdown", - "id": "d9cd0ab8", + "id": "502f4ffa", "metadata": { "editable": true }, "source": [ "## Derivatives and the chain rule\n", "\n", - "From the definition of the activation $z_j^l$ we have" + "From the definition of the input variable to the activation function, that is $z_j^l$ we have" ] }, { "cell_type": "markdown", - "id": "fcb6fbe7", + "id": "6ccb4bd2", "metadata": { "editable": true }, @@ -2534,7 +1434,7 @@ }, { "cell_type": "markdown", - "id": "1596419b", + "id": "86661f7f", "metadata": { "editable": true }, @@ -2544,7 +1444,7 @@ }, { "cell_type": "markdown", - "id": "b3926fe3", + "id": "b7638311", "metadata": { "editable": true }, @@ -2556,7 +1456,7 @@ }, { "cell_type": "markdown", - "id": "4cbdb52c", + "id": "45f9847a", "metadata": { "editable": true }, @@ -2566,7 +1466,7 @@ }, { "cell_type": "markdown", - "id": "27ba313d", + "id": "48754bd5", "metadata": { "editable": true }, @@ -2578,7 +1478,7 @@ }, { "cell_type": "markdown", - "id": "83cdc9bd", + "id": "5c7a69fd", "metadata": { "editable": true }, @@ -2592,7 +1492,7 @@ }, { "cell_type": "markdown", - "id": "780ee74f", + "id": "be7536a6", "metadata": { "editable": true }, @@ -2604,7 +1504,7 @@ }, { "cell_type": "markdown", - "id": "cd0dab4a", + "id": "bca9c851", "metadata": { "editable": true }, @@ -2614,19 +1514,19 @@ }, { "cell_type": "markdown", - "id": "addbaad4", + "id": "86fbee3f", "metadata": { "editable": true }, "source": [ "$$\n", - "\\frac{\\partial{\\cal C}(\\boldsymbol{\\Theta}^L)}{\\partial w_{jk}^L} = \\left(a_j^L - y_j\\right)\\frac{\\partial a_j^L}{\\partial w_{jk}^{L}},\n", + "\\frac{\\partial{\\cal C}(\\boldsymbol{\\Theta}^L)}{\\partial w_{ij}^L} = \\left(a_j^L - y_j\\right)\\frac{\\partial a_j^L}{\\partial w_{ij}^{L}},\n", "$$" ] }, { "cell_type": "markdown", - "id": "206520cb", + "id": "11eaeef8", "metadata": { "editable": true }, @@ -2636,19 +1536,19 @@ }, { "cell_type": "markdown", - "id": "4c462cad", + "id": "80401b16", "metadata": { "editable": true }, "source": [ "$$\n", - "\\frac{\\partial a_j^L}{\\partial w_{jk}^{L}} = \\frac{\\partial a_j^L}{\\partial z_{j}^{L}}\\frac{\\partial z_j^L}{\\partial w_{jk}^{L}}=a_j^L(1-a_j^L)a_k^{L-1}.\n", + "\\frac{\\partial a_j^L}{\\partial w_{ij}^{L}} = \\frac{\\partial a_j^L}{\\partial z_{j}^{L}}\\frac{\\partial z_j^L}{\\partial w_{ij}^{L}}=a_j^L(1-a_j^L)a_i^{L-1}.\n", "$$" ] }, { "cell_type": "markdown", - "id": "7c2a29e8", + "id": "1072ac20", "metadata": { "editable": true }, @@ -2660,19 +1560,19 @@ }, { "cell_type": "markdown", - "id": "eb66f37b", + "id": "89ffde64", "metadata": { "editable": true }, "source": [ "$$\n", - "\\frac{\\partial{\\cal C}((\\boldsymbol{\\Theta}^L)}{\\partial w_{jk}^L} = \\left(a_j^L - y_j\\right)a_j^L(1-a_j^L)a_k^{L-1},\n", + "\\frac{\\partial{\\cal C}((\\boldsymbol{\\Theta}^L)}{\\partial w_{ij}^L} = \\left(a_j^L - y_j\\right)a_j^L(1-a_j^L)a_i^{L-1},\n", "$$" ] }, { "cell_type": "markdown", - "id": "a9d8ecfe", + "id": "325836cb", "metadata": { "editable": true }, @@ -2682,7 +1582,7 @@ }, { "cell_type": "markdown", - "id": "bbc11d6b", + "id": "a30436a3", "metadata": { "editable": true }, @@ -2694,7 +1594,7 @@ }, { "cell_type": "markdown", - "id": "a7386484", + "id": "641e2b0a", "metadata": { "editable": true }, @@ -2704,19 +1604,19 @@ }, { "cell_type": "markdown", - "id": "c9fa93c1", + "id": "14f11611", "metadata": { "editable": true }, "source": [ "$$\n", - "\\boldsymbol{\\delta}^L = \\sigma'(\\hat{z}^L)\\circ\\frac{\\partial {\\cal C}}{\\partial (\\boldsymbol{a}^L)}.\n", + "\\boldsymbol{\\delta}^L = \\sigma'(\\boldsymbol{z}^L)\\circ\\frac{\\partial {\\cal C}}{\\partial (\\boldsymbol{a}^L)}.\n", "$$" ] }, { "cell_type": "markdown", - "id": "fc10ec83", + "id": "49989080", "metadata": { "editable": true }, @@ -2734,7 +1634,7 @@ }, { "cell_type": "markdown", - "id": "8aa8880f", + "id": "f5a2ec44", "metadata": { "editable": true }, @@ -2752,7 +1652,7 @@ }, { "cell_type": "markdown", - "id": "83c9c075", + "id": "deb975c0", "metadata": { "editable": true }, @@ -2764,7 +1664,7 @@ }, { "cell_type": "markdown", - "id": "1be1d34f", + "id": "afc51f7d", "metadata": { "editable": true }, @@ -2774,19 +1674,19 @@ }, { "cell_type": "markdown", - "id": "3c847977", + "id": "429f602a", "metadata": { "editable": true }, "source": [ "$$\n", - "\\frac{\\partial{\\cal C}}{\\partial w_{jk}^L} = \\delta_j^La_k^{L-1}.\n", + "\\frac{\\partial{\\cal C}}{\\partial w_{ij}^L} = \\delta_j^La_i^{L-1}.\n", "$$" ] }, { "cell_type": "markdown", - "id": "a57bcd96", + "id": "e2edd78f", "metadata": { "editable": true }, @@ -2798,7 +1698,7 @@ }, { "cell_type": "markdown", - "id": "8fb635cc", + "id": "63f7032b", "metadata": { "editable": true }, @@ -2810,7 +1710,7 @@ }, { "cell_type": "markdown", - "id": "4ac99568", + "id": "f02b1a1b", "metadata": { "editable": true }, @@ -2820,7 +1720,7 @@ }, { "cell_type": "markdown", - "id": "8e7acd86", + "id": "0574e916", "metadata": { "editable": true }, @@ -2832,7 +1732,7 @@ }, { "cell_type": "markdown", - "id": "68758d65", + "id": "41bdc15f", "metadata": { "editable": true }, @@ -2842,7 +1742,7 @@ }, { "cell_type": "markdown", - "id": "e954a55d", + "id": "09cc68f7", "metadata": { "editable": true }, @@ -2854,7 +1754,7 @@ }, { "cell_type": "markdown", - "id": "b168ab5c", + "id": "b40293f4", "metadata": { "editable": true }, @@ -2864,7 +1764,7 @@ "\n", "$$\n", "\\begin{equation}\n", - "\\frac{\\partial{\\cal C}(\\hat{W^L})}{\\partial w_{jk}^L} = \\delta_j^La_k^{L-1},\n", + "\\frac{\\partial{\\cal C}(\\boldsymbol{W^L})}{\\partial w_{ij}^L} = \\delta_j^La_i^{L-1},\n", "\\label{_auto1} \\tag{1}\n", "\\end{equation}\n", "$$" @@ -2872,7 +1772,7 @@ }, { "cell_type": "markdown", - "id": "fe377dd7", + "id": "c3d18ebb", "metadata": { "editable": true }, @@ -2882,7 +1782,7 @@ }, { "cell_type": "markdown", - "id": "679eed39", + "id": "38775abe", "metadata": { "editable": true }, @@ -2900,7 +1800,7 @@ }, { "cell_type": "markdown", - "id": "f192a5a6", + "id": "5ec01530", "metadata": { "editable": true }, @@ -2910,7 +1810,7 @@ }, { "cell_type": "markdown", - "id": "54d27300", + "id": "b86f7ca4", "metadata": { "editable": true }, @@ -2928,7 +1828,7 @@ }, { "cell_type": "markdown", - "id": "08e1bbe0", + "id": "fd42f1c0", "metadata": { "editable": true }, @@ -2940,7 +1840,7 @@ }, { "cell_type": "markdown", - "id": "5f602d2a", + "id": "9904c840", "metadata": { "editable": true }, @@ -2952,7 +1852,7 @@ }, { "cell_type": "markdown", - "id": "54c9d793", + "id": "40481edd", "metadata": { "editable": true }, @@ -2962,7 +1862,7 @@ }, { "cell_type": "markdown", - "id": "bdc963ae", + "id": "92d8689b", "metadata": { "editable": true }, @@ -2974,7 +1874,7 @@ }, { "cell_type": "markdown", - "id": "2cbdc512", + "id": "22ec4130", "metadata": { "editable": true }, @@ -2986,7 +1886,7 @@ }, { "cell_type": "markdown", - "id": "64859c1b", + "id": "8491df20", "metadata": { "editable": true }, @@ -2996,7 +1896,7 @@ }, { "cell_type": "markdown", - "id": "5e704afb", + "id": "d4959520", "metadata": { "editable": true }, @@ -3008,7 +1908,7 @@ }, { "cell_type": "markdown", - "id": "0fd360a4", + "id": "0feb4648", "metadata": { "editable": true }, @@ -3018,7 +1918,7 @@ }, { "cell_type": "markdown", - "id": "f5735e76", + "id": "bd8747a2", "metadata": { "editable": true }, @@ -3030,7 +1930,7 @@ }, { "cell_type": "markdown", - "id": "3ea87117", + "id": "b13a8b94", "metadata": { "editable": true }, @@ -3042,7 +1942,7 @@ }, { "cell_type": "markdown", - "id": "a5fac002", + "id": "5e765c85", "metadata": { "editable": true }, @@ -3051,13 +1951,13 @@ "\n", "The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm.\n", "\n", - "**First**, we set up the input data $\\hat{x}$ and the activations\n", - "$\\hat{z}_1$ of the input layer and compute the activation function and\n", - "the pertinent outputs $\\hat{a}^1$.\n", + "**First**, we set up the input data $\\boldsymbol{x}$ and the activations\n", + "$\\boldsymbol{z}_1$ of the input layer and compute the activation function and\n", + "the pertinent outputs $\\boldsymbol{a}^1$.\n", "\n", "**Secondly**, we perform then the feed forward till we reach the output\n", - "layer and compute all $\\hat{z}_l$ of the input layer and compute the\n", - "activation function and the pertinent outputs $\\hat{a}^l$ for\n", + "layer and compute all $\\boldsymbol{z}_l$ of the input layer and compute the\n", + "activation function and the pertinent outputs $\\boldsymbol{a}^l$ for\n", "$l=1,2,3,\\dots,L$.\n", "\n", "**Notation**: The first hidden layer has $l=1$ as label and the final output layer has $l=L$." @@ -3065,19 +1965,19 @@ }, { "cell_type": "markdown", - "id": "507f82ab", + "id": "849bcaca", "metadata": { "editable": true }, "source": [ "## Setting up the back propagation algorithm, part 2\n", "\n", - "Thereafter we compute the ouput error $\\hat{\\delta}^L$ by computing all" + "Thereafter we compute the ouput error $\\boldsymbol{\\delta}^L$ by computing all" ] }, { "cell_type": "markdown", - "id": "978f8867", + "id": "12d2661b", "metadata": { "editable": true }, @@ -3089,7 +1989,7 @@ }, { "cell_type": "markdown", - "id": "721e0d30", + "id": "c7ebdf39", "metadata": { "editable": true }, @@ -3099,7 +1999,7 @@ }, { "cell_type": "markdown", - "id": "eea98531", + "id": "be4a1d22", "metadata": { "editable": true }, @@ -3111,7 +2011,7 @@ }, { "cell_type": "markdown", - "id": "cec652d7", + "id": "1f93b3f8", "metadata": { "editable": true }, @@ -3119,25 +2019,25 @@ "## Setting up the Back propagation algorithm, part 3\n", "\n", "Finally, we update the weights and the biases using gradient descent\n", - "for each $l=L-1,L-2,\\dots,1$ and update the weights and biases\n", + "for each $l=L-1,L-2,\\dots,1$ (the first hidden layer) and update the weights and biases\n", "according to the rules" ] }, { "cell_type": "markdown", - "id": "686a0fe6", + "id": "3dd41f12", "metadata": { "editable": true }, "source": [ "$$\n", - "w_{jk}^l\\leftarrow = w_{jk}^l- \\eta \\delta_j^la_k^{l-1},\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", "$$" ] }, { "cell_type": "markdown", - "id": "8ede23f2", + "id": "0e84ce0b", "metadata": { "editable": true }, @@ -3149,7 +2049,7 @@ }, { "cell_type": "markdown", - "id": "beaa8b55", + "id": "a9bfd977", "metadata": { "editable": true }, @@ -3159,7 +2059,7 @@ }, { "cell_type": "markdown", - "id": "f11ccc11", + "id": "19d2fec5", "metadata": { "editable": true }, @@ -3171,19 +2071,19 @@ }, { "cell_type": "markdown", - "id": "37b975fb", + "id": "0ed61a3b", "metadata": { "editable": true }, "source": [ "$$\n", - "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l),\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l),\n", "$$" ] }, { "cell_type": "markdown", - "id": "d7478e45", + "id": "0c42324f", "metadata": { "editable": true }, @@ -3193,19 +2093,19 @@ }, { "cell_type": "markdown", - "id": "d6afd100", + "id": "5509053e", "metadata": { "editable": true }, "source": [ "$$\n", - "w_{jk}^l\\leftarrow = w_{jk}^l- \\eta \\delta_j^la_k^{l-1},\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", "$$" ] }, { "cell_type": "markdown", - "id": "00eb4607", + "id": "8c989c9e", "metadata": { "editable": true }, @@ -3217,7 +2117,7 @@ }, { "cell_type": "markdown", - "id": "5302dc01", + "id": "e49cc8bb", "metadata": { "editable": true }, @@ -3240,7 +2140,7 @@ }, { "cell_type": "markdown", - "id": "8fb04c45", + "id": "c950cb42", "metadata": { "editable": true }, @@ -3259,19 +2159,19 @@ }, { "cell_type": "markdown", - "id": "1d8fdcb2", + "id": "b3f1cb1d", "metadata": { "editable": true }, "source": [ "$$\n", - "f(x) = \\frac{1}{1 + e^{-x}},\n", + "\\sigma(x) = \\frac{1}{1 + e^{-x}},\n", "$$" ] }, { "cell_type": "markdown", - "id": "da2f664b", + "id": "b09b88af", "metadata": { "editable": true }, @@ -3281,19 +2181,19 @@ }, { "cell_type": "markdown", - "id": "322b8716", + "id": "0580595f", "metadata": { "editable": true }, "source": [ "$$\n", - "f(x) = \\tanh(x)\n", + "\\sigma(x) = \\tanh(x)\n", "$$" ] }, { "cell_type": "markdown", - "id": "ea2eb00e", + "id": "c59b68cf", "metadata": { "editable": true }, @@ -3309,8 +2209,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "c666b075", + "execution_count": 2, + "id": "c1d4f091", "metadata": { "collapsed": false, "editable": true @@ -3394,7 +2294,7 @@ }, { "cell_type": "markdown", - "id": "bc0f22f0", + "id": "ab302230", "metadata": { "editable": true }, @@ -3423,7 +2323,7 @@ }, { "cell_type": "markdown", - "id": "23b7e79c", + "id": "3cde68ea", "metadata": { "editable": true }, @@ -3449,7 +2349,7 @@ }, { "cell_type": "markdown", - "id": "28996a44", + "id": "e0b04810", "metadata": { "editable": true }, @@ -3471,7 +2371,7 @@ }, { "cell_type": "markdown", - "id": "d9f2f0be", + "id": "dd7968ba", "metadata": { "editable": true }, @@ -3489,7 +2389,7 @@ }, { "cell_type": "markdown", - "id": "45800fa9", + "id": "6fb372cb", "metadata": { "editable": true }, @@ -3512,7 +2412,7 @@ }, { "cell_type": "markdown", - "id": "0069e3d4", + "id": "f04d9799", "metadata": { "editable": true }, @@ -3531,7 +2431,7 @@ }, { "cell_type": "markdown", - "id": "b3228d7a", + "id": "c258546e", "metadata": { "editable": true }, @@ -3559,7 +2459,7 @@ }, { "cell_type": "markdown", - "id": "3a99037d", + "id": "356cd43c", "metadata": { "editable": true }, @@ -3579,7 +2479,7 @@ }, { "cell_type": "markdown", - "id": "7cde776c", + "id": "ea800ab5", "metadata": { "editable": true }, @@ -3600,7 +2500,7 @@ }, { "cell_type": "markdown", - "id": "bdabe170", + "id": "96b69144", "metadata": { "editable": true }, @@ -3614,7 +2514,7 @@ }, { "cell_type": "markdown", - "id": "f7f8604a", + "id": "ca2cf253", "metadata": { "editable": true }, @@ -3626,7 +2526,7 @@ }, { "cell_type": "markdown", - "id": "030848f5", + "id": "5cc62a16", "metadata": { "editable": true }, @@ -3648,7 +2548,7 @@ }, { "cell_type": "markdown", - "id": "582e0af4", + "id": "3afc6427", "metadata": { "editable": true }, @@ -3670,7 +2570,7 @@ }, { "cell_type": "markdown", - "id": "591e4534", + "id": "f7bd09b4", "metadata": { "editable": true }, @@ -3696,7 +2596,7 @@ }, { "cell_type": "markdown", - "id": "5c7fbeeb", + "id": "370453da", "metadata": { "editable": true }, @@ -3716,7 +2616,7 @@ }, { "cell_type": "markdown", - "id": "5d6e97ae", + "id": "6dce1d04", "metadata": { "editable": true }, @@ -3736,7 +2636,7 @@ }, { "cell_type": "markdown", - "id": "b349eb99", + "id": "910f2a34", "metadata": { "editable": true }, @@ -3762,7 +2662,7 @@ }, { "cell_type": "markdown", - "id": "4209c8ac", + "id": "cfaf1f5f", "metadata": { "editable": true }, @@ -3791,7 +2691,7 @@ }, { "cell_type": "markdown", - "id": "1f935cef", + "id": "fece4515", "metadata": { "editable": true }, @@ -3809,7 +2709,7 @@ }, { "cell_type": "markdown", - "id": "19b4d572", + "id": "5dda98bd", "metadata": { "editable": true }, @@ -3825,7 +2725,7 @@ }, { "cell_type": "markdown", - "id": "86136afa", + "id": "161c505e", "metadata": { "editable": true }, @@ -3837,7 +2737,7 @@ }, { "cell_type": "markdown", - "id": "fb173300", + "id": "d60af03f", "metadata": { "editable": true }, @@ -3851,7 +2751,7 @@ }, { "cell_type": "markdown", - "id": "2d99d133", + "id": "d8e4db81", "metadata": { "editable": true }, @@ -3874,7 +2774,7 @@ }, { "cell_type": "markdown", - "id": "d95a57f5", + "id": "14ab8c21", "metadata": { "editable": true }, @@ -3886,7 +2786,7 @@ }, { "cell_type": "markdown", - "id": "96cbb19a", + "id": "7356a830", "metadata": { "editable": true }, @@ -3896,19 +2796,19 @@ }, { "cell_type": "markdown", - "id": "6bf6db79", + "id": "26cd1439", "metadata": { "editable": true }, "source": [ "$$\n", - "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l).\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l).\n", "$$" ] }, { "cell_type": "markdown", - "id": "2b52586e", + "id": "a8e13b66", "metadata": { "editable": true }, @@ -3918,19 +2818,19 @@ }, { "cell_type": "markdown", - "id": "d9ab881f", + "id": "205ebbe0", "metadata": { "editable": true }, "source": [ "$$\n", - "w_{jk}^l\\leftarrow = w_{jk}^l- \\eta \\delta_j^la_k^{l-1},\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", "$$" ] }, { "cell_type": "markdown", - "id": "910741f1", + "id": "551a96dc", "metadata": { "editable": true }, @@ -3942,7 +2842,7 @@ }, { "cell_type": "markdown", - "id": "9d905ba4", + "id": "1c0b3401", "metadata": { "editable": true }, @@ -3953,7 +2853,7 @@ }, { "cell_type": "markdown", - "id": "3934fbbc", + "id": "5ad8c77b", "metadata": { "editable": true }, @@ -3981,7 +2881,7 @@ }, { "cell_type": "markdown", - "id": "4f91daa7", + "id": "b6533f98", "metadata": { "editable": true }, @@ -3993,7 +2893,7 @@ }, { "cell_type": "markdown", - "id": "1ecdd033", + "id": "bb2d393f", "metadata": { "editable": true }, @@ -4003,7 +2903,7 @@ }, { "cell_type": "markdown", - "id": "9f7289fb", + "id": "2e148310", "metadata": { "editable": true }, @@ -4015,7 +2915,7 @@ }, { "cell_type": "markdown", - "id": "ae3cd357", + "id": "b5d87151", "metadata": { "editable": true }, @@ -4026,7 +2926,7 @@ }, { "cell_type": "markdown", - "id": "3d047b07", + "id": "28e2d06e", "metadata": { "editable": true }, @@ -4038,7 +2938,7 @@ }, { "cell_type": "markdown", - "id": "a08dbe7d", + "id": "eda4883d", "metadata": { "editable": true }, @@ -4051,7 +2951,7 @@ }, { "cell_type": "markdown", - "id": "8d0c381e", + "id": "71ce4abc", "metadata": { "editable": true }, @@ -4076,7 +2976,7 @@ }, { "cell_type": "markdown", - "id": "e6c9415e", + "id": "4c611560", "metadata": { "editable": true }, @@ -4089,7 +2989,7 @@ }, { "cell_type": "markdown", - "id": "df5d8101", + "id": "2c0d438a", "metadata": { "editable": true }, @@ -4101,7 +3001,7 @@ }, { "cell_type": "markdown", - "id": "f20ca152", + "id": "6c98d19b", "metadata": { "editable": true }, @@ -4113,7 +3013,7 @@ }, { "cell_type": "markdown", - "id": "dd13ab62", + "id": "4d00e55a", "metadata": { "editable": true }, @@ -4123,7 +3023,7 @@ }, { "cell_type": "markdown", - "id": "c845d11c", + "id": "c9aada26", "metadata": { "editable": true }, @@ -4135,7 +3035,7 @@ }, { "cell_type": "markdown", - "id": "65fdee85", + "id": "a3b4dd2f", "metadata": { "editable": true }, @@ -4147,7 +3047,7 @@ }, { "cell_type": "markdown", - "id": "08eca06f", + "id": "eec6576a", "metadata": { "editable": true }, @@ -4159,7 +3059,7 @@ }, { "cell_type": "markdown", - "id": "a0d3f787", + "id": "85f8ed7a", "metadata": { "editable": true }, @@ -4171,7 +3071,7 @@ }, { "cell_type": "markdown", - "id": "c6717a0f", + "id": "f2f13ddb", "metadata": { "editable": true }, @@ -4181,7 +3081,7 @@ }, { "cell_type": "markdown", - "id": "845dcb7a", + "id": "22b642fc", "metadata": { "editable": true }, @@ -4193,7 +3093,7 @@ }, { "cell_type": "markdown", - "id": "d8c37f3c", + "id": "6178c894", "metadata": { "editable": true }, @@ -4203,7 +3103,7 @@ }, { "cell_type": "markdown", - "id": "e1442769", + "id": "38e05b57", "metadata": { "editable": true }, @@ -4215,7 +3115,7 @@ }, { "cell_type": "markdown", - "id": "19b80e63", + "id": "9a4f4808", "metadata": { "editable": true }, @@ -4228,7 +3128,7 @@ }, { "cell_type": "markdown", - "id": "8fcc5767", + "id": "465d3ffc", "metadata": { "editable": true }, @@ -4240,7 +3140,7 @@ }, { "cell_type": "markdown", - "id": "67fa04a6", + "id": "d5da2c3b", "metadata": { "editable": true }, @@ -4250,7 +3150,7 @@ }, { "cell_type": "markdown", - "id": "306db596", + "id": "d4eb87c0", "metadata": { "editable": true }, @@ -4262,7 +3162,7 @@ }, { "cell_type": "markdown", - "id": "f8e1c07d", + "id": "67788627", "metadata": { "editable": true }, @@ -4273,7 +3173,7 @@ }, { "cell_type": "markdown", - "id": "f35e084e", + "id": "1fb29f4a", "metadata": { "editable": true }, @@ -4285,7 +3185,7 @@ }, { "cell_type": "markdown", - "id": "83f30316", + "id": "81955be4", "metadata": { "editable": true }, @@ -4295,7 +3195,7 @@ }, { "cell_type": "markdown", - "id": "759cafb3", + "id": "5233b18b", "metadata": { "editable": true }, @@ -4307,7 +3207,7 @@ }, { "cell_type": "markdown", - "id": "3ec7443d", + "id": "326d597b", "metadata": { "editable": true }, @@ -4317,7 +3217,7 @@ }, { "cell_type": "markdown", - "id": "9239002f", + "id": "5d331cc6", "metadata": { "editable": true }, @@ -4328,7 +3228,7 @@ }, { "cell_type": "markdown", - "id": "ac650a2b", + "id": "ba07203c", "metadata": { "editable": true }, @@ -4341,7 +3241,7 @@ }, { "cell_type": "markdown", - "id": "db17e50a", + "id": "4280c0c6", "metadata": { "editable": true }, @@ -4351,7 +3251,7 @@ }, { "cell_type": "markdown", - "id": "900bf5eb", + "id": "6448b342", "metadata": { "editable": true }, @@ -4363,7 +3263,7 @@ }, { "cell_type": "markdown", - "id": "39f15930", + "id": "3881713b", "metadata": { "editable": true }, @@ -4373,7 +3273,7 @@ }, { "cell_type": "markdown", - "id": "cf388a03", + "id": "9dc18af4", "metadata": { "editable": true }, @@ -4385,7 +3285,7 @@ }, { "cell_type": "markdown", - "id": "f460bb98", + "id": "238cb866", "metadata": { "editable": true }, @@ -4395,7 +3295,7 @@ }, { "cell_type": "markdown", - "id": "a70ab930", + "id": "ad0c9102", "metadata": { "editable": true }, @@ -4419,7 +3319,7 @@ }, { "cell_type": "markdown", - "id": "309a7941", + "id": "41d90e91", "metadata": { "editable": true }, @@ -4468,8 +3368,8 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "24f37ad6", + "execution_count": 3, + "id": "3f281bbf", "metadata": { "collapsed": false, "editable": true @@ -4522,7 +3422,7 @@ }, { "cell_type": "markdown", - "id": "ef046f93", + "id": "8c745ae2", "metadata": { "editable": true }, @@ -4542,8 +3442,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "b34793d5", + "execution_count": 4, + "id": "cec6ceb5", "metadata": { "collapsed": false, "editable": true @@ -4581,7 +3481,7 @@ }, { "cell_type": "markdown", - "id": "a529b30e", + "id": "67ed0f4e", "metadata": { "editable": true }, @@ -4625,7 +3525,7 @@ }, { "cell_type": "markdown", - "id": "a6675ce3", + "id": "dddab3f1", "metadata": { "editable": true }, @@ -4665,7 +3565,7 @@ }, { "cell_type": "markdown", - "id": "7b4ece6d", + "id": "6de261cd", "metadata": { "editable": true }, @@ -4685,8 +3585,8 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "a091d233", + "execution_count": 5, + "id": "f55b95fc", "metadata": { "collapsed": false, "editable": true @@ -4712,7 +3612,7 @@ }, { "cell_type": "markdown", - "id": "d468e760", + "id": "e4048837", "metadata": { "editable": true }, @@ -4740,7 +3640,7 @@ }, { "cell_type": "markdown", - "id": "c2e3b8eb", + "id": "8d8e15ea", "metadata": { "editable": true }, @@ -4776,8 +3676,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "bef31ef6", + "execution_count": 6, + "id": "c366cb05", "metadata": { "collapsed": false, "editable": true @@ -4823,7 +3723,7 @@ }, { "cell_type": "markdown", - "id": "518b8815", + "id": "a329838e", "metadata": { "editable": true }, @@ -4854,7 +3754,7 @@ }, { "cell_type": "markdown", - "id": "123c88a9", + "id": "acc107d3", "metadata": { "editable": true }, @@ -4892,7 +3792,7 @@ }, { "cell_type": "markdown", - "id": "b3965278", + "id": "b7513f34", "metadata": { "editable": true }, @@ -4926,7 +3826,7 @@ }, { "cell_type": "markdown", - "id": "82fe6fc2", + "id": "80d4c1fa", "metadata": { "editable": true }, @@ -4966,8 +3866,8 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "4cd2d778", + "execution_count": 7, + "id": "717ac016", "metadata": { "collapsed": false, "editable": true @@ -5046,7 +3946,7 @@ }, { "cell_type": "markdown", - "id": "b89c18e9", + "id": "c5578ae4", "metadata": { "editable": true }, @@ -5067,7 +3967,7 @@ }, { "cell_type": "markdown", - "id": "e9b89422", + "id": "897b827c", "metadata": { "editable": true }, @@ -5080,8 +3980,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "id": "89eba703", + "execution_count": 8, + "id": "2d81f6b5", "metadata": { "collapsed": false, "editable": true @@ -5191,7 +4091,7 @@ }, { "cell_type": "markdown", - "id": "d8b7e64b", + "id": "71093a4f", "metadata": { "editable": true }, @@ -5209,8 +4109,8 @@ }, { "cell_type": "code", - "execution_count": 11, - "id": "21181c7b", + "execution_count": 9, + "id": "dbda9e36", "metadata": { "collapsed": false, "editable": true @@ -5237,7 +4137,7 @@ }, { "cell_type": "markdown", - "id": "16a32cf3", + "id": "d1baf786", "metadata": { "editable": true }, @@ -5250,8 +4150,8 @@ }, { "cell_type": "code", - "execution_count": 12, - "id": "dd9d7c2c", + "execution_count": 10, + "id": "07cfe247", "metadata": { "collapsed": false, "editable": true @@ -5282,7 +4182,7 @@ }, { "cell_type": "markdown", - "id": "a1fd219b", + "id": "333bada1", "metadata": { "editable": true }, @@ -5292,8 +4192,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "id": "8a636aa8", + "execution_count": 11, + "id": "4aa6acfb", "metadata": { "collapsed": false, "editable": true @@ -5337,7 +4237,7 @@ }, { "cell_type": "markdown", - "id": "59def5a3", + "id": "40608240", "metadata": { "editable": true }, @@ -5359,8 +4259,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "3c3419f5", + "execution_count": 12, + "id": "ebb62e20", "metadata": { "collapsed": false, "editable": true @@ -5387,7 +4287,7 @@ }, { "cell_type": "markdown", - "id": "ffa0f6b9", + "id": "893ff59f", "metadata": { "editable": true }, @@ -5397,8 +4297,8 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "1bacf2c0", + "execution_count": 13, + "id": "5063e339", "metadata": { "collapsed": false, "editable": true @@ -5443,7 +4343,7 @@ }, { "cell_type": "markdown", - "id": "c5a4a5c3", + "id": "4f48007a", "metadata": { "editable": true }, @@ -5461,7 +4361,7 @@ }, { "cell_type": "markdown", - "id": "fb6e2cb5", + "id": "093bd249", "metadata": { "editable": true }, @@ -5495,8 +4395,8 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "ae8ceee0", + "execution_count": 14, + "id": "f592148d", "metadata": { "collapsed": false, "editable": true @@ -5508,7 +4408,7 @@ }, { "cell_type": "markdown", - "id": "ce53eff3", + "id": "78c5fc79", "metadata": { "editable": true }, @@ -5519,8 +4419,8 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "ba642745", + "execution_count": 15, + "id": "3a17f898", "metadata": { "collapsed": false, "editable": true @@ -5533,7 +4433,7 @@ }, { "cell_type": "markdown", - "id": "a1120e60", + "id": "1909eced", "metadata": { "editable": true }, @@ -5543,8 +4443,8 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "41492080", + "execution_count": 16, + "id": "5156163c", "metadata": { "collapsed": false, "editable": true @@ -5557,7 +4457,7 @@ }, { "cell_type": "markdown", - "id": "a9961e87", + "id": "230b7faa", "metadata": { "editable": true }, @@ -5571,8 +4471,8 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "7b07c4fa", + "execution_count": 17, + "id": "1eef0b98", "metadata": { "collapsed": false, "editable": true @@ -5584,7 +4484,7 @@ }, { "cell_type": "markdown", - "id": "88a4c19d", + "id": "cea9bd1a", "metadata": { "editable": true }, @@ -5596,7 +4496,7 @@ }, { "cell_type": "markdown", - "id": "250ee926", + "id": "99d7772b", "metadata": { "editable": true }, @@ -5608,8 +4508,8 @@ }, { "cell_type": "code", - "execution_count": 20, - "id": "9b31890f", + "execution_count": 18, + "id": "6c6f5bfc", "metadata": { "collapsed": false, "editable": true @@ -5663,8 +4563,8 @@ }, { "cell_type": "code", - "execution_count": 21, - "id": "84b23da0", + "execution_count": 19, + "id": "4fc79e1e", "metadata": { "collapsed": false, "editable": true @@ -5692,8 +4592,8 @@ }, { "cell_type": "code", - "execution_count": 22, - "id": "5458316d", + "execution_count": 20, + "id": "241dcbec", "metadata": { "collapsed": false, "editable": true @@ -5722,8 +4622,8 @@ }, { "cell_type": "code", - "execution_count": 23, - "id": "cf7f4c0c", + "execution_count": 21, + "id": "1936206d", "metadata": { "collapsed": false, "editable": true @@ -5749,8 +4649,8 @@ }, { "cell_type": "code", - "execution_count": 24, - "id": "e0907d51", + "execution_count": 22, + "id": "e52140a7", "metadata": { "collapsed": false, "editable": true @@ -5792,7 +4692,7 @@ }, { "cell_type": "markdown", - "id": "3c5f6244", + "id": "665b3ebd", "metadata": { "editable": true }, @@ -5802,8 +4702,8 @@ }, { "cell_type": "code", - "execution_count": 25, - "id": "40958884", + "execution_count": 23, + "id": "36caace7", "metadata": { "collapsed": false, "editable": true @@ -5980,7 +4880,7 @@ }, { "cell_type": "markdown", - "id": "c99dec14", + "id": "9f85a17f", "metadata": { "editable": true }, @@ -5999,7 +4899,7 @@ }, { "cell_type": "markdown", - "id": "d6694a1a", + "id": "6d9cfcc8", "metadata": { "editable": true }, @@ -6020,8 +4920,8 @@ }, { "cell_type": "code", - "execution_count": 26, - "id": "2c6dee13", + "execution_count": 24, + "id": "be81a71a", "metadata": { "collapsed": false, "editable": true @@ -6162,7 +5062,7 @@ }, { "cell_type": "markdown", - "id": "42f65148", + "id": "63283a38", "metadata": { "editable": true }, @@ -6177,8 +5077,8 @@ }, { "cell_type": "code", - "execution_count": 27, - "id": "52462d73", + "execution_count": 25, + "id": "9584fa14", "metadata": { "collapsed": false, "editable": true @@ -6191,7 +5091,7 @@ }, { "cell_type": "markdown", - "id": "413f1a7f", + "id": "2a5616ae", "metadata": { "editable": true }, @@ -6202,8 +5102,8 @@ }, { "cell_type": "code", - "execution_count": 28, - "id": "1dab11ab", + "execution_count": 26, + "id": "866b3bfa", "metadata": { "collapsed": false, "editable": true @@ -6225,7 +5125,7 @@ }, { "cell_type": "markdown", - "id": "aa401c67", + "id": "756d05d2", "metadata": { "editable": true }, @@ -6240,8 +5140,8 @@ }, { "cell_type": "code", - "execution_count": 29, - "id": "6c18b101", + "execution_count": 27, + "id": "d8850104", "metadata": { "collapsed": false, "editable": true @@ -6279,7 +5179,7 @@ }, { "cell_type": "markdown", - "id": "c5ebf089", + "id": "8edc05c4", "metadata": { "editable": true }, @@ -6291,8 +5191,8 @@ }, { "cell_type": "code", - "execution_count": 30, - "id": "6091c829", + "execution_count": 28, + "id": "a9e67ca3", "metadata": { "collapsed": false, "editable": true @@ -6313,7 +5213,7 @@ }, { "cell_type": "markdown", - "id": "833b9bc0", + "id": "1dd64c49", "metadata": { "editable": true }, @@ -6328,8 +5228,8 @@ }, { "cell_type": "code", - "execution_count": 31, - "id": "32de31f1", + "execution_count": 29, + "id": "129aad84", "metadata": { "collapsed": false, "editable": true @@ -6387,7 +5287,7 @@ }, { "cell_type": "markdown", - "id": "80f8e150", + "id": "e4dfc795", "metadata": { "editable": true }, @@ -6401,8 +5301,8 @@ }, { "cell_type": "code", - "execution_count": 32, - "id": "a0ba84c5", + "execution_count": 30, + "id": "c0e717fc", "metadata": { "collapsed": false, "editable": true @@ -6423,7 +5323,7 @@ }, { "cell_type": "markdown", - "id": "2bc9f6e4", + "id": "29b69c91", "metadata": { "editable": true }, @@ -6446,8 +5346,8 @@ }, { "cell_type": "code", - "execution_count": 33, - "id": "43ffbd42", + "execution_count": 31, + "id": "904c351d", "metadata": { "collapsed": false, "editable": true @@ -6919,7 +5819,7 @@ }, { "cell_type": "markdown", - "id": "38690fd3", + "id": "2673e5bc", "metadata": { "editable": true }, @@ -6930,8 +5830,8 @@ }, { "cell_type": "code", - "execution_count": 34, - "id": "a02f5942", + "execution_count": 32, + "id": "10ba6bc4", "metadata": { "collapsed": false, "editable": true @@ -6975,7 +5875,7 @@ }, { "cell_type": "markdown", - "id": "97f01de8", + "id": "d452842e", "metadata": { "editable": true }, @@ -6990,8 +5890,8 @@ }, { "cell_type": "code", - "execution_count": 35, - "id": "bba882b0", + "execution_count": 33, + "id": "2871b76c", "metadata": { "collapsed": false, "editable": true @@ -7006,7 +5906,7 @@ }, { "cell_type": "markdown", - "id": "83011027", + "id": "9e2a0f1d", "metadata": { "editable": true }, @@ -7016,8 +5916,8 @@ }, { "cell_type": "code", - "execution_count": 36, - "id": "7f60aa19", + "execution_count": 34, + "id": "95caf15c", "metadata": { "collapsed": false, "editable": true @@ -7032,7 +5932,7 @@ }, { "cell_type": "markdown", - "id": "b54ac065", + "id": "33f4287b", "metadata": { "editable": true }, @@ -7047,8 +5947,8 @@ }, { "cell_type": "code", - "execution_count": 37, - "id": "027bf397", + "execution_count": 35, + "id": "19065db0", "metadata": { "collapsed": false, "editable": true @@ -7062,7 +5962,7 @@ }, { "cell_type": "markdown", - "id": "0e8f8d78", + "id": "6715b1fc", "metadata": { "editable": true }, @@ -7076,8 +5976,8 @@ }, { "cell_type": "code", - "execution_count": 38, - "id": "c45642bf", + "execution_count": 36, + "id": "1958e0dd", "metadata": { "collapsed": false, "editable": true @@ -7102,8 +6002,8 @@ }, { "cell_type": "code", - "execution_count": 39, - "id": "91bd0e44", + "execution_count": 37, + "id": "d33c99ee", "metadata": { "collapsed": false, "editable": true @@ -7118,7 +6018,7 @@ }, { "cell_type": "markdown", - "id": "6abca79d", + "id": "2763a4de", "metadata": { "editable": true }, @@ -7128,8 +6028,8 @@ }, { "cell_type": "code", - "execution_count": 40, - "id": "40aa4292", + "execution_count": 38, + "id": "04cbbddf", "metadata": { "collapsed": false, "editable": true @@ -7144,7 +6044,7 @@ }, { "cell_type": "markdown", - "id": "50dddaba", + "id": "f405b627", "metadata": { "editable": true }, @@ -7154,8 +6054,8 @@ }, { "cell_type": "code", - "execution_count": 41, - "id": "8f1ef4c8", + "execution_count": 39, + "id": "efbfba8c", "metadata": { "collapsed": false, "editable": true @@ -7174,8 +6074,8 @@ }, { "cell_type": "code", - "execution_count": 42, - "id": "b98ff415", + "execution_count": 40, + "id": "bf066770", "metadata": { "collapsed": false, "editable": true @@ -7190,7 +6090,7 @@ }, { "cell_type": "markdown", - "id": "7809dfee", + "id": "3b99ffc1", "metadata": { "editable": true }, @@ -7204,8 +6104,8 @@ }, { "cell_type": "code", - "execution_count": 43, - "id": "8f154790", + "execution_count": 41, + "id": "f85167ba", "metadata": { "collapsed": false, "editable": true @@ -7242,7 +6142,7 @@ }, { "cell_type": "markdown", - "id": "b3a6091a", + "id": "d614b967", "metadata": { "editable": true }, @@ -7254,8 +6154,8 @@ }, { "cell_type": "code", - "execution_count": 44, - "id": "71ee86a2", + "execution_count": 42, + "id": "f4d5609a", "metadata": { "collapsed": false, "editable": true @@ -7278,7 +6178,7 @@ }, { "cell_type": "markdown", - "id": "27a30ed3", + "id": "efce242a", "metadata": { "editable": true }, diff --git a/doc/src/week42/week42.do.txt b/doc/src/week42/week42.do.txt index d94a44012..900da32a2 100644 --- a/doc/src/week42/week42.do.txt +++ b/doc/src/week42/week42.do.txt @@ -26,6 +26,7 @@ I also recommend Michael Nielsen's intuitive approach to the neural networks an * Discussion of project 2 !eblock +_Note_: some of the codes will also be discussed next week in connection with the solution of differential equations. !split @@ -34,7 +35,7 @@ I also recommend Michael Nielsen's intuitive approach to the neural networks an Last week we discussed the basics of neural networks and deep learning and the basics of automatic differentiation. We looked also at examples on how compute the parameters of a simple network with scalar -inputs and ouputs and no or just one hiden layers. +inputs and ouputs and no or just one hidden layers. We ended our discussions with the derivation of the equations for a @@ -576,7 +577,7 @@ network $\bm{\tilde{y}}$ and the inputs $\bm{x}$ we define now the activation $z_j^l$ of node/neuron/unit $j$ of the $l$-th layer as a function of the bias, the weights which add up from the previous layer $l-1$ and the forward passes/outputs -$\hat{a}^{l-1}$ from the previous layer as +$\bm{a}^{l-1}$ from the previous layer as !bt @@ -684,7 +685,7 @@ Defining and using the Hadamard product of two vectors we can write this as !bt \[ -\bm{\delta}^L = \sigma'(\hat{z}^L)\circ\frac{\partial {\cal C}}{\partial (\bm{a}^L)}. +\bm{\delta}^L = \sigma'(\bm{z}^L)\circ\frac{\partial {\cal C}}{\partial (\bm{a}^L)}. \] !et @@ -720,7 +721,7 @@ trouble in calculating With the definition of $\delta_j^L$ we have a more compact definition of the derivative of the cost function in terms of the weights, namely !bt \[ -\frac{\partial{\cal C}}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +\frac{\partial{\cal C}}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}. \] !et @@ -749,7 +750,7 @@ We have now three equations that are essential for the computations of the deriv !bt \begin{equation} -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, +\frac{\partial{\cal C}(\bm{W^L})}{\partial w_{ij}^L} = \delta_j^La_i^{L-1}, \end{equation} !et and @@ -808,13 +809,13 @@ We are now ready to set up the algorithm for back propagation and learning the w The four equations provide us with a way of computing the gradient of the cost function. Let us write this out in the form of an algorithm. -_First_, we set up the input data $\hat{x}$ and the activations -$\hat{z}_1$ of the input layer and compute the activation function and -the pertinent outputs $\hat{a}^1$. +_First_, we set up the input data $\bm{x}$ and the activations +$\bm{z}_1$ of the input layer and compute the activation function and +the pertinent outputs $\bm{a}^1$. _Secondly_, we perform then the feed forward till we reach the output -layer and compute all $\hat{z}_l$ of the input layer and compute the -activation function and the pertinent outputs $\hat{a}^l$ for +layer and compute all $\bm{z}_l$ of the input layer and compute the +activation function and the pertinent outputs $\bm{a}^l$ for $l=1,2,3,\dots,L$. @@ -824,7 +825,7 @@ _Notation_: The first hidden layer has $l=1$ as label and the final output layer ===== Setting up the back propagation algorithm, part 2 ===== -Thereafter we compute the ouput error $\hat{\delta}^L$ by computing all +Thereafter we compute the ouput error $\bm{\delta}^L$ by computing all !bt \[ \delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. @@ -843,12 +844,12 @@ Then we compute the back propagate error for each $l=L-1,L-2,\dots,1$ as Finally, we update the weights and the biases using gradient descent -for each $l=L-1,L-2,\dots,1$ and update the weights and biases +for each $l=L-1,L-2,\dots,1$ (the first hidden layer) and update the weights and biases according to the rules !bt \[ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, \] !et @@ -865,13 +866,13 @@ with $\eta$ being the learning rate. With the back propagate error for each $l=L-1,L-2,\dots,1$ as !bt \[ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}sigma'(z_j^l), +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), \] !et we update the weights and the biases using gradient descent for each $l=L-1,L-2,\dots,1$ and update the weights and biases according to the rules !bt \[ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, \] !et @@ -917,13 +918,13 @@ functions Typical examples are the logistic *Sigmoid* !bt \[ - f(x) = \frac{1}{1 + e^{-x}}, + \sigma(x) = \frac{1}{1 + e^{-x}}, \] !et and the *hyperbolic tangent* function !bt \[ - f(x) = \tanh(x) + \sigma(x) = \tanh(x) \] !et @@ -1012,10 +1013,6 @@ plt.show() - - - - !split ===== Fine-tuning neural network hyperparameters ===== @@ -1378,7 +1375,7 @@ Thereafter we compute the ouput error $\bm{\delta}^L$ by computing all Then we compute the back propagate error for each $l=L-1,L-2,\dots,2$ as !bt \[ -\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l). +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). \] !et !eblock @@ -1387,7 +1384,7 @@ Then we compute the back propagate error for each $l=L-1,L-2,\dots,2$ as Finally, we update the weights and the biases using gradient descent for each $l=L-1,L-2,\dots,2$ and update the weights and biases according to the rules !bt \[ -w_{jk}^l\leftarrow = w_{jk}^l- \eta \delta_j^la_k^{l-1}, +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, \] !et