From ea640c443edd51821db77054f73d3041355fe988 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Tue, 16 Nov 2021 06:44:26 +0100 Subject: [PATCH] update on week40 --- doc/pub/week40/html/._week40-bs000.html | 118 +- doc/pub/week40/html/._week40-bs001.html | 116 +- doc/pub/week40/html/._week40-bs002.html | 116 +- doc/pub/week40/html/._week40-bs003.html | 116 +- doc/pub/week40/html/._week40-bs004.html | 116 +- doc/pub/week40/html/._week40-bs005.html | 116 +- doc/pub/week40/html/._week40-bs006.html | 116 +- doc/pub/week40/html/._week40-bs007.html | 116 +- doc/pub/week40/html/._week40-bs008.html | 116 +- doc/pub/week40/html/._week40-bs009.html | 116 +- doc/pub/week40/html/._week40-bs010.html | 116 +- doc/pub/week40/html/._week40-bs011.html | 116 +- doc/pub/week40/html/._week40-bs012.html | 116 +- doc/pub/week40/html/._week40-bs013.html | 152 +- doc/pub/week40/html/._week40-bs014.html | 154 +- doc/pub/week40/html/._week40-bs015.html | 172 +-- doc/pub/week40/html/._week40-bs016.html | 183 ++- doc/pub/week40/html/._week40-bs017.html | 159 +- doc/pub/week40/html/._week40-bs018.html | 169 +-- doc/pub/week40/html/._week40-bs019.html | 169 ++- doc/pub/week40/html/._week40-bs020.html | 218 +-- doc/pub/week40/html/._week40-bs021.html | 203 ++- doc/pub/week40/html/._week40-bs022.html | 165 +-- doc/pub/week40/html/._week40-bs023.html | 167 ++- doc/pub/week40/html/._week40-bs024.html | 145 +- doc/pub/week40/html/._week40-bs025.html | 137 +- doc/pub/week40/html/._week40-bs026.html | 177 +-- doc/pub/week40/html/._week40-bs027.html | 190 ++- doc/pub/week40/html/._week40-bs028.html | 151 +- doc/pub/week40/html/._week40-bs029.html | 175 +-- doc/pub/week40/html/._week40-bs030.html | 175 ++- doc/pub/week40/html/._week40-bs031.html | 178 +-- doc/pub/week40/html/._week40-bs032.html | 160 +- doc/pub/week40/html/._week40-bs033.html | 209 +-- doc/pub/week40/html/._week40-bs034.html | 174 ++- doc/pub/week40/html/._week40-bs035.html | 129 +- doc/pub/week40/html/._week40-bs036.html | 180 +-- doc/pub/week40/html/._week40-bs037.html | 185 ++- doc/pub/week40/html/._week40-bs038.html | 145 +- doc/pub/week40/html/._week40-bs039.html | 144 +- doc/pub/week40/html/._week40-bs040.html | 147 +- doc/pub/week40/html/._week40-bs041.html | 138 +- doc/pub/week40/html/._week40-bs042.html | 134 +- doc/pub/week40/html/._week40-bs043.html | 133 +- doc/pub/week40/html/._week40-bs044.html | 137 +- doc/pub/week40/html/._week40-bs045.html | 185 +-- doc/pub/week40/html/._week40-bs046.html | 148 +- doc/pub/week40/html/._week40-bs047.html | 174 ++- doc/pub/week40/html/._week40-bs048.html | 158 +- doc/pub/week40/html/._week40-bs049.html | 160 +- doc/pub/week40/html/._week40-bs050.html | 163 +- doc/pub/week40/html/._week40-bs051.html | 141 +- doc/pub/week40/html/._week40-bs052.html | 141 +- doc/pub/week40/html/._week40-bs053.html | 158 +- doc/pub/week40/html/._week40-bs054.html | 155 +- doc/pub/week40/html/._week40-bs055.html | 143 +- doc/pub/week40/html/._week40-bs056.html | 147 +- doc/pub/week40/html/._week40-bs057.html | 228 +-- doc/pub/week40/html/._week40-bs058.html | 240 +-- doc/pub/week40/html/._week40-bs059.html | 160 +- doc/pub/week40/html/._week40-bs060.html | 154 +- doc/pub/week40/html/._week40-bs061.html | 163 +- doc/pub/week40/html/._week40-bs062.html | 147 +- doc/pub/week40/html/._week40-bs063.html | 132 +- doc/pub/week40/html/._week40-bs064.html | 157 +- doc/pub/week40/html/._week40-bs065.html | 160 +- doc/pub/week40/html/week40-bs.html | 118 +- doc/pub/week40/html/week40-reveal.html | 12 +- doc/pub/week40/html/week40-solarized.html | 12 +- doc/pub/week40/html/week40.html | 12 +- doc/pub/week40/ipynb/ipynb-week40-src.tar.gz | Bin 34326 -> 34326 bytes doc/pub/week40/ipynb/week40.ipynb | 1391 ++++++++++++------ doc/src/week40/week40.do.txt | 6 + 73 files changed, 6162 insertions(+), 5567 deletions(-) diff --git a/doc/pub/week40/html/._week40-bs000.html b/doc/pub/week40/html/._week40-bs000.html index 76cb74266..dd9e9bdc5 100644 --- a/doc/pub/week40/html/._week40-bs000.html +++ b/doc/pub/week40/html/._week40-bs000.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -334,7 +336,7 @@ MathJax.Hub.Config({
    -

    Nov 5, 2021

    +

    Nov 16, 2021


    @@ -359,7 +361,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs001.html b/doc/pub/week40/html/._week40-bs001.html index 11be6d1f6..a4815fd1a 100644 --- a/doc/pub/week40/html/._week40-bs001.html +++ b/doc/pub/week40/html/._week40-bs001.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -349,7 +351,7 @@ For neural networks we recommend Goodfellow et al chapters 6 and 7 and Bishop 5.
  • 10
  • 11
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs002.html b/doc/pub/week40/html/._week40-bs002.html index f59bf09ce..a0330670f 100644 --- a/doc/pub/week40/html/._week40-bs002.html +++ b/doc/pub/week40/html/._week40-bs002.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -337,7 +339,7 @@ MathJax.Hub.Config({
  • 11
  • 12
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs003.html b/doc/pub/week40/html/._week40-bs003.html index c272067e1..914de4935 100644 --- a/doc/pub/week40/html/._week40-bs003.html +++ b/doc/pub/week40/html/._week40-bs003.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -349,7 +351,7 @@ perform a parameter update.
  • 12
  • 13
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs004.html b/doc/pub/week40/html/._week40-bs004.html index f7e37029a..06c311c66 100644 --- a/doc/pub/week40/html/._week40-bs004.html +++ b/doc/pub/week40/html/._week40-bs004.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -361,7 +363,7 @@ sized in powers of 2.
  • 13
  • 14
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs005.html b/doc/pub/week40/html/._week40-bs005.html index 4ce38970b..f2dc16cf8 100644 --- a/doc/pub/week40/html/._week40-bs005.html +++ b/doc/pub/week40/html/._week40-bs005.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -352,7 +354,7 @@ $$
  • 14
  • 15
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs006.html b/doc/pub/week40/html/._week40-bs006.html index 9a103c987..10f0ce926 100644 --- a/doc/pub/week40/html/._week40-bs006.html +++ b/doc/pub/week40/html/._week40-bs006.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -354,7 +356,7 @@ minibatches. We denote these minibatches by \( B_k \) where
  • 15
  • 16
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs007.html b/doc/pub/week40/html/._week40-bs007.html index efaacff02..e75dd53ba 100644 --- a/doc/pub/week40/html/._week40-bs007.html +++ b/doc/pub/week40/html/._week40-bs007.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -362,7 +364,7 @@ $$
  • 16
  • 17
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs008.html b/doc/pub/week40/html/._week40-bs008.html index d1c1dc8f9..2c8f9a92e 100644 --- a/doc/pub/week40/html/._week40-bs008.html +++ b/doc/pub/week40/html/._week40-bs008.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -354,7 +356,7 @@ the number of minibatches, as exemplified in the code below.
  • 17
  • 18
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs009.html b/doc/pub/week40/html/._week40-bs009.html index d1b2fa34b..c591f0034 100644 --- a/doc/pub/week40/html/._week40-bs009.html +++ b/doc/pub/week40/html/._week40-bs009.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -387,7 +389,7 @@ all \( n \) datapoints.
  • 18
  • 19
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs010.html b/doc/pub/week40/html/._week40-bs010.html index 57cd1ee8d..79ba1295a 100644 --- a/doc/pub/week40/html/._week40-bs010.html +++ b/doc/pub/week40/html/._week40-bs010.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -355,7 +357,7 @@ gave the lowest value.
  • 19
  • 20
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs011.html b/doc/pub/week40/html/._week40-bs011.html index 68eb4a975..36116737a 100644 --- a/doc/pub/week40/html/._week40-bs011.html +++ b/doc/pub/week40/html/._week40-bs011.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -405,7 +407,7 @@ j = 0
  • 20
  • 21
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs012.html b/doc/pub/week40/html/._week40-bs012.html index 8d3b9b57b..298e55273 100644 --- a/doc/pub/week40/html/._week40-bs012.html +++ b/doc/pub/week40/html/._week40-bs012.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -435,7 +437,7 @@ plt.show()
  • 21
  • 22
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs013.html b/doc/pub/week40/html/._week40-bs013.html index 32fc312b5..134fe0825 100644 --- a/doc/pub/week40/html/._week40-bs013.html +++ b/doc/pub/week40/html/._week40-bs013.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,40 +318,14 @@ MathJax.Hub.Config({

     

     

     

    -

    Momentum based GD

    +

    Replace or not

    -

    The stochastic gradient descent (SGD) is almost always used with a -momentum or inertia term that serves as a memory of the direction we -are moving in parameter space. This is typically implemented as -follows +

    In the above code, we have use replacement in setting up the +mini-batches. The discussion +here may be +useful. More material will be added later.

    -$$ -\begin{align} -\mathbf{v}_{t}&=\gamma \mathbf{v}_{t-1}+\eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t) \nonumber \\ -\boldsymbol{\theta}_{t+1}&= \boldsymbol{\theta}_t -\mathbf{v}_{t}, -\tag{1} -\end{align} -$$ - -

    where we have introduced a momentum parameter \( \gamma \), with -\( 0\le\gamma\le 1 \), and for brevity we dropped the explicit notation to -indicate the gradient is to be taken over a different mini-batch at -each step. We call this algorithm gradient descent with momentum -(GDM). From these equations, it is clear that \( \mathbf{v}_t \) is a -running average of recently encountered gradients and -\( (1-\gamma)^{-1} \) sets the characteristic time scale for the memory -used in the averaging procedure. Consistent with this, when -\( \gamma=0 \), this just reduces down to ordinary SGD as discussed -earlier. An equivalent way of writing the updates is -

    - -$$ -\Delta \boldsymbol{\theta}_{t+1} = \gamma \Delta \boldsymbol{\theta}_t -\ \eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t), -$$ - -

    where we have defined \( \Delta \boldsymbol{\theta}_{t}= \boldsymbol{\theta}_t-\boldsymbol{\theta}_{t-1} \).

    -

    diff --git a/doc/pub/week40/html/._week40-bs014.html b/doc/pub/week40/html/._week40-bs014.html index 019aefc34..2889731d2 100644 --- a/doc/pub/week40/html/._week40-bs014.html +++ b/doc/pub/week40/html/._week40-bs014.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,31 +318,39 @@ MathJax.Hub.Config({

     

     

     

    -

    More on momentum based approaches

    +

    Momentum based GD

    -

    Let us try to get more intuition from these equations. It is helpful -to consider a simple physical analogy with a particle of mass \( m \) -moving in a viscous medium with drag coefficient \( \mu \) and potential -\( E(\mathbf{w}) \). If we denote the particle's position by \( \mathbf{w} \), -then its motion is described by +

    The stochastic gradient descent (SGD) is almost always used with a +momentum or inertia term that serves as a memory of the direction we +are moving in parameter space. This is typically implemented as +follows

    $$ -m {d^2 \mathbf{w} \over dt^2} + \mu {d \mathbf{w} \over dt }= -\nabla_w E(\mathbf{w}). +\begin{align} +\mathbf{v}_{t}&=\gamma \mathbf{v}_{t-1}+\eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t) \nonumber \\ +\boldsymbol{\theta}_{t+1}&= \boldsymbol{\theta}_t -\mathbf{v}_{t}, +\tag{1} +\end{align} $$ -

    We can discretize this equation in the usual way to get

    +

    where we have introduced a momentum parameter \( \gamma \), with +\( 0\le\gamma\le 1 \), and for brevity we dropped the explicit notation to +indicate the gradient is to be taken over a different mini-batch at +each step. We call this algorithm gradient descent with momentum +(GDM). From these equations, it is clear that \( \mathbf{v}_t \) is a +running average of recently encountered gradients and +\( (1-\gamma)^{-1} \) sets the characteristic time scale for the memory +used in the averaging procedure. Consistent with this, when +\( \gamma=0 \), this just reduces down to ordinary SGD as discussed +earlier. An equivalent way of writing the updates is +

    $$ -m { \mathbf{w}_{t+\Delta t}-2 \mathbf{w}_{t} +\mathbf{w}_{t-\Delta t} \over (\Delta t)^2}+\mu {\mathbf{w}_{t+\Delta t}- \mathbf{w}_{t} \over \Delta t} = -\nabla_w E(\mathbf{w}). -$$ - -

    Rearranging this equation, we can rewrite this as

    - -$$ -\Delta \mathbf{w}_{t +\Delta t}= - { (\Delta t)^2 \over m +\mu \Delta t} \nabla_w E(\mathbf{w})+ {m \over m +\mu \Delta t} \Delta \mathbf{w}_t. +\Delta \boldsymbol{\theta}_{t+1} = \gamma \Delta \boldsymbol{\theta}_t -\ \eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t), $$ +

    where we have defined \( \Delta \boldsymbol{\theta}_{t}= \boldsymbol{\theta}_t-\boldsymbol{\theta}_{t-1} \).

    @@ -367,7 +377,7 @@ $$

  • 23
  • 24
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs015.html b/doc/pub/week40/html/._week40-bs015.html index ee164c68b..40b8b9736 100644 --- a/doc/pub/week40/html/._week40-bs015.html +++ b/doc/pub/week40/html/._week40-bs015.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,57 +318,31 @@ MathJax.Hub.Config({

     

     

     

    -

    Momentum parameter

    +

    More on momentum based approaches

    -

    Notice that this equation is identical to previous one if we identify -the position of the particle, \( \mathbf{w} \), with the parameters -\( \boldsymbol{\theta} \). This allows us to identify the momentum -parameter and learning rate with the mass of the particle and the -viscous drag as: +

    Let us try to get more intuition from these equations. It is helpful +to consider a simple physical analogy with a particle of mass \( m \) +moving in a viscous medium with drag coefficient \( \mu \) and potential +\( E(\mathbf{w}) \). If we denote the particle's position by \( \mathbf{w} \), +then its motion is described by

    $$ -\gamma= {m \over m +\mu \Delta t }, \qquad \eta = {(\Delta t)^2 \over m +\mu \Delta t}. +m {d^2 \mathbf{w} \over dt^2} + \mu {d \mathbf{w} \over dt }= -\nabla_w E(\mathbf{w}). $$ -

    Thus, as the name suggests, the momentum parameter is proportional to -the mass of the particle and effectively provides inertia. -Furthermore, in the large viscosity/small learning rate limit, our -memory time scales as \( (1-\gamma)^{-1} \approx m/(\mu \Delta t) \). -

    - -

    Why is momentum useful? SGD momentum helps the gradient descent -algorithm gain speed in directions with persistent but small gradients -even in the presence of stochasticity, while suppressing oscillations -in high-curvature directions. This becomes especially important in -situations where the landscape is shallow and flat in some directions -and narrow and steep in others. It has been argued that first-order -methods (with appropriate initial conditions) can perform comparable -to more expensive second order methods, especially in the context of -complex deep learning models. -

    - -

    These beneficial properties of momentum can sometimes become even more -pronounced by using a slight modification of the classical momentum -algorithm called Nesterov Accelerated Gradient (NAG). -

    - -

    In the NAG algorithm, rather than calculating the gradient at the -current parameters, \( \nabla_\theta E(\boldsymbol{\theta}_t) \), one -calculates the gradient at the expected value of the parameters given -our current momentum, \( \nabla_\theta E(\boldsymbol{\theta}_t +\gamma -\mathbf{v}_{t-1}) \). This yields the NAG update rule -

    +

    We can discretize this equation in the usual way to get

    $$ -\begin{align} -\mathbf{v}_{t}&=\gamma \mathbf{v}_{t-1}+\eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t +\gamma \mathbf{v}_{t-1}) \nonumber \\ -\boldsymbol{\theta}_{t+1}&= \boldsymbol{\theta}_t -\mathbf{v}_{t}. -\tag{2} -\end{align} +m { \mathbf{w}_{t+\Delta t}-2 \mathbf{w}_{t} +\mathbf{w}_{t-\Delta t} \over (\Delta t)^2}+\mu {\mathbf{w}_{t+\Delta t}- \mathbf{w}_{t} \over \Delta t} = -\nabla_w E(\mathbf{w}). +$$ + +

    Rearranging this equation, we can rewrite this as

    + +$$ +\Delta \mathbf{w}_{t +\Delta t}= - { (\Delta t)^2 \over m +\mu \Delta t} \nabla_w E(\mathbf{w})+ {m \over m +\mu \Delta t} \Delta \mathbf{w}_t. $$ -

    One of the major advantages of NAG is that it allows for the use of a larger learning rate than GDM for the same choice of \( \gamma \).

    @@ -393,7 +369,7 @@ $$

  • 24
  • 25
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs016.html b/doc/pub/week40/html/._week40-bs016.html index 48a3c5b3d..57c9add41 100644 --- a/doc/pub/week40/html/._week40-bs016.html +++ b/doc/pub/week40/html/._week40-bs016.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,31 +318,58 @@ MathJax.Hub.Config({

     

     

     

    -

    Second moment of the gradient

    +

    Momentum parameter

    -

    In stochastic gradient descent, with and without momentum, we still -have to specify a schedule for tuning the learning rates \( \eta_t \) -as a function of time. As discussed in the context of Newton's -method, this presents a number of dilemmas. The learning rate is -limited by the steepest direction which can change depending on the -current position in the landscape. To circumvent this problem, ideally -our algorithm would keep track of curvature and take large steps in -shallow, flat directions and small steps in steep, narrow directions. -Second-order methods accomplish this by calculating or approximating -the Hessian and normalizing the learning rate by the -curvature. However, this is very computationally expensive for -extremely large models. Ideally, we would like to be able to -adaptively change the step size to match the landscape without paying -the steep computational price of calculating or approximating -Hessians. +

    Notice that this equation is identical to previous one if we identify +the position of the particle, \( \mathbf{w} \), with the parameters +\( \boldsymbol{\theta} \). This allows us to identify the momentum +parameter and learning rate with the mass of the particle and the +viscous drag as:

    -

    Recently, a number of methods have been introduced that accomplish -this by tracking not only the gradient, but also the second moment of -the gradient. These methods include AdaGrad, AdaDelta, Root Mean Squared Propagation (RMS-Prop), and -ADAM. +$$ +\gamma= {m \over m +\mu \Delta t }, \qquad \eta = {(\Delta t)^2 \over m +\mu \Delta t}. +$$ + +

    Thus, as the name suggests, the momentum parameter is proportional to +the mass of the particle and effectively provides inertia. +Furthermore, in the large viscosity/small learning rate limit, our +memory time scales as \( (1-\gamma)^{-1} \approx m/(\mu \Delta t) \).

    +

    Why is momentum useful? SGD momentum helps the gradient descent +algorithm gain speed in directions with persistent but small gradients +even in the presence of stochasticity, while suppressing oscillations +in high-curvature directions. This becomes especially important in +situations where the landscape is shallow and flat in some directions +and narrow and steep in others. It has been argued that first-order +methods (with appropriate initial conditions) can perform comparable +to more expensive second order methods, especially in the context of +complex deep learning models. +

    + +

    These beneficial properties of momentum can sometimes become even more +pronounced by using a slight modification of the classical momentum +algorithm called Nesterov Accelerated Gradient (NAG). +

    + +

    In the NAG algorithm, rather than calculating the gradient at the +current parameters, \( \nabla_\theta E(\boldsymbol{\theta}_t) \), one +calculates the gradient at the expected value of the parameters given +our current momentum, \( \nabla_\theta E(\boldsymbol{\theta}_t +\gamma +\mathbf{v}_{t-1}) \). This yields the NAG update rule +

    + +$$ +\begin{align} +\mathbf{v}_{t}&=\gamma \mathbf{v}_{t-1}+\eta_{t}\nabla_\theta E(\boldsymbol{\theta}_t +\gamma \mathbf{v}_{t-1}) \nonumber \\ +\boldsymbol{\theta}_{t+1}&= \boldsymbol{\theta}_t -\mathbf{v}_{t}. +\tag{2} +\end{align} +$$ + +

    One of the major advantages of NAG is that it allows for the use of a larger learning rate than GDM for the same choice of \( \gamma \).

    +

    diff --git a/doc/pub/week40/html/._week40-bs017.html b/doc/pub/week40/html/._week40-bs017.html index f1d908fc6..b6c61f4fd 100644 --- a/doc/pub/week40/html/._week40-bs017.html +++ b/doc/pub/week40/html/._week40-bs017.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,32 +318,29 @@ MathJax.Hub.Config({

     

     

     

    -

    RMS prop

    +

    Second moment of the gradient

    -

    In RMS prop, in addition to keeping a running average of the first -moment of the gradient, we also keep track of the second moment -denoted by \( \mathbf{s}_t=\mathbb{E}[\mathbf{g}_t^2] \). The update rule -for RMS prop is given by +

    In stochastic gradient descent, with and without momentum, we still +have to specify a schedule for tuning the learning rates \( \eta_t \) +as a function of time. As discussed in the context of Newton's +method, this presents a number of dilemmas. The learning rate is +limited by the steepest direction which can change depending on the +current position in the landscape. To circumvent this problem, ideally +our algorithm would keep track of curvature and take large steps in +shallow, flat directions and small steps in steep, narrow directions. +Second-order methods accomplish this by calculating or approximating +the Hessian and normalizing the learning rate by the +curvature. However, this is very computationally expensive for +extremely large models. Ideally, we would like to be able to +adaptively change the step size to match the landscape without paying +the steep computational price of calculating or approximating +Hessians.

    -$$ -\begin{align} -\mathbf{g}_t &= \nabla_\theta E(\boldsymbol{\theta}) -\tag{3}\\ -\mathbf{s}_t &=\beta \mathbf{s}_{t-1} +(1-\beta)\mathbf{g}_t^2 \nonumber \\ -\boldsymbol{\theta}_{t+1}&=&\boldsymbol{\theta}_t - \eta_t { \mathbf{g}_t \over \sqrt{\mathbf{s}_t +\epsilon}}, \nonumber -\end{align} -$$ - -

    where \( \beta \) controls the averaging time of the second moment and is -typically taken to be about \( \beta=0.9 \), \( \eta_t \) is a learning rate -typically chosen to be \( 10^{-3} \), and \( \epsilon\sim 10^{-8} \) is a -small regularization constant to prevent divergences. Multiplication -and division by vectors is understood as an element-wise operation. It -is clear from this formula that the learning rate is reduced in -directions where the norm of the gradient is consistently large. This -greatly speeds up the convergence by allowing us to use a larger -learning rate for flat directions. +

    Recently, a number of methods have been introduced that accomplish +this by tracking not only the gradient, but also the second moment of +the gradient. These methods include AdaGrad, AdaDelta, Root Mean Squared Propagation (RMS-Prop), and +ADAM.

    @@ -369,7 +368,7 @@ learning rate for flat directions.

  • 26
  • 27
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs018.html b/doc/pub/week40/html/._week40-bs018.html index 013a1b0c0..faf421f78 100644 --- a/doc/pub/week40/html/._week40-bs018.html +++ b/doc/pub/week40/html/._week40-bs018.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,53 +318,34 @@ MathJax.Hub.Config({

     

     

     

    -

    ADAM optimizer

    +

    RMS prop

    -

    A related algorithm is the ADAM optimizer. In ADAM, we keep a running -average of both the first and second moment of the gradient and use -this information to adaptively change the learning rate for different -parameters. In addition to keeping a running average of the first and -second moments of the gradient -(i.e. \( \mathbf{m}_t=\mathbb{E}[\mathbf{g}_t] \) and -\( \mathbf{s}_t=\mathbb{E}[\mathbf{g}^2_t] \), respectively), ADAM -performs an additional bias correction to account for the fact that we -are estimating the first two moments of the gradient using a running -average (denoted by the hats in the update rule below). The update -rule for ADAM is given by (where multiplication and division are once -again understood to be element-wise operations below) +

    In RMS prop, in addition to keeping a running average of the first +moment of the gradient, we also keep track of the second moment +denoted by \( \mathbf{s}_t=\mathbb{E}[\mathbf{g}_t^2] \). The update rule +for RMS prop is given by

    $$ \begin{align} \mathbf{g}_t &= \nabla_\theta E(\boldsymbol{\theta}) -\tag{4}\\ -\mathbf{m}_t &= \beta_1 \mathbf{m}_{t-1} + (1-\beta_1) \mathbf{g}_t \nonumber \\ -\mathbf{s}_t &=\beta_2 \mathbf{s}_{t-1} +(1-\beta_2)\mathbf{g}_t^2 \nonumber \\ -\boldsymbol{\mathbf{m}}_t&={\mathbf{m}_t \over 1-\beta_1^t} \nonumber \\ -\boldsymbol{\mathbf{s}}_t &={\mathbf{s}_t \over1-\beta_2^t} \nonumber \\ -\boldsymbol{\theta}_{t+1}&=\boldsymbol{\theta}_t - \eta_t { \boldsymbol{\mathbf{m}}_t \over \sqrt{\boldsymbol{\mathbf{s}}_t} +\epsilon}, \nonumber \\ -\tag{5} +\tag{3}\\ +\mathbf{s}_t &=\beta \mathbf{s}_{t-1} +(1-\beta)\mathbf{g}_t^2 \nonumber \\ +\boldsymbol{\theta}_{t+1}&=&\boldsymbol{\theta}_t - \eta_t { \mathbf{g}_t \over \sqrt{\mathbf{s}_t +\epsilon}}, \nonumber \end{align} $$ -

    where \( \beta_1 \) and \( \beta_2 \) set the memory lifetime of the first and -second moment and are typically taken to be \( 0.9 \) and \( 0.99 \) -respectively, and \( \eta \) and \( \epsilon \) are identical to RMSprop. +

    where \( \beta \) controls the averaging time of the second moment and is +typically taken to be about \( \beta=0.9 \), \( \eta_t \) is a learning rate +typically chosen to be \( 10^{-3} \), and \( \epsilon\sim 10^{-8} \) is a +small regularization constant to prevent divergences. Multiplication +and division by vectors is understood as an element-wise operation. It +is clear from this formula that the learning rate is reduced in +directions where the norm of the gradient is consistently large. This +greatly speeds up the convergence by allowing us to use a larger +learning rate for flat directions.

    -

    Like in RMSprop, the effective step size of a parameter depends on the -magnitude of its gradient squared. To understand this better, let us -rewrite this expression in terms of the variance -\( \boldsymbol{\sigma}_t^2 = \boldsymbol{\mathbf{s}}_t - -(\boldsymbol{\mathbf{m}}_t)^2 \). Consider a single parameter \( \theta_t \). The -update rule for this parameter is given by -

    - -$$ -\Delta \theta_{t+1}= -\eta_t { \boldsymbol{m}_t \over \sqrt{\sigma_t^2 + m_t^2 }+\epsilon}. -$$ - -

    diff --git a/doc/pub/week40/html/._week40-bs019.html b/doc/pub/week40/html/._week40-bs019.html index dece297a4..4b4a8d444 100644 --- a/doc/pub/week40/html/._week40-bs019.html +++ b/doc/pub/week40/html/._week40-bs019.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,15 +318,52 @@ MathJax.Hub.Config({

     

     

     

    -

    Practical tips

    +

    ADAM optimizer

    + +

    A related algorithm is the ADAM optimizer. In ADAM, we keep a running +average of both the first and second moment of the gradient and use +this information to adaptively change the learning rate for different +parameters. In addition to keeping a running average of the first and +second moments of the gradient +(i.e. \( \mathbf{m}_t=\mathbb{E}[\mathbf{g}_t] \) and +\( \mathbf{s}_t=\mathbb{E}[\mathbf{g}^2_t] \), respectively), ADAM +performs an additional bias correction to account for the fact that we +are estimating the first two moments of the gradient using a running +average (denoted by the hats in the update rule below). The update +rule for ADAM is given by (where multiplication and division are once +again understood to be element-wise operations below) +

    + +$$ +\begin{align} +\mathbf{g}_t &= \nabla_\theta E(\boldsymbol{\theta}) +\tag{4}\\ +\mathbf{m}_t &= \beta_1 \mathbf{m}_{t-1} + (1-\beta_1) \mathbf{g}_t \nonumber \\ +\mathbf{s}_t &=\beta_2 \mathbf{s}_{t-1} +(1-\beta_2)\mathbf{g}_t^2 \nonumber \\ +\boldsymbol{\mathbf{m}}_t&={\mathbf{m}_t \over 1-\beta_1^t} \nonumber \\ +\boldsymbol{\mathbf{s}}_t &={\mathbf{s}_t \over1-\beta_2^t} \nonumber \\ +\boldsymbol{\theta}_{t+1}&=\boldsymbol{\theta}_t - \eta_t { \boldsymbol{\mathbf{m}}_t \over \sqrt{\boldsymbol{\mathbf{s}}_t} +\epsilon}, \nonumber \\ +\tag{5} +\end{align} +$$ + +

    where \( \beta_1 \) and \( \beta_2 \) set the memory lifetime of the first and +second moment and are typically taken to be \( 0.9 \) and \( 0.99 \) +respectively, and \( \eta \) and \( \epsilon \) are identical to RMSprop. +

    + +

    Like in RMSprop, the effective step size of a parameter depends on the +magnitude of its gradient squared. To understand this better, let us +rewrite this expression in terms of the variance +\( \boldsymbol{\sigma}_t^2 = \boldsymbol{\mathbf{s}}_t - +(\boldsymbol{\mathbf{m}}_t)^2 \). Consider a single parameter \( \theta_t \). The +update rule for this parameter is given by +

    + +$$ +\Delta \theta_{t+1}= -\eta_t { \boldsymbol{m}_t \over \sqrt{\sigma_t^2 + m_t^2 }+\epsilon}. +$$ - -

    Geron's text, see chapter 11, has several interesting discussions.

    @@ -351,7 +390,7 @@ MathJax.Hub.Config({

  • 28
  • 29
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs020.html b/doc/pub/week40/html/._week40-bs020.html index 718894179..f8ecb92e7 100644 --- a/doc/pub/week40/html/._week40-bs020.html +++ b/doc/pub/week40/html/._week40-bs020.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,105 +318,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Automatic differentiation

    - -

    Automatic differentiation (AD), -also called algorithmic -differentiation or computational differentiation,is a set of -techniques to numerically evaluate the derivative of a function -specified by a computer program. AD exploits the fact that every -computer program, no matter how complicated, executes a sequence of -elementary arithmetic operations (addition, subtraction, -multiplication, division, etc.) and elementary functions (exp, log, -sin, cos, etc.). By applying the chain rule repeatedly to these -operations, derivatives of arbitrary order can be computed -automatically, accurately to working precision, and using at most a -small constant factor more arithmetic operations than the original -program. -

    - -

    Automatic differentiation is neither:

    +

    Practical tips

    -

    Symbolic differentiation can lead to inefficient code and faces the -difficulty of converting a computer program into a single expression, -while numerical differentiation can introduce round-off errors in the -discretization process and cancellation -

    - -

    Python has tools for so-called automatic differentiation. -Consider the following example -

    -$$ -f(x) = \sin\left(2\pi x + x^2\right) -$$ - -

    which has the following derivative

    -$$ -f'(x) = \cos\left(2\pi x + x^2\right)\left(2\pi + 2x\right) -$$ - -

    Using autograd we have

    - - - -
    -
    -
    -
    -
    -
    import autograd.numpy as np
    -
    -# To do elementwise differentiation:
    -from autograd import elementwise_grad as egrad 
    -
    -# To plot:
    -import matplotlib.pyplot as plt 
    -
    -
    -def f(x):
    -    return np.sin(2*np.pi*x + x**2)
    -
    -def f_grad_analytic(x):
    -    return np.cos(2*np.pi*x + x**2)*(2*np.pi + 2*x)
    -
    -# Do the comparison:
    -x = np.linspace(0,1,1000)
    -
    -f_grad = egrad(f)
    -
    -computed = f_grad(x)
    -analytic = f_grad_analytic(x)
    -
    -plt.title('Derivative computed from Autograd compared with the analytical derivative')
    -plt.plot(x,computed,label='autograd')
    -plt.plot(x,analytic,label='analytic')
    -
    -plt.xlabel('x')
    -plt.ylabel('y')
    -plt.legend()
    -
    -plt.show()
    -
    -print("The max absolute difference is: %g"%(np.max(np.abs(computed - analytic))))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - +

    Geron's text, see chapter 11, has several interesting discussions.

    @@ -441,7 +353,7 @@ plt.show()

  • 29
  • 30
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs021.html b/doc/pub/week40/html/._week40-bs021.html index 8ff302775..288d8d53d 100644 --- a/doc/pub/week40/html/._week40-bs021.html +++ b/doc/pub/week40/html/._week40-bs021.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -315,16 +317,50 @@ MathJax.Hub.Config({

     

     

     

    - -

    Using autograd

    + +

    Automatic differentiation

    -

    Here we -experiment with what kind of functions Autograd is capable -of finding the gradient of. The following Python functions are just -meant to illustrate what Autograd can do, but please feel free to -experiment with other, possibly more complicated, functions as well. +

    Automatic differentiation (AD), +also called algorithmic +differentiation or computational differentiation,is a set of +techniques to numerically evaluate the derivative of a function +specified by a computer program. AD exploits the fact that every +computer program, no matter how complicated, executes a sequence of +elementary arithmetic operations (addition, subtraction, +multiplication, division, etc.) and elementary functions (exp, log, +sin, cos, etc.). By applying the chain rule repeatedly to these +operations, derivatives of arbitrary order can be computed +automatically, accurately to working precision, and using at most a +small constant factor more arithmetic operations than the original +program.

    +

    Automatic differentiation is neither:

    + + +

    Symbolic differentiation can lead to inefficient code and faces the +difficulty of converting a computer program into a single expression, +while numerical differentiation can introduce round-off errors in the +discretization process and cancellation +

    + +

    Python has tools for so-called automatic differentiation. +Consider the following example +

    +$$ +f(x) = \sin\left(2\pi x + x^2\right) +$$ + +

    which has the following derivative

    +$$ +f'(x) = \cos\left(2\pi x + x^2\right)\left(2\pi + 2x\right) +$$ + +

    Using autograd we have

    +
    @@ -333,22 +369,39 @@ experiment with other, possibly more complicated, functions as well.
    import autograd.numpy as np
    -from autograd import grad
     
    -def f1(x):
    -    return x**3 + 1
    +# To do elementwise differentiation:
    +from autograd import elementwise_grad as egrad 
     
    -f1_grad = grad(f1)
    +# To plot:
    +import matplotlib.pyplot as plt 
     
    -# Remember to send in float as argument to the computed gradient from Autograd!
    -a = 1.0
     
    -# See the evaluated gradient at a using autograd:
    -print("The gradient of f1 evaluated at a = %g using autograd is: %g"%(a,f1_grad(a)))
    +def f(x):
    +    return np.sin(2*np.pi*x + x**2)
     
    -# Compare with the analytical derivative, that is f1'(x) = 3*x**2 
    -grad_analytical = 3*a**2
    -print("The gradient of f1 evaluated at a = %g by finding the analytic expression is: %g"%(a,grad_analytical))
    +def f_grad_analytic(x):
    +    return np.cos(2*np.pi*x + x**2)*(2*np.pi + 2*x)
    +
    +# Do the comparison:
    +x = np.linspace(0,1,1000)
    +
    +f_grad = egrad(f)
    +
    +computed = f_grad(x)
    +analytic = f_grad_analytic(x)
    +
    +plt.title('Derivative computed from Autograd compared with the analytical derivative')
    +plt.plot(x,computed,label='autograd')
    +plt.plot(x,analytic,label='analytic')
    +
    +plt.xlabel('x')
    +plt.ylabel('y')
    +plt.legend()
    +
    +plt.show()
    +
    +print("The max absolute difference is: %g"%(np.max(np.abs(computed - analytic))))
     
    @@ -390,7 +443,7 @@ grad_analytical = 30
  • 31
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs022.html b/doc/pub/week40/html/._week40-bs022.html index 59a66e1fc..dda43e7f7 100644 --- a/doc/pub/week40/html/._week40-bs022.html +++ b/doc/pub/week40/html/._week40-bs022.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -315,12 +317,14 @@ MathJax.Hub.Config({

     

     

     

    - -

    Autograd with more complicated functions

    + +

    Using autograd

    -

    To differentiate with respect to two (or more) arguments of a Python -function, Autograd need to know at which variable the function if -being differentiated with respect to. +

    Here we +experiment with what kind of functions Autograd is capable +of finding the gradient of. The following Python functions are just +meant to illustrate what Autograd can do, but please feel free to +experiment with other, possibly more complicated, functions as well.

    @@ -332,37 +336,21 @@ being differentiated with respect to.
    import autograd.numpy as np
     from autograd import grad
    -def f2(x1,x2):
    -    return 3*x1**3 + x2*(x1 - 5) + 1
     
    -# By sending the argument 0, Autograd will compute the derivative w.r.t the first variable, in this case x1
    -f2_grad_x1 = grad(f2,0)
    +def f1(x):
    +    return x**3 + 1
     
    -# ... and differentiate w.r.t x2 by sending 1 as an additional arugment to grad
    -f2_grad_x2 = grad(f2,1)
    +f1_grad = grad(f1)
     
    -x1 = 1.0
    -x2 = 3.0 
    +# Remember to send in float as argument to the computed gradient from Autograd!
    +a = 1.0
     
    -print("Evaluating at x1 = %g, x2 = %g"%(x1,x2))
    -print("-"*30)
    +# See the evaluated gradient at a using autograd:
    +print("The gradient of f1 evaluated at a = %g using autograd is: %g"%(a,f1_grad(a)))
     
    -# Compare with the analytical derivatives:
    -
    -# Derivative of f2 w.r.t x1 is: 9*x1**2 + x2:
    -f2_grad_x1_analytical = 9*x1**2 + x2
    -
    -# Derivative of f2 w.r.t x2 is: x1 - 5:
    -f2_grad_x2_analytical = x1 - 5
    -
    -# See the evaluated derivations:
    -print("The derivative of f2 w.r.t x1: %g"%( f2_grad_x1(x1,x2) ))
    -print("The analytical derivative of f2 w.r.t x1: %g"%( f2_grad_x1(x1,x2) ))
    -
    -print()
    -
    -print("The derivative of f2 w.r.t x2: %g"%( f2_grad_x2(x1,x2) ))
    -print("The analytical derivative of f2 w.r.t x2: %g"%( f2_grad_x2(x1,x2) ))
    +# Compare with the analytical derivative, that is f1'(x) = 3*x**2 
    +grad_analytical = 3*a**2
    +print("The gradient of f1 evaluated at a = %g by finding the analytic expression is: %g"%(a,grad_analytical))
     
    @@ -378,7 +366,6 @@ f2_grad_x2_analytical = x1 = x1 31
  • 32
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs023.html b/doc/pub/week40/html/._week40-bs023.html index e86fc7083..3323d9886 100644 --- a/doc/pub/week40/html/._week40-bs023.html +++ b/doc/pub/week40/html/._week40-bs023.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,12 @@ MathJax.Hub.Config({

     

     

     

    -

    More complicated functions using the elements of their arguments directly

    +

    Autograd with more complicated functions

    + +

    To differentiate with respect to two (or more) arguments of a Python +function, Autograd need to know at which variable the function if +being differentiated with respect to. +

    @@ -327,21 +334,37 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f3(x): # Assumes x is an array of length 5 or higher
    -    return 2*x[0] + 3*x[1] + 5*x[2] + 7*x[3] + 11*x[4]**2
    +def f2(x1,x2):
    +    return 3*x1**3 + x2*(x1 - 5) + 1
     
    -f3_grad = grad(f3)
    +# By sending the argument 0, Autograd will compute the derivative w.r.t the first variable, in this case x1
    +f2_grad_x1 = grad(f2,0)
     
    -x = np.linspace(0,4,5)
    +# ... and differentiate w.r.t x2 by sending 1 as an additional arugment to grad
    +f2_grad_x2 = grad(f2,1)
     
    -# Print the computed gradient:
    -print("The computed gradient of f3 is: ", f3_grad(x))
    +x1 = 1.0
    +x2 = 3.0 
     
    -# The analytical gradient is: (2, 3, 5, 7, 22*x[4])
    -f3_grad_analytical = np.array([2, 3, 5, 7, 22*x[4]])
    +print("Evaluating at x1 = %g, x2 = %g"%(x1,x2))
    +print("-"*30)
     
    -# Print the analytical gradient:
    -print("The analytical gradient of f3 is: ", f3_grad_analytical)
    +# Compare with the analytical derivatives:
    +
    +# Derivative of f2 w.r.t x1 is: 9*x1**2 + x2:
    +f2_grad_x1_analytical = 9*x1**2 + x2
    +
    +# Derivative of f2 w.r.t x2 is: x1 - 5:
    +f2_grad_x2_analytical = x1 - 5
    +
    +# See the evaluated derivations:
    +print("The derivative of f2 w.r.t x1: %g"%( f2_grad_x1(x1,x2) ))
    +print("The analytical derivative of f2 w.r.t x1: %g"%( f2_grad_x1(x1,x2) ))
    +
    +print()
    +
    +print("The derivative of f2 w.r.t x2: %g"%( f2_grad_x2(x1,x2) ))
    +print("The analytical derivative of f2 w.r.t x2: %g"%( f2_grad_x2(x1,x2) ))
     
    @@ -357,13 +380,7 @@ f3_grad_analytical = np32
  • 33
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs024.html b/doc/pub/week40/html/._week40-bs024.html index f24a791f2..72be7317a 100644 --- a/doc/pub/week40/html/._week40-bs024.html +++ b/doc/pub/week40/html/._week40-bs024.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -315,8 +317,8 @@ MathJax.Hub.Config({

     

     

     

    - -

    Functions using mathematical functions from Numpy

    + +

    More complicated functions using the elements of their arguments directly

    @@ -327,21 +329,21 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f4(x):
    -    return np.sqrt(1+x**2) + np.exp(x) + np.sin(2*np.pi*x)
    +def f3(x): # Assumes x is an array of length 5 or higher
    +    return 2*x[0] + 3*x[1] + 5*x[2] + 7*x[3] + 11*x[4]**2
     
    -f4_grad = grad(f4)
    +f3_grad = grad(f3)
     
    -x = 2.7
    +x = np.linspace(0,4,5)
     
    -# Print the computed derivative:
    -print("The computed derivative of f4 at x = %g is: %g"%(x,f4_grad(x)))
    +# Print the computed gradient:
    +print("The computed gradient of f3 is: ", f3_grad(x))
     
    -# The analytical derivative is: x/sqrt(1 + x**2) + exp(x) + cos(2*pi*x)*2*pi
    -f4_grad_analytical = x/np.sqrt(1 + x**2) + np.exp(x) + np.cos(2*np.pi*x)*2*np.pi
    +# The analytical gradient is: (2, 3, 5, 7, 22*x[4])
    +f3_grad_analytical = np.array([2, 3, 5, 7, 22*x[4]])
     
     # Print the analytical gradient:
    -print("The analytical gradient of f4 at x = %g is: %g"%(x,f4_grad_analytical))
    +print("The analytical gradient of f3 is: ", f3_grad_analytical)
     
    @@ -357,6 +359,13 @@ f4_grad_analytical = x= x33
  • 34
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs025.html b/doc/pub/week40/html/._week40-bs025.html index 96e869022..f9bc4dcbf 100644 --- a/doc/pub/week40/html/._week40-bs025.html +++ b/doc/pub/week40/html/._week40-bs025.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -315,8 +317,8 @@ MathJax.Hub.Config({

     

     

     

    - -

    More autograd

    + +

    Functions using mathematical functions from Numpy

    @@ -327,18 +329,21 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f5(x):
    -    if x >= 0:
    -        return x**2
    -    else:
    -        return -3*x + 1
    +def f4(x):
    +    return np.sqrt(1+x**2) + np.exp(x) + np.sin(2*np.pi*x)
     
    -f5_grad = grad(f5)
    +f4_grad = grad(f4)
     
     x = 2.7
     
     # Print the computed derivative:
    -print("The computed derivative of f5 at x = %g is: %g"%(x,f5_grad(x)))
    +print("The computed derivative of f4 at x = %g is: %g"%(x,f4_grad(x)))
    +
    +# The analytical derivative is: x/sqrt(1 + x**2) + exp(x) + cos(2*pi*x)*2*pi
    +f4_grad_analytical = x/np.sqrt(1 + x**2) + np.exp(x) + np.cos(2*np.pi*x)*2*np.pi
    +
    +# Print the analytical gradient:
    +print("The analytical gradient of f4 at x = %g is: %g"%(x,f4_grad_analytical))
     
    @@ -380,7 +385,7 @@ x = 2.7
  • 34
  • 35
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs026.html b/doc/pub/week40/html/._week40-bs026.html index a80a339b7..c62d8cdad 100644 --- a/doc/pub/week40/html/._week40-bs026.html +++ b/doc/pub/week40/html/._week40-bs026.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,7 @@ MathJax.Hub.Config({

     

     

     

    -

    And with loops

    +

    More autograd

    @@ -327,59 +329,18 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f6_for(x):
    -    val = 0
    -    for i in range(10):
    -        val = val + x**i
    -    return val
    +def f5(x):
    +    if x >= 0:
    +        return x**2
    +    else:
    +        return -3*x + 1
     
    -def f6_while(x):
    -    val = 0
    -    i = 0
    -    while i < 10:
    -        val = val + x**i
    -        i = i + 1
    -    return val
    +f5_grad = grad(f5)
     
    -f6_for_grad = grad(f6_for)
    -f6_while_grad = grad(f6_while)
    +x = 2.7
     
    -x = 0.5
    -
    -# Print the computed derivaties of f6_for and f6_while
    -print("The computed derivative of f6_for at x = %g is: %g"%(x,f6_for_grad(x)))
    -print("The computed derivative of f6_while at x = %g is: %g"%(x,f6_while_grad(x)))
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    -
    -
    - - - - -
    -
    -
    -
    -
    -
    import autograd.numpy as np
    -from autograd import grad
    -# Both of the functions are implementation of the sum: sum(x**i) for i = 0, ..., 9
    -# The analytical derivative is: sum(i*x**(i-1)) 
    -f6_grad_analytical = 0
    -for i in range(10):
    -    f6_grad_analytical += i*x**(i-1)
    -
    -print("The analytical derivative of f6 at x = %g is: %g"%(x,f6_grad_analytical))
    +# Print the computed derivative:
    +print("The computed derivative of f5 at x = %g is: %g"%(x,f5_grad(x)))
     
    @@ -421,7 +382,7 @@ f6_grad_analytical = 35
  • 36
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs027.html b/doc/pub/week40/html/._week40-bs027.html index e108a2623..8e15dfa41 100644 --- a/doc/pub/week40/html/._week40-bs027.html +++ b/doc/pub/week40/html/._week40-bs027.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,8 @@ MathJax.Hub.Config({

     

     

     

    -

    Using recursion

    +

    And with loops

    +
    @@ -326,31 +329,59 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    +def f6_for(x):
    +    val = 0
    +    for i in range(10):
    +        val = val + x**i
    +    return val
     
    -def f7(n): # Assume that n is an integer
    -    if n == 1 or n == 0:
    -        return 1
    -    else:
    -        return n*f7(n-1)
    +def f6_while(x):
    +    val = 0
    +    i = 0
    +    while i < 10:
    +        val = val + x**i
    +        i = i + 1
    +    return val
     
    -f7_grad = grad(f7)
    +f6_for_grad = grad(f6_for)
    +f6_while_grad = grad(f6_while)
     
    -n = 2.0
    +x = 0.5
     
    -print("The computed derivative of f7 at n = %d is: %g"%(n,f7_grad(n)))
    -
    -# The function f7 is an implementation of the factorial of n.
    -# By using the product rule, one can find that the derivative is:
    -
    -f7_grad_analytical = 0
    -for i in range(int(n)-1):
    -    tmp = 1
    -    for k in range(int(n)-1):
    -        if k != i:
    -            tmp *= (n - k)
    -    f7_grad_analytical += tmp
    -
    -print("The analytical derivative of f7 at n = %d is: %g"%(n,f7_grad_analytical))
    +# Print the computed derivaties of f6_for and f6_while
    +print("The computed derivative of f6_for at x = %g is: %g"%(x,f6_for_grad(x)))
    +print("The computed derivative of f6_while at x = %g is: %g"%(x,f6_while_grad(x)))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    +
    import autograd.numpy as np
    +from autograd import grad
    +# Both of the functions are implementation of the sum: sum(x**i) for i = 0, ..., 9
    +# The analytical derivative is: sum(i*x**(i-1)) 
    +f6_grad_analytical = 0
    +for i in range(10):
    +    f6_grad_analytical += i*x**(i-1)
    +
    +print("The analytical derivative of f6 at x = %g is: %g"%(x,f6_grad_analytical))
     
    @@ -366,7 +397,6 @@ f7_grad_analytical = = 36
  • 37
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs028.html b/doc/pub/week40/html/._week40-bs028.html index 70c43436c..d8c7d8fe6 100644 --- a/doc/pub/week40/html/._week40-bs028.html +++ b/doc/pub/week40/html/._week40-bs028.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,10 +318,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Unsupported functions

    -

    Autograd supports many features. However, there are some functions that is not supported (yet) by Autograd.

    - -

    Assigning a value to the variable being differentiated with respect to

    +

    Using recursion

    @@ -329,15 +328,31 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f8(x): # Assume x is an array
    -    x[2] = 3
    -    return x*2
     
    -f8_grad = grad(f8)
    +def f7(n): # Assume that n is an integer
    +    if n == 1 or n == 0:
    +        return 1
    +    else:
    +        return n*f7(n-1)
     
    -x = 8.4
    +f7_grad = grad(f7)
     
    -print("The derivative of f8 is:",f8_grad(x))
    +n = 2.0
    +
    +print("The computed derivative of f7 at n = %d is: %g"%(n,f7_grad(n)))
    +
    +# The function f7 is an implementation of the factorial of n.
    +# By using the product rule, one can find that the derivative is:
    +
    +f7_grad_analytical = 0
    +for i in range(int(n)-1):
    +    tmp = 1
    +    for k in range(int(n)-1):
    +        if k != i:
    +            tmp *= (n - k)
    +    f7_grad_analytical += tmp
    +
    +print("The analytical derivative of f7 at n = %d is: %g"%(n,f7_grad_analytical))
     
    @@ -353,7 +368,7 @@ x = 8.4
    -

    Here, Autograd tells us that an 'ArrayBox' does not support item assignment. The item assignment is done when the program tries to assign x[2] to the value 3. However, Autograd has implemented the computation of the derivative such that this assignment is not possible.

    +

    Note that if n is equal to zero or one, Autograd will give an error message. This message appears when the output is independent on input.

    @@ -380,7 +395,7 @@ x = 8.4

  • 37
  • 38
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs029.html b/doc/pub/week40/html/._week40-bs029.html index f9f132b45..e4c842148 100644 --- a/doc/pub/week40/html/._week40-bs029.html +++ b/doc/pub/week40/html/._week40-bs029.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,10 @@ MathJax.Hub.Config({

     

     

     

    -

    The syntax a.dot(b) when finding the dot product

    +

    Unsupported functions

    +

    Autograd supports many features. However, there are some functions that is not supported (yet) by Autograd.

    + +

    Assigning a value to the variable being differentiated with respect to

    @@ -326,56 +331,15 @@ MathJax.Hub.Config({
    import autograd.numpy as np
     from autograd import grad
    -def f9(a): # Assume a is an array with 2 elements
    -    b = np.array([1.0,2.0])
    -    return a.dot(b)
    +def f8(x): # Assume x is an array
    +    x[2] = 3
    +    return x*2
     
    -f9_grad = grad(f9)
    +f8_grad = grad(f8)
     
    -x = np.array([1.0,0.0])
    +x = 8.4
     
    -print("The derivative of f9 is:",f9_grad(x))
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    - - -

    Here we are told that the 'dot' function does not belong to Autograd's -version of a Numpy array. To overcome this, an alternative syntax -which also computed the dot product can be used: -

    - - - -
    -
    -
    -
    -
    -
    import autograd.numpy as np
    -from autograd import grad
    -def f9_alternative(x): # Assume a is an array with 2 elements
    -    b = np.array([1.0,2.0])
    -    return np.dot(x,b) # The same as x_1*b_1 + x_2*b_2
    -
    -f9_alternative_grad = grad(f9_alternative)
    -
    -x = np.array([3.0,0.0])
    -
    -print("The gradient of f9 is:",f9_alternative_grad(x))
    -
    -# The analytical gradient of the dot product of vectors x and b with two elements (x_1,x_2) and (b_1, b_2) respectively
    -# w.r.t x is (b_1, b_2).
    +print("The derivative of f8 is:",f8_grad(x))
     
    @@ -391,6 +355,7 @@ x = np.a
    +

    Here, Autograd tells us that an 'ArrayBox' does not support item assignment. The item assignment is done when the program tries to assign x[2] to the value 3. However, Autograd has implemented the computation of the derivative such that this assignment is not possible.

    @@ -417,7 +382,7 @@ x = np.a

  • 38
  • 39
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs030.html b/doc/pub/week40/html/._week40-bs030.html index 9ecb2ad30..731822275 100644 --- a/doc/pub/week40/html/._week40-bs030.html +++ b/doc/pub/week40/html/._week40-bs030.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,8 +318,7 @@ MathJax.Hub.Config({

     

     

     

    - -

    The documentation recommends to avoid inplace operations such as

    +

    The syntax a.dot(b) when finding the dot product

    @@ -325,10 +326,58 @@ MathJax.Hub.Config({
    -
    a += b
    -a -= b
    -a*= b
    -a /=b
    +  
    import autograd.numpy as np
    +from autograd import grad
    +def f9(a): # Assume a is an array with 2 elements
    +    b = np.array([1.0,2.0])
    +    return a.dot(b)
    +
    +f9_grad = grad(f9)
    +
    +x = np.array([1.0,0.0])
    +
    +print("The derivative of f9 is:",f9_grad(x))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    Here we are told that the 'dot' function does not belong to Autograd's +version of a Numpy array. To overcome this, an alternative syntax +which also computed the dot product can be used: +

    + + + +
    +
    +
    +
    +
    +
    import autograd.numpy as np
    +from autograd import grad
    +def f9_alternative(x): # Assume a is an array with 2 elements
    +    b = np.array([1.0,2.0])
    +    return np.dot(x,b) # The same as x_1*b_1 + x_2*b_2
    +
    +f9_alternative_grad = grad(f9_alternative)
    +
    +x = np.array([3.0,0.0])
    +
    +print("The gradient of f9 is:",f9_alternative_grad(x))
    +
    +# The analytical gradient of the dot product of vectors x and b with two elements (x_1,x_2) and (b_1, b_2) respectively
    +# w.r.t x is (b_1, b_2).
     
    @@ -370,7 +419,7 @@ a /=b
  • 39
  • 40
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs031.html b/doc/pub/week40/html/._week40-bs031.html index 2d449ddc7..8bc0f5ea5 100644 --- a/doc/pub/week40/html/._week40-bs031.html +++ b/doc/pub/week40/html/._week40-bs031.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,13 +318,8 @@ MathJax.Hub.Config({

     

     

     

    -

    Using Autograd with OLS

    - -

    We conclude the part on optmization by showing how we can make codes -for linear regression and logistic regression using autograd. The -first example shows results with ordinary leats squares. -

    - + +

    The documentation recommends to avoid inplace operations such as

    @@ -330,55 +327,10 @@ first example shows results with ordinary leats squares.
    -
    # Using Autograd to calculate gradients for OLS
    -from random import random, seed
    -import numpy as np
    -import autograd.numpy as np
    -import matplotlib.pyplot as plt
    -from autograd import grad
    -
    -def CostOLS(beta):
    -    return (1.0/n)*np.sum((y-X @ beta)**2)
    -
    -n = 100
    -x = 2*np.random.rand(n,1)
    -y = 4+3*x+np.random.randn(n,1)
    -
    -X = np.c_[np.ones((n,1)), x]
    -XT_X = X.T @ X
    -theta_linreg = np.linalg.pinv(XT_X) @ (X.T @ y)
    -print("Own inversion")
    -print(theta_linreg)
    -# Hessian matrix
    -H = (2.0/n)* XT_X
    -EigValues, EigVectors = np.linalg.eig(H)
    -print(f"Eigenvalues of Hessian Matrix:{EigValues}")
    -
    -theta = np.random.randn(2,1)
    -eta = 1.0/np.max(EigValues)
    -Niterations = 1000
    -# define the gradient
    -training_gradient = grad(CostOLS)
    -
    -for iter in range(Niterations):
    -    gradients = training_gradient(theta)
    -    theta -= eta*gradients
    -print("theta from own gd")
    -print(theta)
    -
    -xnew = np.array([[0],[2]])
    -Xnew = np.c_[np.ones((2,1)), xnew]
    -ypredict = Xnew.dot(theta)
    -ypredict2 = Xnew.dot(theta_linreg)
    -
    -plt.plot(xnew, ypredict, "r-")
    -plt.plot(xnew, ypredict2, "b-")
    -plt.plot(x, y ,'ro')
    -plt.axis([0,2.0,0, 15.0])
    -plt.xlabel(r'$x$')
    -plt.ylabel(r'$y$')
    -plt.title(r'Random numbers ')
    -plt.show()
    +  
    a += b
    +a -= b
    +a*= b
    +a /=b
     
    @@ -420,7 +372,7 @@ plt.show()
  • 40
  • 41
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs032.html b/doc/pub/week40/html/._week40-bs032.html index 41aad2c83..efd465633 100644 --- a/doc/pub/week40/html/._week40-bs032.html +++ b/doc/pub/week40/html/._week40-bs032.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,8 +318,12 @@ MathJax.Hub.Config({

     

     

     

    -

    Including Stochastic Gradient Descent with Autograd

    -

    In this code we include the stochastic gradient descent approach discussed above. Note here that we specify which argument we are taking the derivative with respect to when using autograd.

    +

    Using Autograd with OLS

    + +

    We conclude the part on optmization by showing how we can make codes +for linear regression and logistic regression using autograd. The +first example shows results with ordinary leats squares. +

    @@ -326,17 +332,15 @@ MathJax.Hub.Config({
    -
    # Using Autograd to calculate gradients using SGD
    -# OLS example
    +  
    # Using Autograd to calculate gradients for OLS
     from random import random, seed
     import numpy as np
     import autograd.numpy as np
     import matplotlib.pyplot as plt
     from autograd import grad
     
    -# Note change from previous example
    -def CostOLS(y,X,theta):
    -    return np.sum((y-X @ theta)**2)
    +def CostOLS(beta):
    +    return (1.0/n)*np.sum((y-X @ beta)**2)
     
     n = 100
     x = 2*np.random.rand(n,1)
    @@ -355,12 +359,11 @@ EigValues, EigVectors = np= np.random.randn(2,1)
     eta = 1.0/np.max(EigValues)
     Niterations = 1000
    -
    -# Note that we request the derivative wrt third argument (theta, 2 here)
    -training_gradient = grad(CostOLS,2)
    +# define the gradient
    +training_gradient = grad(CostOLS)
     
     for iter in range(Niterations):
    -    gradients = (1.0/n)*training_gradient(y, X, theta)
    +    gradients = training_gradient(theta)
         theta -= eta*gradients
     print("theta from own gd")
     print(theta)
    @@ -378,27 +381,6 @@ plt.xlabel(r
     plt.ylabel(r'$y$')
     plt.title(r'Random numbers ')
     plt.show()
    -
    -n_epochs = 50
    -M = 5   #size of each minibatch
    -m = int(n/M) #number of minibatches
    -t0, t1 = 5, 50
    -def learning_schedule(t):
    -    return t0/(t+t1)
    -
    -theta = np.random.randn(2,1)
    -
    -for epoch in range(n_epochs):
    -# Can you figure out a better way of setting up the contributions to each batch?
    -    for i in range(m):
    -        random_index = M*np.random.randint(m)
    -        xi = X[random_index:random_index+M]
    -        yi = y[random_index:random_index+M]
    -        gradients = (2.0/M)*training_gradient(yi, xi, theta)
    -        eta = learning_schedule(epoch*m+i)
    -        theta = theta - eta*gradients
    -print("theta from own sdg")
    -print(theta)
     
    @@ -440,7 +422,7 @@ theta = np.41
  • 42
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs033.html b/doc/pub/week40/html/._week40-bs033.html index be8eba4ba..25871597d 100644 --- a/doc/pub/week40/html/._week40-bs033.html +++ b/doc/pub/week40/html/._week40-bs033.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,8 @@ MathJax.Hub.Config({

     

     

     

    -

    And Logistic Regression

    +

    Including Stochastic Gradient Descent with Autograd

    +

    In this code we include the stochastic gradient descent approach discussed above. Note here that we specify which argument we are taking the derivative with respect to when using autograd.

    @@ -325,39 +328,79 @@ MathJax.Hub.Config({
    -
    import autograd.numpy as np
    +  
    # Using Autograd to calculate gradients using SGD
    +# OLS example
    +from random import random, seed
    +import numpy as np
    +import autograd.numpy as np
    +import matplotlib.pyplot as plt
     from autograd import grad
     
    -def sigmoid(x):
    -    return 0.5 * (np.tanh(x / 2.) + 1)
    +# Note change from previous example
    +def CostOLS(y,X,theta):
    +    return np.sum((y-X @ theta)**2)
     
    -def logistic_predictions(weights, inputs):
    -    # Outputs probability of a label being true according to logistic model.
    -    return sigmoid(np.dot(inputs, weights))
    +n = 100
    +x = 2*np.random.rand(n,1)
    +y = 4+3*x+np.random.randn(n,1)
     
    -def training_loss(weights):
    -    # Training loss is the negative log-likelihood of the training labels.
    -    preds = logistic_predictions(weights, inputs)
    -    label_probabilities = preds * targets + (1 - preds) * (1 - targets)
    -    return -np.sum(np.log(label_probabilities))
    +X = np.c_[np.ones((n,1)), x]
    +XT_X = X.T @ X
    +theta_linreg = np.linalg.pinv(XT_X) @ (X.T @ y)
    +print("Own inversion")
    +print(theta_linreg)
    +# Hessian matrix
    +H = (2.0/n)* XT_X
    +EigValues, EigVectors = np.linalg.eig(H)
    +print(f"Eigenvalues of Hessian Matrix:{EigValues}")
     
    -# Build a toy dataset.
    -inputs = np.array([[0.52, 1.12,  0.77],
    -                   [0.88, -1.08, 0.15],
    -                   [0.52, 0.06, -1.30],
    -                   [0.74, -2.49, 1.39]])
    -targets = np.array([True, True, False, True])
    +theta = np.random.randn(2,1)
    +eta = 1.0/np.max(EigValues)
    +Niterations = 1000
     
    -# Define a function that returns gradients of training loss using Autograd.
    -training_gradient_fun = grad(training_loss)
    +# Note that we request the derivative wrt third argument (theta, 2 here)
    +training_gradient = grad(CostOLS,2)
     
    -# Optimize weights using gradient descent.
    -weights = np.array([0.0, 0.0, 0.0])
    -print("Initial loss:", training_loss(weights))
    -for i in range(100):
    -    weights -= training_gradient_fun(weights) * 0.01
    +for iter in range(Niterations):
    +    gradients = (1.0/n)*training_gradient(y, X, theta)
    +    theta -= eta*gradients
    +print("theta from own gd")
    +print(theta)
     
    -print("Trained loss:", training_loss(weights))
    +xnew = np.array([[0],[2]])
    +Xnew = np.c_[np.ones((2,1)), xnew]
    +ypredict = Xnew.dot(theta)
    +ypredict2 = Xnew.dot(theta_linreg)
    +
    +plt.plot(xnew, ypredict, "r-")
    +plt.plot(xnew, ypredict2, "b-")
    +plt.plot(x, y ,'ro')
    +plt.axis([0,2.0,0, 15.0])
    +plt.xlabel(r'$x$')
    +plt.ylabel(r'$y$')
    +plt.title(r'Random numbers ')
    +plt.show()
    +
    +n_epochs = 50
    +M = 5   #size of each minibatch
    +m = int(n/M) #number of minibatches
    +t0, t1 = 5, 50
    +def learning_schedule(t):
    +    return t0/(t+t1)
    +
    +theta = np.random.randn(2,1)
    +
    +for epoch in range(n_epochs):
    +# Can you figure out a better way of setting up the contributions to each batch?
    +    for i in range(m):
    +        random_index = M*np.random.randint(m)
    +        xi = X[random_index:random_index+M]
    +        yi = y[random_index:random_index+M]
    +        gradients = (2.0/M)*training_gradient(yi, xi, theta)
    +        eta = learning_schedule(epoch*m+i)
    +        theta = theta - eta*gradients
    +print("theta from own sdg")
    +print(theta)
     
    @@ -399,7 +442,7 @@ weights = np.42
  • 43
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs034.html b/doc/pub/week40/html/._week40-bs034.html index ecdb0dc47..354922a85 100644 --- a/doc/pub/week40/html/._week40-bs034.html +++ b/doc/pub/week40/html/._week40-bs034.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,11 +318,63 @@ MathJax.Hub.Config({

     

     

     

    -

    Videos on Neural Networks

    +

    And Logistic Regression

    -Neural Networks demystified -Building Neural Networks from scratch + +
    +
    +
    +
    +
    +
    import autograd.numpy as np
    +from autograd import grad
    +
    +def sigmoid(x):
    +    return 0.5 * (np.tanh(x / 2.) + 1)
    +
    +def logistic_predictions(weights, inputs):
    +    # Outputs probability of a label being true according to logistic model.
    +    return sigmoid(np.dot(inputs, weights))
    +
    +def training_loss(weights):
    +    # Training loss is the negative log-likelihood of the training labels.
    +    preds = logistic_predictions(weights, inputs)
    +    label_probabilities = preds * targets + (1 - preds) * (1 - targets)
    +    return -np.sum(np.log(label_probabilities))
    +
    +# Build a toy dataset.
    +inputs = np.array([[0.52, 1.12,  0.77],
    +                   [0.88, -1.08, 0.15],
    +                   [0.52, 0.06, -1.30],
    +                   [0.74, -2.49, 1.39]])
    +targets = np.array([True, True, False, True])
    +
    +# Define a function that returns gradients of training loss using Autograd.
    +training_gradient_fun = grad(training_loss)
    +
    +# Optimize weights using gradient descent.
    +weights = np.array([0.0, 0.0, 0.0])
    +print("Initial loss:", training_loss(weights))
    +for i in range(100):
    +    weights -= training_gradient_fun(weights) * 0.01
    +
    +print("Trained loss:", training_loss(weights))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -347,7 +401,7 @@ MathJax.Hub.Config({

  • 43
  • 44
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs035.html b/doc/pub/week40/html/._week40-bs035.html index 4323c5806..1e47c26ad 100644 --- a/doc/pub/week40/html/._week40-bs035.html +++ b/doc/pub/week40/html/._week40-bs035.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,16 +318,11 @@ MathJax.Hub.Config({

     

     

     

    -

    Neural networks

    +

    Videos on Neural Networks

    -

    Artificial neural networks are computational systems that can learn to -perform tasks by considering examples, generally without being -programmed with any task-specific rules. It is supposed to mimic a -biological system, wherein neurons interact by sending signals in the -form of mathematical functions between layers. All layers can contain -an arbitrary number of neurons, and each connection is represented by -a weight variable. -

    +Neural Networks demystified + +Building Neural Networks from scratch

    @@ -352,7 +349,7 @@ a weight variable.

  • 44
  • 45
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs036.html b/doc/pub/week40/html/._week40-bs036.html index d98c0be60..609426261 100644 --- a/doc/pub/week40/html/._week40-bs036.html +++ b/doc/pub/week40/html/._week40-bs036.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,63 +318,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Artificial neurons

    +

    Neural networks

    -

    The field of artificial neural networks has a long history of -development, and is closely connected with the advancement of computer -science and computers in general. A model of artificial neurons was -first developed by McCulloch and Pitts in 1943 to study signal -processing in the brain and has later been refined by others. The -general idea is to mimic neural networks in the human brain, which is -composed of billions of neurons that communicate with each other by -sending electrical signals. Each neuron accumulates its incoming -signals, which must exceed an activation threshold to yield an -output. If the threshold is not overcome, the neuron remains inactive, -i.e. has zero output. -

    - -

    This behaviour has inspired a simple mathematical model for an artificial neuron.

    - -$$ -\begin{equation} - y = f\left(\sum_{i=1}^n w_ix_i\right) = f(u) -\tag{6} -\end{equation} -$$ - -

    Here, the output \( y \) of the neuron is the value of its activation function, which have as input -a weighted sum of signals \( x_i, \dots ,x_n \) received by \( n \) other neurons. -

    - -

    Conceptually, it is helpful to divide neural networks into four -categories: -

    -
      -
    1. general purpose neural networks for supervised learning,
    2. -
    3. neural networks designed specifically for image processing, the most prominent example of this class being Convolutional Neural Networks (CNNs),
    4. -
    5. neural networks for sequential data such as Recurrent Neural Networks (RNNs), and
    6. -
    7. neural networks for unsupervised learning such as Deep Boltzmann Machines.
    8. -
    -

    In natural science, DNNs and CNNs have already found numerous -applications. In statistical physics, they have been applied to detect -phase transitions in 2D Ising and Potts models, lattice gauge -theories, and different phases of polymers, or solving the -Navier-Stokes equation in weather forecasting. Deep learning has also -found interesting applications in quantum physics. Various quantum -phase transitions can be detected and studied using DNNs and CNNs, -topological phases, and even non-equilibrium many-body -localization. Representing quantum states as DNNs quantum state -tomography are among some of the impressive achievements to reveal the -potential of DNNs to facilitate the study of quantum systems. -

    - -

    In quantum information theory, it has been shown that one can perform -gate decompositions with the help of neural. -

    - -

    The applications are not limited to the natural sciences. There is a -plethora of applications in essentially all disciplines, from the -humanities to life science and medicine. +

    Artificial neural networks are computational systems that can learn to +perform tasks by considering examples, generally without being +programmed with any task-specific rules. It is supposed to mimic a +biological system, wherein neurons interact by sending signals in the +form of mathematical functions between layers. All layers can contain +an arbitrary number of neurons, and each connection is represented by +a weight variable.

    @@ -400,7 +354,7 @@ humanities to life science and medicine.

  • 45
  • 46
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs037.html b/doc/pub/week40/html/._week40-bs037.html index ee773cb5f..799d6f50a 100644 --- a/doc/pub/week40/html/._week40-bs037.html +++ b/doc/pub/week40/html/._week40-bs037.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,28 +318,63 @@ MathJax.Hub.Config({

     

     

     

    -

    Neural network types

    +

    Artificial neurons

    -

    An artificial neural network (ANN), is a computational model that -consists of layers of connected neurons, or nodes or units. We will -refer to these interchangeably as units or nodes, and sometimes as -neurons. +

    The field of artificial neural networks has a long history of +development, and is closely connected with the advancement of computer +science and computers in general. A model of artificial neurons was +first developed by McCulloch and Pitts in 1943 to study signal +processing in the brain and has later been refined by others. The +general idea is to mimic neural networks in the human brain, which is +composed of billions of neurons that communicate with each other by +sending electrical signals. Each neuron accumulates its incoming +signals, which must exceed an activation threshold to yield an +output. If the threshold is not overcome, the neuron remains inactive, +i.e. has zero output.

    -

    It is supposed to mimic a biological nervous system by letting each -neuron interact with other neurons by sending signals in the form of -mathematical functions between layers. A wide variety of different -ANNs have been developed, but most of them consist of an input layer, -an output layer and eventual layers in-between, called hidden -layers. All layers can contain an arbitrary number of nodes, and each -connection between two nodes is associated with a weight variable. +

    This behaviour has inspired a simple mathematical model for an artificial neuron.

    + +$$ +\begin{equation} + y = f\left(\sum_{i=1}^n w_ix_i\right) = f(u) +\tag{6} +\end{equation} +$$ + +

    Here, the output \( y \) of the neuron is the value of its activation function, which have as input +a weighted sum of signals \( x_i, \dots ,x_n \) received by \( n \) other neurons.

    -

    Neural networks (also called neural nets) are neural-inspired -nonlinear models for supervised learning. As we will see, neural nets -can be viewed as natural, more powerful extensions of supervised -learning methods such as linear and logistic regression and soft-max -methods we discussed earlier. +

    Conceptually, it is helpful to divide neural networks into four +categories: +

    +
      +
    1. general purpose neural networks for supervised learning,
    2. +
    3. neural networks designed specifically for image processing, the most prominent example of this class being Convolutional Neural Networks (CNNs),
    4. +
    5. neural networks for sequential data such as Recurrent Neural Networks (RNNs), and
    6. +
    7. neural networks for unsupervised learning such as Deep Boltzmann Machines.
    8. +
    +

    In natural science, DNNs and CNNs have already found numerous +applications. In statistical physics, they have been applied to detect +phase transitions in 2D Ising and Potts models, lattice gauge +theories, and different phases of polymers, or solving the +Navier-Stokes equation in weather forecasting. Deep learning has also +found interesting applications in quantum physics. Various quantum +phase transitions can be detected and studied using DNNs and CNNs, +topological phases, and even non-equilibrium many-body +localization. Representing quantum states as DNNs quantum state +tomography are among some of the impressive achievements to reveal the +potential of DNNs to facilitate the study of quantum systems. +

    + +

    In quantum information theory, it has been shown that one can perform +gate decompositions with the help of neural. +

    + +

    The applications are not limited to the natural sciences. There is a +plethora of applications in essentially all disciplines, from the +humanities to life science and medicine.

    @@ -365,7 +402,7 @@ methods we discussed earlier.

  • 46
  • 47
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs038.html b/doc/pub/week40/html/._week40-bs038.html index bf243d488..8adc4e6b9 100644 --- a/doc/pub/week40/html/._week40-bs038.html +++ b/doc/pub/week40/html/._week40-bs038.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,19 +318,28 @@ MathJax.Hub.Config({

     

     

     

    -

    Feed-forward neural networks

    +

    Neural network types

    -

    The feed-forward neural network (FFNN) was the first and simplest type -of ANNs that were devised. In this network, the information moves in -only one direction: forward through the layers. +

    An artificial neural network (ANN), is a computational model that +consists of layers of connected neurons, or nodes or units. We will +refer to these interchangeably as units or nodes, and sometimes as +neurons.

    -

    Nodes are represented by circles, while the arrows display the -connections between the nodes, including the direction of information -flow. Additionally, each arrow corresponds to a weight variable -(figure to come). We observe that each node in a layer is connected -to all nodes in the subsequent layer, making this a so-called -fully-connected FFNN. +

    It is supposed to mimic a biological nervous system by letting each +neuron interact with other neurons by sending signals in the form of +mathematical functions between layers. A wide variety of different +ANNs have been developed, but most of them consist of an input layer, +an output layer and eventual layers in-between, called hidden +layers. All layers can contain an arbitrary number of nodes, and each +connection between two nodes is associated with a weight variable. +

    + +

    Neural networks (also called neural nets) are neural-inspired +nonlinear models for supervised learning. As we will see, neural nets +can be viewed as natural, more powerful extensions of supervised +learning methods such as linear and logistic regression and soft-max +methods we discussed earlier.

    @@ -356,7 +367,7 @@ to all nodes in the subsequent layer, making this a so-called

  • 47
  • 48
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs039.html b/doc/pub/week40/html/._week40-bs039.html index ef512643a..7acc308eb 100644 --- a/doc/pub/week40/html/._week40-bs039.html +++ b/doc/pub/week40/html/._week40-bs039.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,27 +318,19 @@ MathJax.Hub.Config({

     

     

     

    -

    Convolutional Neural Network

    +

    Feed-forward neural networks

    -

    A different variant of FFNNs are convolutional neural networks -(CNNs), which have a connectivity pattern inspired by the animal -visual cortex. Individual neurons in the visual cortex only respond to -stimuli from small sub-regions of the visual field, called a receptive -field. This makes the neurons well-suited to exploit the strong -spatially local correlation present in natural images. The response of -each neuron can be approximated mathematically as a convolution -operation. (figure to come) +

    The feed-forward neural network (FFNN) was the first and simplest type +of ANNs that were devised. In this network, the information moves in +only one direction: forward through the layers.

    -

    Convolutional neural networks emulate the behaviour of neurons in the -visual cortex by enforcing a local connectivity pattern between -nodes of adjacent layers: Each node in a convolutional layer is -connected only to a subset of the nodes in the previous layer, in -contrast to the fully-connected FFNN. Often, CNNs consist of several -convolutional layers that learn local features of the input, with a -fully-connected layer at the end, which gathers all the local data and -produces the outputs. They have wide applications in image and video -recognition. +

    Nodes are represented by circles, while the arrows display the +connections between the nodes, including the direction of information +flow. Additionally, each arrow corresponds to a weight variable +(figure to come). We observe that each node in a layer is connected +to all nodes in the subsequent layer, making this a so-called +fully-connected FFNN.

    @@ -364,7 +358,7 @@ recognition.

  • 48
  • 49
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs040.html b/doc/pub/week40/html/._week40-bs040.html index c8def1c52..0e433c5ce 100644 --- a/doc/pub/week40/html/._week40-bs040.html +++ b/doc/pub/week40/html/._week40-bs040.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,18 +318,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Recurrent neural networks

    +

    Convolutional Neural Network

    -

    So far we have only mentioned ANNs where information flows in one -direction: forward. Recurrent neural networks on the other hand, -have connections between nodes that form directed cycles. This -creates a form of internal memory which are able to capture -information on what has been calculated before; the output is -dependent on the previous computations. Recurrent NNs make use of -sequential information by performing the same task for every element -in a sequence, where each element depends on previous elements. An -example of such information is sentences, making recurrent NNs -especially well-suited for handwriting and speech recognition. +

    A different variant of FFNNs are convolutional neural networks +(CNNs), which have a connectivity pattern inspired by the animal +visual cortex. Individual neurons in the visual cortex only respond to +stimuli from small sub-regions of the visual field, called a receptive +field. This makes the neurons well-suited to exploit the strong +spatially local correlation present in natural images. The response of +each neuron can be approximated mathematically as a convolution +operation. (figure to come) +

    + +

    Convolutional neural networks emulate the behaviour of neurons in the +visual cortex by enforcing a local connectivity pattern between +nodes of adjacent layers: Each node in a convolutional layer is +connected only to a subset of the nodes in the previous layer, in +contrast to the fully-connected FFNN. Often, CNNs consist of several +convolutional layers that learn local features of the input, with a +fully-connected layer at the end, which gathers all the local data and +produces the outputs. They have wide applications in image and video +recognition.

    @@ -355,7 +366,7 @@ especially well-suited for handwriting and speech recognition.

  • 49
  • 50
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs041.html b/doc/pub/week40/html/._week40-bs041.html index f4c68b793..36b8f07da 100644 --- a/doc/pub/week40/html/._week40-bs041.html +++ b/doc/pub/week40/html/._week40-bs041.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,18 +318,18 @@ MathJax.Hub.Config({

     

     

     

    -

    Other types of networks

    +

    Recurrent neural networks

    -

    There are many other kinds of ANNs that have been developed. One type -that is specifically designed for interpolation in multidimensional -space is the radial basis function (RBF) network. RBFs are typically -made up of three layers: an input layer, a hidden layer with -non-linear radial symmetric activation functions and a linear output -layer (''linear'' here means that each node in the output layer has a -linear activation function). The layers are normally fully-connected -and there are no cycles, thus RBFs can be viewed as a type of -fully-connected FFNN. They are however usually treated as a separate -type of NN due the unusual activation functions. +

    So far we have only mentioned ANNs where information flows in one +direction: forward. Recurrent neural networks on the other hand, +have connections between nodes that form directed cycles. This +creates a form of internal memory which are able to capture +information on what has been calculated before; the output is +dependent on the previous computations. Recurrent NNs make use of +sequential information by performing the same task for every element +in a sequence, where each element depends on previous elements. An +example of such information is sentences, making recurrent NNs +especially well-suited for handwriting and speech recognition.

    @@ -355,7 +357,7 @@ type of NN due the unusual activation functions.

  • 50
  • 51
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs042.html b/doc/pub/week40/html/._week40-bs042.html index 261e28bad..3e23d5f0d 100644 --- a/doc/pub/week40/html/._week40-bs042.html +++ b/doc/pub/week40/html/._week40-bs042.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,16 +318,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Multilayer perceptrons

    +

    Other types of networks

    -

    One uses often so-called fully-connected feed-forward neural networks -with three or more layers (an input layer, one or more hidden layers -and an output layer) consisting of neurons that have non-linear -activation functions. +

    There are many other kinds of ANNs that have been developed. One type +that is specifically designed for interpolation in multidimensional +space is the radial basis function (RBF) network. RBFs are typically +made up of three layers: an input layer, a hidden layer with +non-linear radial symmetric activation functions and a linear output +layer (''linear'' here means that each node in the output layer has a +linear activation function). The layers are normally fully-connected +and there are no cycles, thus RBFs can be viewed as a type of +fully-connected FFNN. They are however usually treated as a separate +type of NN due the unusual activation functions.

    -

    Such networks are often called multilayer perceptrons (MLPs).

    -

      @@ -351,7 +357,7 @@ activation functions.
    • 51
    • 52
    • ...
    • -
    • 69
    • +
    • 70
    • »
    diff --git a/doc/pub/week40/html/._week40-bs043.html b/doc/pub/week40/html/._week40-bs043.html index 5f14f3c55..762d5b233 100644 --- a/doc/pub/week40/html/._week40-bs043.html +++ b/doc/pub/week40/html/._week40-bs043.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,20 +318,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Why multilayer perceptrons?

    +

    Multilayer perceptrons

    -

    According to the Universal approximation theorem, a feed-forward -neural network with just a single hidden layer containing a finite -number of neurons can approximate a continuous multidimensional -function to arbitrary accuracy, assuming the activation function for -the hidden layer is a non-constant, bounded and -monotonically-increasing continuous function. +

    One uses often so-called fully-connected feed-forward neural networks +with three or more layers (an input layer, one or more hidden layers +and an output layer) consisting of neurons that have non-linear +activation functions.

    -

    Note that the requirements on the activation function only applies to -the hidden layer, the output nodes are always assumed to be linear, so -as to not restrict the range of output values. -

    +

    Such networks are often called multilayer perceptrons (MLPs).

    @@ -356,7 +353,7 @@ as to not restrict the range of output values.

  • 52
  • 53
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs044.html b/doc/pub/week40/html/._week40-bs044.html index 024a02b5e..004987acc 100644 --- a/doc/pub/week40/html/._week40-bs044.html +++ b/doc/pub/week40/html/._week40-bs044.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,15 +318,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Illustration of a single perceptropn model and a multi-perceptron model

    +

    Why multilayer perceptrons?

    -
    -
    -
    -

    Figure 1: In a) we show a single perceptron model while in b) we dispay a network with two hidden layers, an input layer and an output layer.

    -
    -

    -
    +

    According to the Universal approximation theorem, a feed-forward +neural network with just a single hidden layer containing a finite +number of neurons can approximate a continuous multidimensional +function to arbitrary accuracy, assuming the activation function for +the hidden layer is a non-constant, bounded and +monotonically-increasing continuous function. +

    + +

    Note that the requirements on the activation function only applies to +the hidden layer, the output nodes are always assumed to be linear, so +as to not restrict the range of output values. +

    @@ -351,7 +358,7 @@ MathJax.Hub.Config({

  • 53
  • 54
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs045.html b/doc/pub/week40/html/._week40-bs045.html index b7a020b82..869597536 100644 --- a/doc/pub/week40/html/._week40-bs045.html +++ b/doc/pub/week40/html/._week40-bs045.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,68 +318,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Examples of XOR, OR and AND gates

    +

    Illustration of a single perceptropn model and a multi-perceptron model

    -

    Let us first try to fit various gates using standard linear -regression. The gates we are thinking of are the classical XOR, OR and -AND gates, well-known elements in computer science. The tables here -show how we can set up the inputs \( x_1 \) and \( x_2 \) in order to yield a -specific target \( y_i \). -

    - - - -
    -
    -
    -
    -
    -
    """
    -Simple code that tests XOR, OR and AND gates with linear regression
    -"""
    -
    -import numpy as np
    -# Design matrix
    -X = np.array([ [1, 0, 0], [1, 0, 1], [1, 1, 0],[1, 1, 1]],dtype=np.float64)
    -print(f"The X.TX  matrix:{X.T @ X}")
    -Xinv = np.linalg.pinv(X.T @ X)
    -print(f"The invers of X.TX  matrix:{Xinv}")
    -
    -# The XOR gate 
    -yXOR = np.array( [ 0, 1 ,1, 0])
    -ThetaXOR  = Xinv @ X.T @ yXOR
    -print(f"The values of theta for the XOR gate:{ThetaXOR}")
    -print(f"The linear regression prediction  for the XOR gate:{X @ ThetaXOR}")
    -
    -
    -# The OR gate 
    -yOR = np.array( [ 0, 1 ,1, 1])
    -ThetaOR  = Xinv @ X.T @ yOR
    -print(f"The values of theta for the OR gate:{ThetaOR}")
    -print(f"The linear regression prediction  for the OR gate:{X @ ThetaOR}")
    -
    -
    -# The OR gate 
    -yAND = np.array( [ 0, 0 ,0, 1])
    -ThetaAND  = Xinv @ X.T @ yAND
    -print(f"The values of theta for the AND gate:{ThetaAND}")
    -print(f"The linear regression prediction  for the AND gate:{X @ ThetaAND}")
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -

    What is happening here?

    +
    +
    +
    +

    Figure 1: In a) we show a single perceptron model while in b) we dispay a network with two hidden layers, an input layer and an output layer.

    +
    +

    +

    @@ -404,7 +353,7 @@ ThetaAND = Xinv 54

  • 55
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs046.html b/doc/pub/week40/html/._week40-bs046.html index 331ab6594..e3062d681 100644 --- a/doc/pub/week40/html/._week40-bs046.html +++ b/doc/pub/week40/html/._week40-bs046.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,14 @@ MathJax.Hub.Config({

     

     

     

    -

    Does Logistic Regression do a better Job?

    +

    Examples of XOR, OR and AND gates

    + +

    Let us first try to fit various gates using standard linear +regression. The gates we are thinking of are the classical XOR, OR and +AND gates, well-known elements in computer science. The tables here +show how we can set up the inputs \( x_1 \) and \( x_2 \) in order to yield a +specific target \( y_i \). +

    @@ -326,14 +335,10 @@ MathJax.Hub.Config({
    """
    -Simple code that tests XOR and OR gates with linear regression
    -and logistic regression
    +Simple code that tests XOR, OR and AND gates with linear regression
     """
     
    -import matplotlib.pyplot as plt
    -from sklearn.linear_model import LogisticRegression
     import numpy as np
    -
     # Design matrix
     X = np.array([ [1, 0, 0], [1, 0, 1], [1, 1, 0],[1, 1, 1]],dtype=np.float64)
     print(f"The X.TX  matrix:{X.T @ X}")
    @@ -359,21 +364,6 @@ yAND = np.= Xinv @ X.T @ yAND
     print(f"The values of theta for the AND gate:{ThetaAND}")
     print(f"The linear regression prediction  for the AND gate:{X @ ThetaAND}")
    -
    -# Now we change to logistic regression
    -
    -
    -# Logistic Regression
    -logreg = LogisticRegression()
    -logreg.fit(X, yOR)
    -print("Test set accuracy with Logistic Regression for OR gate: {:.2f}".format(logreg.score(X,yOR)))
    -
    -logreg.fit(X, yXOR)
    -print("Test set accuracy with Logistic Regression for XOR gate: {:.2f}".format(logreg.score(X,yXOR)))
    -
    -
    -logreg.fit(X, yAND)
    -print("Test set accuracy with Logistic Regression for AND gate: {:.2f}".format(logreg.score(X,yAND)))
     
    @@ -389,7 +379,7 @@ logreg.fit(X, yAND)
    -

    Not exactly impressive, but somewhat better.

    +

    What is happening here?

    @@ -416,7 +406,7 @@ logreg.fit(X, yAND)

  • 55
  • 56
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs047.html b/doc/pub/week40/html/._week40-bs047.html index 5bce33dd4..d92470c7e 100644 --- a/doc/pub/week40/html/._week40-bs047.html +++ b/doc/pub/week40/html/._week40-bs047.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,7 +318,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Adding Neural Networks

    +

    Does Logistic Regression do a better Job?

    @@ -325,14 +327,55 @@ MathJax.Hub.Config({
    -
    # and now neural networks with Scikit-Learn and the XOR
    +  
    """
    +Simple code that tests XOR and OR gates with linear regression
    +and logistic regression
    +"""
     
    -from sklearn.neural_network import MLPClassifier
    -from sklearn.datasets import make_classification
    -X, yXOR = make_classification(n_samples=100, random_state=1)
    -FFNN = MLPClassifier(random_state=1, max_iter=300).fit(X, yXOR)
    -FFNN.predict_proba(X)
    -print(f"Test set accuracy with Feed Forward Neural Network  for XOR gate:{FFNN.score(X, yXOR)}")
    +import matplotlib.pyplot as plt
    +from sklearn.linear_model import LogisticRegression
    +import numpy as np
    +
    +# Design matrix
    +X = np.array([ [1, 0, 0], [1, 0, 1], [1, 1, 0],[1, 1, 1]],dtype=np.float64)
    +print(f"The X.TX  matrix:{X.T @ X}")
    +Xinv = np.linalg.pinv(X.T @ X)
    +print(f"The invers of X.TX  matrix:{Xinv}")
    +
    +# The XOR gate 
    +yXOR = np.array( [ 0, 1 ,1, 0])
    +ThetaXOR  = Xinv @ X.T @ yXOR
    +print(f"The values of theta for the XOR gate:{ThetaXOR}")
    +print(f"The linear regression prediction  for the XOR gate:{X @ ThetaXOR}")
    +
    +
    +# The OR gate 
    +yOR = np.array( [ 0, 1 ,1, 1])
    +ThetaOR  = Xinv @ X.T @ yOR
    +print(f"The values of theta for the OR gate:{ThetaOR}")
    +print(f"The linear regression prediction  for the OR gate:{X @ ThetaOR}")
    +
    +
    +# The OR gate 
    +yAND = np.array( [ 0, 0 ,0, 1])
    +ThetaAND  = Xinv @ X.T @ yAND
    +print(f"The values of theta for the AND gate:{ThetaAND}")
    +print(f"The linear regression prediction  for the AND gate:{X @ ThetaAND}")
    +
    +# Now we change to logistic regression
    +
    +
    +# Logistic Regression
    +logreg = LogisticRegression()
    +logreg.fit(X, yOR)
    +print("Test set accuracy with Logistic Regression for OR gate: {:.2f}".format(logreg.score(X,yOR)))
    +
    +logreg.fit(X, yXOR)
    +print("Test set accuracy with Logistic Regression for XOR gate: {:.2f}".format(logreg.score(X,yXOR)))
    +
    +
    +logreg.fit(X, yAND)
    +print("Test set accuracy with Logistic Regression for AND gate: {:.2f}".format(logreg.score(X,yAND)))
     
    @@ -348,6 +391,7 @@ FFNN.predict_proba(X)
    +

    Not exactly impressive, but somewhat better.

    @@ -374,7 +418,7 @@ FFNN.predict_proba(X)

  • 56
  • 57
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs048.html b/doc/pub/week40/html/._week40-bs048.html index d51073b75..465a4e3a1 100644 --- a/doc/pub/week40/html/._week40-bs048.html +++ b/doc/pub/week40/html/._week40-bs048.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,20 +318,38 @@ MathJax.Hub.Config({

     

     

     

    -

    Mathematical model

    +

    Adding Neural Networks

    -

    The output \( y \) is produced via the activation function \( f \)

    -$$ - y = f\left(\sum_{i=1}^n w_ix_i + b_i\right) = f(z), -$$ -

    This function receives \( x_i \) as inputs. -Here the activation \( z=(\sum_{i=1}^n w_ix_i+b_i) \). -In an FFNN of such neurons, the inputs \( x_i \) are the outputs of -the neurons in the preceding layer. Furthermore, an MLP is -fully-connected, which means that each neuron receives a weighted sum -of the outputs of all neurons in the previous layer. -

    + +
    +
    +
    +
    +
    +
    # and now neural networks with Scikit-Learn and the XOR
    +
    +from sklearn.neural_network import MLPClassifier
    +from sklearn.datasets import make_classification
    +X, yXOR = make_classification(n_samples=100, random_state=1)
    +FFNN = MLPClassifier(random_state=1, max_iter=300).fit(X, yXOR)
    +FFNN.predict_proba(X)
    +print(f"Test set accuracy with Feed Forward Neural Network  for XOR gate:{FFNN.score(X, yXOR)}")
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -356,7 +376,7 @@ of the outputs of all neurons in the previous layer.

  • 57
  • 58
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs049.html b/doc/pub/week40/html/._week40-bs049.html index 2541dea00..966dfc78b 100644 --- a/doc/pub/week40/html/._week40-bs049.html +++ b/doc/pub/week40/html/._week40-bs049.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -318,45 +320,17 @@ MathJax.Hub.Config({

    Mathematical model

    -

    First, for each node \( i \) in the first hidden layer, we calculate a weighted sum \( z_i^1 \) of the input coordinates \( x_j \),

    - +

    The output \( y \) is produced via the activation function \( f \)

    $$ -\begin{equation} z_i^1 = \sum_{j=1}^{M} w_{ij}^1 x_j + b_i^1 -\tag{7} -\end{equation} + y = f\left(\sum_{i=1}^n w_ix_i + b_i\right) = f(z), $$ -

    Here \( b_i \) is the so-called bias which is normally needed in -case of zero activation weights or inputs. How to fix the biases and -the weights will be discussed below. The value of \( z_i^1 \) is the -argument to the activation function \( f_i \) of each node \( i \), The -variable \( M \) stands for all possible inputs to a given node \( i \) in the -first layer. We define the output \( y_i^1 \) of all neurons in layer 1 as -

    - -$$ -\begin{equation} - y_i^1 = f(z_i^1) = f\left(\sum_{j=1}^M w_{ij}^1 x_j + b_i^1\right) -\tag{8} -\end{equation} -$$ - -

    where we assume that all nodes in the same layer have identical -activation functions, hence the notation \( f \). In general, we could assume in the more general case that different layers have different activation functions. -In this case we would identify these functions with a superscript \( l \) for the \( l \)-th layer, -

    - -$$ -\begin{equation} - y_i^l = f^l(u_i^l) = f^l\left(\sum_{j=1}^{N_{l-1}} w_{ij}^l y_j^{l-1} + b_i^l\right) -\tag{9} -\end{equation} -$$ - -

    where \( N_l \) is the number of nodes in layer \( l \). When the output of -all the nodes in the first hidden layer are computed, the values of -the subsequent layer can be calculated and so forth until the output -is obtained. +

    This function receives \( x_i \) as inputs. +Here the activation \( z=(\sum_{i=1}^n w_ix_i+b_i) \). +In an FFNN of such neurons, the inputs \( x_i \) are the outputs of +the neurons in the preceding layer. Furthermore, an MLP is +fully-connected, which means that each neuron receives a weighted sum +of the outputs of all neurons in the previous layer.

    @@ -384,7 +358,7 @@ is obtained.

  • 58
  • 59
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs050.html b/doc/pub/week40/html/._week40-bs050.html index ec27dba50..2ec168484 100644 --- a/doc/pub/week40/html/._week40-bs050.html +++ b/doc/pub/week40/html/._week40-bs050.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -318,29 +320,46 @@ MathJax.Hub.Config({

    Mathematical model

    -

    The output of neuron \( i \) in layer 2 is thus,

    +

    First, for each node \( i \) in the first hidden layer, we calculate a weighted sum \( z_i^1 \) of the input coordinates \( x_j \),

    $$ -\begin{align} - y_i^2 &= f^2\left(\sum_{j=1}^N w_{ij}^2 y_j^1 + b_i^2\right) -\tag{10}\\ - &= f^2\left[\sum_{j=1}^N w_{ij}^2f^1\left(\sum_{k=1}^M w_{jk}^1 x_k + b_j^1\right) + b_i^2\right] -\tag{11} -\end{align} +\begin{equation} z_i^1 = \sum_{j=1}^{M} w_{ij}^1 x_j + b_i^1 +\tag{7} +\end{equation} $$ -

    where we have substituted \( y_k^1 \) with the inputs \( x_k \). Finally, the ANN output reads

    +

    Here \( b_i \) is the so-called bias which is normally needed in +case of zero activation weights or inputs. How to fix the biases and +the weights will be discussed below. The value of \( z_i^1 \) is the +argument to the activation function \( f_i \) of each node \( i \), The +variable \( M \) stands for all possible inputs to a given node \( i \) in the +first layer. We define the output \( y_i^1 \) of all neurons in layer 1 as +

    $$ -\begin{align} - y_i^3 &= f^3\left(\sum_{j=1}^N w_{ij}^3 y_j^2 + b_i^3\right) -\tag{12}\\ - &= f_3\left[\sum_{j} w_{ij}^3 f^2\left(\sum_{k} w_{jk}^2 f^1\left(\sum_{m} w_{km}^1 x_m + b_k^1\right) + b_j^2\right) - + b_1^3\right] -\tag{13} -\end{align} +\begin{equation} + y_i^1 = f(z_i^1) = f\left(\sum_{j=1}^M w_{ij}^1 x_j + b_i^1\right) +\tag{8} +\end{equation} $$ +

    where we assume that all nodes in the same layer have identical +activation functions, hence the notation \( f \). In general, we could assume in the more general case that different layers have different activation functions. +In this case we would identify these functions with a superscript \( l \) for the \( l \)-th layer, +

    + +$$ +\begin{equation} + y_i^l = f^l(u_i^l) = f^l\left(\sum_{j=1}^{N_{l-1}} w_{ij}^l y_j^{l-1} + b_i^l\right) +\tag{9} +\end{equation} +$$ + +

    where \( N_l \) is the number of nodes in layer \( l \). When the output of +all the nodes in the first hidden layer are computed, the values of +the subsequent layer can be calculated and so forth until the output +is obtained. +

    @@ -367,7 +386,7 @@ $$

  • 59
  • 60
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs051.html b/doc/pub/week40/html/._week40-bs051.html index b97a59fd4..cd90f4e70 100644 --- a/doc/pub/week40/html/._week40-bs051.html +++ b/doc/pub/week40/html/._week40-bs051.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -318,20 +320,29 @@ MathJax.Hub.Config({

    Mathematical model

    -

    We can generalize this expression to an MLP with \( l \) hidden -layers. The complete functional form is, -

    +

    The output of neuron \( i \) in layer 2 is thus,

    $$ \begin{align} -&y^{l+1}_i = f^{l+1}\left[\!\sum_{j=1}^{N_l} w_{ij}^3 f^l\left(\sum_{k=1}^{N_{l-1}}w_{jk}^{l-1}\left(\dots f^1\left(\sum_{n=1}^{N_0} w_{mn}^1 x_n+ b_m^1\right)\dots\right)+b_k^2\right)+b_1^3\right] && -\tag{14} + y_i^2 &= f^2\left(\sum_{j=1}^N w_{ij}^2 y_j^1 + b_i^2\right) +\tag{10}\\ + &= f^2\left[\sum_{j=1}^N w_{ij}^2f^1\left(\sum_{k=1}^M w_{jk}^1 x_k + b_j^1\right) + b_i^2\right] +\tag{11} +\end{align} +$$ + +

    where we have substituted \( y_k^1 \) with the inputs \( x_k \). Finally, the ANN output reads

    + +$$ +\begin{align} + y_i^3 &= f^3\left(\sum_{j=1}^N w_{ij}^3 y_j^2 + b_i^3\right) +\tag{12}\\ + &= f_3\left[\sum_{j} w_{ij}^3 f^2\left(\sum_{k} w_{jk}^2 f^1\left(\sum_{m} w_{km}^1 x_m + b_k^1\right) + b_j^2\right) + + b_1^3\right] +\tag{13} \end{align} $$ -

    which illustrates a basic property of MLPs: The only independent -variables are the input values \( x_n \). -

    @@ -358,7 +369,7 @@ variables are the input values \( x_n \).

  • 60
  • 61
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs052.html b/doc/pub/week40/html/._week40-bs052.html index 2d1d02b86..df224aeb3 100644 --- a/doc/pub/week40/html/._week40-bs052.html +++ b/doc/pub/week40/html/._week40-bs052.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -318,28 +320,19 @@ MathJax.Hub.Config({

    Mathematical model

    -

    This confirms that an MLP, despite its quite convoluted mathematical -form, is nothing more than an analytic function, specifically a -mapping of real-valued vectors \( \hat{x} \in \mathbb{R}^n \rightarrow -\hat{y} \in \mathbb{R}^m \). -

    - -

    Furthermore, the flexibility and universality of an MLP can be -illustrated by realizing that the expression is essentially a nested -sum of scaled activation functions of the form +

    We can generalize this expression to an MLP with \( l \) hidden +layers. The complete functional form is,

    $$ -\begin{equation} - f(x) = c_1 f(c_2 x + c_3) + c_4 -\tag{15} -\end{equation} +\begin{align} +&y^{l+1}_i = f^{l+1}\left[\!\sum_{j=1}^{N_l} w_{ij}^3 f^l\left(\sum_{k=1}^{N_{l-1}}w_{jk}^{l-1}\left(\dots f^1\left(\sum_{n=1}^{N_0} w_{mn}^1 x_n+ b_m^1\right)\dots\right)+b_k^2\right)+b_1^3\right] && +\tag{14} +\end{align} $$ -

    where the parameters \( c_i \) are weights and biases. By adjusting these -parameters, the activation functions can be shifted up and down or -left and right, change slope or be rescaled which is the key to the -flexibility of a neural network. +

    which illustrates a basic property of MLPs: The only independent +variables are the input values \( x_n \).

    @@ -367,7 +360,7 @@ flexibility of a neural network.

  • 61
  • 62
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs053.html b/doc/pub/week40/html/._week40-bs053.html index 850e113f2..2bb3ad162 100644 --- a/doc/pub/week40/html/._week40-bs053.html +++ b/doc/pub/week40/html/._week40-bs053.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,41 +318,31 @@ MathJax.Hub.Config({

     

     

     

    -

    Matrix-vector notation

    +

    Mathematical model

    -

    We can introduce a more convenient notation for the activations in an A NN.

    - -

    Additionally, we can represent the biases and activations -as layer-wise column vectors \( \hat{b}_l \) and \( \hat{y}_l \), so that the \( i \)-th element of each vector -is the bias \( b_i^l \) and activation \( y_i^l \) of node \( i \) in layer \( l \) respectively. +

    This confirms that an MLP, despite its quite convoluted mathematical +form, is nothing more than an analytic function, specifically a +mapping of real-valued vectors \( \hat{x} \in \mathbb{R}^n \rightarrow +\hat{y} \in \mathbb{R}^m \).

    -

    We have that \( \mathrm{W}_l \) is an \( N_{l-1} \times N_l \) matrix, while \( \hat{b}_l \) and \( \hat{y}_l \) are \( N_l \times 1 \) column vectors. -With this notation, the sum becomes a matrix-vector multiplication, and we can write -the equation for the activations of hidden layer 2 (assuming three nodes for simplicity) as +

    Furthermore, the flexibility and universality of an MLP can be +illustrated by realizing that the expression is essentially a nested +sum of scaled activation functions of the form

    + $$ \begin{equation} - \hat{y}_2 = f_2(\mathrm{W}_2 \hat{y}_{1} + \hat{b}_{2}) = - f_2\left(\left[\begin{array}{ccc} - w^2_{11} &w^2_{12} &w^2_{13} \\ - w^2_{21} &w^2_{22} &w^2_{23} \\ - w^2_{31} &w^2_{32} &w^2_{33} \\ - \end{array} \right] \cdot - \left[\begin{array}{c} - y^1_1 \\ - y^1_2 \\ - y^1_3 \\ - \end{array}\right] + - \left[\begin{array}{c} - b^2_1 \\ - b^2_2 \\ - b^2_3 \\ - \end{array}\right]\right). -\tag{16} + f(x) = c_1 f(c_2 x + c_3) + c_4 +\tag{15} \end{equation} $$ +

    where the parameters \( c_i \) are weights and biases. By adjusting these +parameters, the activation functions can be shifted up and down or +left and right, change slope or be rescaled which is the key to the +flexibility of a neural network. +

    @@ -377,7 +369,7 @@ $$

  • 62
  • 63
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs054.html b/doc/pub/week40/html/._week40-bs054.html index bf0aba6a7..37962ba53 100644 --- a/doc/pub/week40/html/._week40-bs054.html +++ b/doc/pub/week40/html/._week40-bs054.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,24 +318,41 @@ MathJax.Hub.Config({

     

     

     

    -

    Matrix-vector notation and activation

    +

    Matrix-vector notation

    -

    The activation of node \( i \) in layer 2 is

    +

    We can introduce a more convenient notation for the activations in an A NN.

    +

    Additionally, we can represent the biases and activations +as layer-wise column vectors \( \hat{b}_l \) and \( \hat{y}_l \), so that the \( i \)-th element of each vector +is the bias \( b_i^l \) and activation \( y_i^l \) of node \( i \) in layer \( l \) respectively. +

    + +

    We have that \( \mathrm{W}_l \) is an \( N_{l-1} \times N_l \) matrix, while \( \hat{b}_l \) and \( \hat{y}_l \) are \( N_l \times 1 \) column vectors. +With this notation, the sum becomes a matrix-vector multiplication, and we can write +the equation for the activations of hidden layer 2 (assuming three nodes for simplicity) as +

    $$ \begin{equation} - y^2_i = f_2\Bigr(w^2_{i1}y^1_1 + w^2_{i2}y^1_2 + w^2_{i3}y^1_3 + b^2_i\Bigr) = - f_2\left(\sum_{j=1}^3 w^2_{ij} y_j^1 + b^2_i\right). -\tag{17} + \hat{y}_2 = f_2(\mathrm{W}_2 \hat{y}_{1} + \hat{b}_{2}) = + f_2\left(\left[\begin{array}{ccc} + w^2_{11} &w^2_{12} &w^2_{13} \\ + w^2_{21} &w^2_{22} &w^2_{23} \\ + w^2_{31} &w^2_{32} &w^2_{33} \\ + \end{array} \right] \cdot + \left[\begin{array}{c} + y^1_1 \\ + y^1_2 \\ + y^1_3 \\ + \end{array}\right] + + \left[\begin{array}{c} + b^2_1 \\ + b^2_2 \\ + b^2_3 \\ + \end{array}\right]\right). +\tag{16} \end{equation} $$ -

    This is not just a convenient and compact notation, but also a useful -and intuitive way to think about MLPs: The output is calculated by a -series of matrix-vector multiplications and vector additions that are -used as input to the activation functions. For each operation -\( \mathrm{W}_l \hat{y}_{l-1} \) we move forward one layer. -

    @@ -360,7 +379,7 @@ used as input to the activation functions. For each operation

  • 63
  • 64
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs055.html b/doc/pub/week40/html/._week40-bs055.html index 168bc05fe..b019307f0 100644 --- a/doc/pub/week40/html/._week40-bs055.html +++ b/doc/pub/week40/html/._week40-bs055.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,20 +318,25 @@ MathJax.Hub.Config({

     

     

     

    -

    Activation functions

    +

    Matrix-vector notation and activation

    -

    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 +

    The activation of node \( i \) in layer 2 is

    + +$$ +\begin{equation} + y^2_i = f_2\Bigr(w^2_{i1}y^1_1 + w^2_{i2}y^1_2 + w^2_{i3}y^1_3 + b^2_i\Bigr) = + f_2\left(\sum_{j=1}^3 w^2_{ij} y_j^1 + b^2_i\right). +\tag{17} +\end{equation} +$$ + +

    This is not just a convenient and compact notation, but also a useful +and intuitive way to think about MLPs: The output is calculated by a +series of matrix-vector multiplications and vector additions that are +used as input to the activation functions. For each operation +\( \mathrm{W}_l \hat{y}_{l-1} \) we move forward one layer.

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

      @@ -355,7 +362,7 @@ for a FFNN to fulfill the universal approximation theorem
    • 64
    • 65
    • ...
    • -
    • 69
    • +
    • 70
    • »
    diff --git a/doc/pub/week40/html/._week40-bs056.html b/doc/pub/week40/html/._week40-bs056.html index 7331e07d2..ef656d85a 100644 --- a/doc/pub/week40/html/._week40-bs056.html +++ b/doc/pub/week40/html/._week40-bs056.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,29 +318,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Activation functions, Logistic and Hyperbolic ones

    +

    Activation functions

    -

    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. +

    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

    -

    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) -$$ - - +
      +
    • Non-constant
    • +
    • Bounded
    • +
    • Monotonically-increasing
    • +
    • Continuous
    • +

    diff --git a/doc/pub/week40/html/._week40-bs057.html b/doc/pub/week40/html/._week40-bs057.html index e3dedf15b..fc9e64d0f 100644 --- a/doc/pub/week40/html/._week40-bs057.html +++ b/doc/pub/week40/html/._week40-bs057.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,107 +318,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Relevance

    +

    Activation functions, Logistic and Hyperbolic ones

    -

    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 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.

    +

    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 +

    - -
    -
    -
    -
    -
    -
    """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."""
    +$$
    + f(x) = \frac{1}{1 + e^{-x}},
    +$$
     
    -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()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    and the hyperbolic tangent function

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

    @@ -444,7 +366,7 @@ plt.show()

  • 66
  • 67
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs058.html b/doc/pub/week40/html/._week40-bs058.html index 23a44609b..5f8f06964 100644 --- a/doc/pub/week40/html/._week40-bs058.html +++ b/doc/pub/week40/html/._week40-bs058.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,38 +318,108 @@ MathJax.Hub.Config({

     

     

     

    -

    The multilayer perceptron (MLP)

    +

    Relevance

    -

    The multilayer perceptron is a very popular, and easy to implement approach, to deep learning. It consists of

    -
      -
    1. A neural network with one or more layers of nodes between the input and the output nodes.
    2. -
    3. The multilayer network structure, or architecture, or topology, consists of an input layer, one or more hidden layers, and one output layer.
    4. -
    5. The input nodes pass values to the first hidden layer, its nodes pass the information on to the second and so on till we reach the output layer.
    6. -
    -

    As a convention it is normal to call a network with one layer of input units, one layer of hidden -units and one layer of output units as a two-layer network. A network with two layers of hidden units is called a three-layer network etc etc. +

    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

    -

    For an MLP network there is no direct connection between the output nodes/neurons/units and the input nodes/neurons/units. -Hereafter we will call the various entities of a layer for nodes. -There are also no connections within a single layer. -

    -

    The number of input nodes does not need to equal the number of output -nodes. This applies also to the hidden layers. Each layer may have its -own number of nodes and activation functions. -

    + +
    +
    +
    +
    +
    +
    """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()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    The hidden layers have their name from the fact that they are not -linked to observables and as we will see below when we define the -so-called activation \( \hat{z} \), we can think of this as a basis -expansion of the original inputs \( \hat{x} \). The difference however -between neural networks and say linear regression is that now these -basis functions (which will correspond to the weights in the network) -are learned from data. This results in an important difference between -neural networks and deep learning approaches on one side and methods -like logistic regression or linear regression and their modifications on the other side. -

    @@ -374,7 +446,7 @@ like logistic regression or linear regression and their modifications on the oth

  • 67
  • 68
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs059.html b/doc/pub/week40/html/._week40-bs059.html index 2c45574bf..5c0291e00 100644 --- a/doc/pub/week40/html/._week40-bs059.html +++ b/doc/pub/week40/html/._week40-bs059.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,29 +318,37 @@ MathJax.Hub.Config({

     

     

     

    -

    From one to many layers, the universal approximation theorem

    +

    The multilayer perceptron (MLP)

    -

    A neural network with only one layer, what we called the simple -perceptron, is best suited if we have a standard binary model with -clear (linear) boundaries between the outcomes. As such it could -equally well be replaced by standard linear regression or logistic -regression. Networks with one or more hidden layers approximate -systems with more complex boundaries. +

    The multilayer perceptron is a very popular, and easy to implement approach, to deep learning. It consists of

    +
      +
    1. A neural network with one or more layers of nodes between the input and the output nodes.
    2. +
    3. The multilayer network structure, or architecture, or topology, consists of an input layer, one or more hidden layers, and one output layer.
    4. +
    5. The input nodes pass values to the first hidden layer, its nodes pass the information on to the second and so on till we reach the output layer.
    6. +
    +

    As a convention it is normal to call a network with one layer of input units, one layer of hidden +units and one layer of output units as a two-layer network. A network with two layers of hidden units is called a three-layer network etc etc.

    -

    As stated earlier, -an important theorem in studies of neural networks, restated without -proof here, is the universal approximation -theorem. +

    For an MLP network there is no direct connection between the output nodes/neurons/units and the input nodes/neurons/units. +Hereafter we will call the various entities of a layer for nodes. +There are also no connections within a single layer.

    -

    It states that a feed-forward network with a single hidden layer -containing a finite number of neurons can approximate continuous -functions on compact subsets of real functions. The theorem thus -states that simple neural networks can represent a wide variety of -interesting functions when given appropriate parameters. It is the -multilayer feedforward architecture itself which gives neural networks -the potential of being universal approximators. +

    The number of input nodes does not need to equal the number of output +nodes. This applies also to the hidden layers. Each layer may have its +own number of nodes and activation functions. +

    + +

    The hidden layers have their name from the fact that they are not +linked to observables and as we will see below when we define the +so-called activation \( \hat{z} \), we can think of this as a basis +expansion of the original inputs \( \hat{x} \). The difference however +between neural networks and say linear regression is that now these +basis functions (which will correspond to the weights in the network) +are learned from data. This results in an important difference between +neural networks and deep learning approaches on one side and methods +like logistic regression or linear regression and their modifications on the other side.

    @@ -365,6 +375,8 @@ the potential of being universal approximators.

  • 67
  • 68
  • 69
  • +
  • ...
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs060.html b/doc/pub/week40/html/._week40-bs060.html index 8d42a0e6a..c9eabafbe 100644 --- a/doc/pub/week40/html/._week40-bs060.html +++ b/doc/pub/week40/html/._week40-bs060.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,32 +318,29 @@ MathJax.Hub.Config({

     

     

     

    -

    Deriving the back propagation code for a multilayer perceptron model

    +

    From one to many layers, the universal approximation theorem

    -

    As we have seen now in a feed forward network, we can express the final output of our network in terms of basic matrix-vector multiplications. -The unknowwn quantities are our weights \( w_{ij} \) and we need to find an algorithm for changing them so that our errors are as small as possible. -This leads us to the famous back propagation algorithm. +

    A neural network with only one layer, what we called the simple +perceptron, is best suited if we have a standard binary model with +clear (linear) boundaries between the outcomes. As such it could +equally well be replaced by standard linear regression or logistic +regression. Networks with one or more hidden layers approximate +systems with more complex boundaries.

    -

    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? +

    As stated earlier, +an important theorem in studies of neural networks, restated without +proof here, is the universal approximation +theorem.

    -

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

    - -$$ -{\cal C}(\hat{W}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - t_i\right)^2, -$$ - -

    where the $t_i$s are our \( n \) targets (the values we want to -reproduce), while the outputs of the network after having propagated -all inputs \( \hat{x} \) are given by \( y_i \). Below we will demonstrate -how the basic equations arising from the back propagation algorithm -can be modified in order to study classification problems with \( K \) -classes. +

    It states that a feed-forward network with a single hidden layer +containing a finite number of neurons can approximate continuous +functions on compact subsets of real functions. The theorem thus +states that simple neural networks can represent a wide variety of +interesting functions when given appropriate parameters. It is the +multilayer feedforward architecture itself which gives neural networks +the potential of being universal approximators.

    @@ -367,6 +366,7 @@ classes.

  • 67
  • 68
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs061.html b/doc/pub/week40/html/._week40-bs061.html index ae00022a1..c6245d612 100644 --- a/doc/pub/week40/html/._week40-bs061.html +++ b/doc/pub/week40/html/._week40-bs061.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,42 +318,34 @@ MathJax.Hub.Config({

     

     

     

    -

    Definitions

    +

    Deriving the back propagation code for a multilayer perceptron model

    -

    With our definition of the targets \( \hat{t} \), the outputs of the -network \( \hat{y} \) and the inputs \( \hat{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 +

    As we have seen now in a feed forward network, we can express the final output of our network in terms of basic matrix-vector multiplications. +The unknowwn quantities are our weights \( w_{ij} \) and we need to find an algorithm for changing them so that our errors are as small as possible. +This leads us to the famous back propagation algorithm. +

    + +

    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? +

    + +

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

    $$ -z_j^l = \sum_{i=1}^{M_{l-1}}w_{ij}^la_i^{l-1}+b_j^l, +{\cal C}(\hat{W}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - t_i\right)^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 here illustrates this equation. We can rewrite this in a more -compact form as the matrix-vector products we discussed earlier, +

    where the $t_i$s are our \( n \) targets (the values we want to +reproduce), while the outputs of the network after having propagated +all inputs \( \hat{x} \) are given by \( y_i \). Below we will demonstrate +how the basic equations arising from the back propagation algorithm +can be modified in order to study classification problems with \( K \) +classes.

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

    With the activation values \( \hat{z}^l \) we can in turn define the -output of layer \( l \) as \( \hat{a}^l = f(\hat{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 -

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

    diff --git a/doc/pub/week40/html/._week40-bs062.html b/doc/pub/week40/html/._week40-bs062.html index bbefd0b39..0ca7615b2 100644 --- a/doc/pub/week40/html/._week40-bs062.html +++ b/doc/pub/week40/html/._week40-bs062.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,21 +318,39 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivatives and the chain rule

    +

    Definitions

    + +

    With our definition of the targets \( \hat{t} \), the outputs of the +network \( \hat{y} \) and the inputs \( \hat{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 +

    -

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

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

    and

    +

    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 here illustrates this equation. We can rewrite this in a more +compact form as the matrix-vector products we discussed earlier, +

    + $$ -\frac{\partial z_j^l}{\partial a_i^{l-1}} = w_{ji}^l. +\hat{z}^l = \left(\hat{W}^l\right)^T\hat{a}^{l-1}+\hat{b}^l. $$ -

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

    +

    With the activation values \( \hat{z}^l \) we can in turn define the +output of layer \( l \) as \( \hat{a}^l = f(\hat{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 +

    + $$ -\frac{\partial a_j^l}{\partial z_j^{l}} = a_j^l(1-a_j^l)=f(z_j^l)(1-f(z_j^l)). +a_j^l = f(z_j^l) = \frac{1}{1+\exp{-(z_j^l)}}. $$ @@ -355,6 +375,7 @@ $$
  • 67
  • 68
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs063.html b/doc/pub/week40/html/._week40-bs063.html index 085c1483a..d1b669433 100644 --- a/doc/pub/week40/html/._week40-bs063.html +++ b/doc/pub/week40/html/._week40-bs063.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,24 +318,21 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivative of the cost function

    +

    Derivatives and the chain rule

    -

    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

    +

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

    $$ -{\cal C}(\hat{W^L}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - t_i\right)^2=\frac{1}{2}\sum_{i=1}^n\left(a_i^L - t_i\right)^2, +\frac{\partial z_j^l}{\partial w_{ij}^l} = a_i^{l-1}, $$ -

    The derivative of this function with respect to the weights is

    - +

    and

    $$ -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \left(a_j^L - t_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{L}}, +\frac{\partial z_j^l}{\partial a_i^{l-1}} = w_{ji}^l. $$ -

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

    +

    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 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 z_j^{l}} = a_j^l(1-a_j^l)=f(z_j^l)(1-f(z_j^l)). $$ @@ -357,6 +356,7 @@ $$
  • 67
  • 68
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs064.html b/doc/pub/week40/html/._week40-bs064.html index 46316cd9c..5a5c514cb 100644 --- a/doc/pub/week40/html/._week40-bs064.html +++ b/doc/pub/week40/html/._week40-bs064.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,48 +318,24 @@ MathJax.Hub.Config({

     

     

     

    -

    Bringing it together, first back propagation equation

    +

    Derivative of the cost function

    -

    We have thus

    +

    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

    $$ -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \left(a_j^L - t_j\right)a_j^L(1-a_j^L)a_k^{L-1}, +{\cal C}(\hat{W^L}) = \frac{1}{2}\sum_{i=1}^n\left(y_i - t_i\right)^2=\frac{1}{2}\sum_{i=1}^n\left(a_i^L - t_i\right)^2, $$ -

    Defining

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

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

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

    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 \). -

    - -

    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 -\( f'(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 -

    +

    The derivative of this function with respect to the weights is

    $$ -\frac{\partial {\cal C}}{\partial (a_j^L)} +\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \left(a_j^L - t_j\right)\frac{\partial a_j^L}{\partial w_{jk}^{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

    +

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

    $$ -\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +\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}, $$ @@ -380,6 +358,7 @@ $$
  • 67
  • 68
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/._week40-bs065.html b/doc/pub/week40/html/._week40-bs065.html index ab86d88a5..a8799639e 100644 --- a/doc/pub/week40/html/._week40-bs065.html +++ b/doc/pub/week40/html/._week40-bs065.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -316,20 +318,51 @@ MathJax.Hub.Config({

     

     

     

    -

    Derivatives in terms of \( z_j^L \)

    - -

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

    +

    Bringing it together, first back propagation equation

    +

    We have thus

    $$ -\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}, +\frac{\partial{\cal C}(\hat{W^L})}{\partial w_{jk}^L} = \left(a_j^L - t_j\right)a_j^L(1-a_j^L)a_k^{L-1}, $$ -

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

    +

    Defining

    $$ -\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}, +\delta_j^L = a_j^L(1-a_j^L)\left(a_j^L - t_j\right) = f'(z_j^L)\frac{\partial {\cal C}}{\partial (a_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.

    +

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

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

    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 \). +

    + +

    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 +\( f'(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}(\hat{W^L})}{\partial w_{jk}^L} = \delta_j^La_k^{L-1}. +$$ + +

    diff --git a/doc/pub/week40/html/week40-bs.html b/doc/pub/week40/html/week40-bs.html index 76cb74266..dd9e9bdc5 100644 --- a/doc/pub/week40/html/week40-bs.html +++ b/doc/pub/week40/html/week40-bs.html @@ -63,6 +63,7 @@ doconce format html week40.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -249,62 +250,63 @@ MathJax.Hub.Config({
  • When do we stop?
  • Slightly different approach
  • Program for stochastic gradient
  • -
  • Momentum based GD
  • -
  • More on momentum based approaches
  • -
  • Momentum parameter
  • -
  • Second moment of the gradient
  • -
  • RMS prop
  • -
  • ADAM optimizer
  • -
  • Practical tips
  • -
  • Automatic differentiation
  • -
  • Using autograd
  • -
  • Autograd with more complicated functions
  • -
  • More complicated functions using the elements of their arguments directly
  • -
  • Functions using mathematical functions from Numpy
  • -
  • More autograd
  • -
  • And with loops
  • -
  • Using recursion
  • -
  • Unsupported functions
  • -
  • The syntax a.dot(b) when finding the dot product
  • -
  • Recommended to avoid
  • -
  • Using Autograd with OLS
  • -
  • Including Stochastic Gradient Descent with Autograd
  • -
  • And Logistic Regression
  • -
  • Videos on Neural Networks
  • -
  • Neural networks
  • -
  • Artificial neurons
  • -
  • Neural network types
  • -
  • Feed-forward neural networks
  • -
  • Convolutional Neural Network
  • -
  • Recurrent neural networks
  • -
  • Other types of networks
  • -
  • Multilayer perceptrons
  • -
  • Why multilayer perceptrons?
  • -
  • Illustration of a single perceptropn model and a multi-perceptron model
  • -
  • Examples of XOR, OR and AND gates
  • -
  • Does Logistic Regression do a better Job?
  • -
  • Adding Neural Networks
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  • Mathematical model
  • -
  •    Matrix-vector notation
  • -
  •    Matrix-vector notation and activation
  • -
  •    Activation functions
  • -
  •    Activation functions, Logistic and Hyperbolic ones
  • -
  •    Relevance
  • -
  • The multilayer perceptron (MLP)
  • -
  • From one to many layers, the universal approximation theorem
  • -
  • Deriving the back propagation code for a multilayer perceptron model
  • -
  • Definitions
  • -
  • Derivatives and the chain rule
  • -
  • Derivative of the cost function
  • -
  • Bringing it together, first back propagation equation
  • -
  • Derivatives in terms of \( z_j^L \)
  • -
  • Bringing it together
  • -
  • Final back propagating equation
  • -
  • Setting up the Back propagation algorithm
  • +
  • Replace or not
  • +
  • Momentum based GD
  • +
  • More on momentum based approaches
  • +
  • Momentum parameter
  • +
  • Second moment of the gradient
  • +
  • RMS prop
  • +
  • ADAM optimizer
  • +
  • Practical tips
  • +
  • Automatic differentiation
  • +
  • Using autograd
  • +
  • Autograd with more complicated functions
  • +
  • More complicated functions using the elements of their arguments directly
  • +
  • Functions using mathematical functions from Numpy
  • +
  • More autograd
  • +
  • And with loops
  • +
  • Using recursion
  • +
  • Unsupported functions
  • +
  • The syntax a.dot(b) when finding the dot product
  • +
  • Recommended to avoid
  • +
  • Using Autograd with OLS
  • +
  • Including Stochastic Gradient Descent with Autograd
  • +
  • And Logistic Regression
  • +
  • Videos on Neural Networks
  • +
  • Neural networks
  • +
  • Artificial neurons
  • +
  • Neural network types
  • +
  • Feed-forward neural networks
  • +
  • Convolutional Neural Network
  • +
  • Recurrent neural networks
  • +
  • Other types of networks
  • +
  • Multilayer perceptrons
  • +
  • Why multilayer perceptrons?
  • +
  • Illustration of a single perceptropn model and a multi-perceptron model
  • +
  • Examples of XOR, OR and AND gates
  • +
  • Does Logistic Regression do a better Job?
  • +
  • Adding Neural Networks
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  • Mathematical model
  • +
  •    Matrix-vector notation
  • +
  •    Matrix-vector notation and activation
  • +
  •    Activation functions
  • +
  •    Activation functions, Logistic and Hyperbolic ones
  • +
  •    Relevance
  • +
  • The multilayer perceptron (MLP)
  • +
  • From one to many layers, the universal approximation theorem
  • +
  • Deriving the back propagation code for a multilayer perceptron model
  • +
  • Definitions
  • +
  • Derivatives and the chain rule
  • +
  • Derivative of the cost function
  • +
  • Bringing it together, first back propagation equation
  • +
  • Derivatives in terms of \( z_j^L \)
  • +
  • Bringing it together
  • +
  • Final back propagating equation
  • +
  • Setting up the Back propagation algorithm
  • @@ -334,7 +336,7 @@ MathJax.Hub.Config({
    -

    Nov 5, 2021

    +

    Nov 16, 2021


    @@ -359,7 +361,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 69
  • +
  • 70
  • »
  • diff --git a/doc/pub/week40/html/week40-reveal.html b/doc/pub/week40/html/week40-reveal.html index defd8db62..accd66861 100644 --- a/doc/pub/week40/html/week40-reveal.html +++ b/doc/pub/week40/html/week40-reveal.html @@ -184,7 +184,7 @@ MathJax.Hub.Config({
    -

    Nov 5, 2021

    +

    Nov 16, 2021


    @@ -583,6 +583,16 @@ plt.show()
    +
    +

    Replace or not

    + +

    In the above code, we have use replacement in setting up the +mini-batches. The discussion +here may be +useful. More material will be added later. +

    +
    +

    Momentum based GD

    diff --git a/doc/pub/week40/html/week40-solarized.html b/doc/pub/week40/html/week40-solarized.html index ac962d117..1cc299c09 100644 --- a/doc/pub/week40/html/week40-solarized.html +++ b/doc/pub/week40/html/week40-solarized.html @@ -90,6 +90,7 @@ div.toc p,a { 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -267,7 +268,7 @@ MathJax.Hub.Config({
    -

    Nov 5, 2021

    +

    Nov 16, 2021


    @@ -636,6 +637,15 @@ plt.show()
    +









    +

    Replace or not

    + +

    In the above code, we have use replacement in setting up the +mini-batches. The discussion +here may be +useful. More material will be added later. +

    +









    Momentum based GD

    diff --git a/doc/pub/week40/html/week40.html b/doc/pub/week40/html/week40.html index 77c973a2d..4286dc3a7 100644 --- a/doc/pub/week40/html/week40.html +++ b/doc/pub/week40/html/week40.html @@ -167,6 +167,7 @@ div.toc p,a { 2, None, 'program-for-stochastic-gradient'), + ('Replace or not', 2, None, 'replace-or-not'), ('Momentum based GD', 2, None, 'momentum-based-gd'), ('More on momentum based approaches', 2, @@ -344,7 +345,7 @@ MathJax.Hub.Config({
    -

    Nov 5, 2021

    +

    Nov 16, 2021


    @@ -713,6 +714,15 @@ plt.show()
    +









    +

    Replace or not

    + +

    In the above code, we have use replacement in setting up the +mini-batches. The discussion +here may be +useful. More material will be added later. +

    +









    Momentum based GD

    diff --git a/doc/pub/week40/ipynb/ipynb-week40-src.tar.gz b/doc/pub/week40/ipynb/ipynb-week40-src.tar.gz index d0e5c99f0983e4b8e90f33ac363e022cacd370ca..fa653481bfb5903f3d8e125582e83012ba774960 100644 GIT binary patch delta 18 ZcmbQ%!!)gjiCw;%gF(%8@\n", @@ -12,21 +14,25 @@ }, { "cell_type": "markdown", - "id": "474f8807", - "metadata": {}, + "id": "b0524ff2", + "metadata": { + "editable": true + }, "source": [ "# Week 40: From Stochastic Gradient Descent to Neural networks\n", "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo, Norway and Department of Physics and Astronomy and Facility for Rare Ion Beams, Michigan State University, USA\n", "\n", - "Date: **Nov 5, 2021**\n", + "Date: **Nov 16, 2021**\n", "\n", "Copyright 1999-2021, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license" ] }, { "cell_type": "markdown", - "id": "6c5cc3d9", - "metadata": {}, + "id": "8e316ecc", + "metadata": { + "editable": true + }, "source": [ "## Plan for week 40\n", "\n", @@ -45,8 +51,10 @@ }, { "cell_type": "markdown", - "id": "6e613d6d", - "metadata": {}, + "id": "203a63eb", + "metadata": { + "editable": true + }, "source": [ "## Overview video on Stochastic Gradient Descent\n", "\n", @@ -55,8 +63,10 @@ }, { "cell_type": "markdown", - "id": "acdc41b1", - "metadata": {}, + "id": "0d58e354", + "metadata": { + "editable": true + }, "source": [ "## Batches and mini-batches\n", "\n", @@ -75,8 +85,10 @@ }, { "cell_type": "markdown", - "id": "312926d8", - "metadata": {}, + "id": "47d9ac99", + "metadata": { + "editable": true + }, "source": [ "## Stochastic Gradient Descent (SGD)\n", "\n", @@ -105,8 +117,10 @@ }, { "cell_type": "markdown", - "id": "44cf9842", - "metadata": {}, + "id": "7a6ce0ff", + "metadata": { + "editable": true + }, "source": [ "## Stochastic Gradient Descent\n", "\n", @@ -120,8 +134,10 @@ }, { "cell_type": "markdown", - "id": "6ebea4b5", - "metadata": {}, + "id": "9fd2e9d1", + "metadata": { + "editable": true + }, "source": [ "$$\n", "C(\\mathbf{\\beta}) = \\sum_{i=1}^n c_i(\\mathbf{x}_i,\n", @@ -131,8 +147,10 @@ }, { "cell_type": "markdown", - "id": "3f6389d9", - "metadata": {}, + "id": "4251e80f", + "metadata": { + "editable": true + }, "source": [ "## Computation of gradients\n", "\n", @@ -142,8 +160,10 @@ }, { "cell_type": "markdown", - "id": "22cdd63e", - "metadata": {}, + "id": "279e3ff2", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\nabla_\\beta C(\\mathbf{\\beta}) = \\sum_i^n \\nabla_\\beta c_i(\\mathbf{x}_i,\n", @@ -153,8 +173,10 @@ }, { "cell_type": "markdown", - "id": "4a2d3f21", - "metadata": {}, + "id": "7308b12b", + "metadata": { + "editable": true + }, "source": [ "Stochasticity/randomness is introduced by only taking the\n", "gradient on a subset of the data called minibatches. If there are $n$\n", @@ -165,8 +187,10 @@ }, { "cell_type": "markdown", - "id": "8bf174ef", - "metadata": {}, + "id": "a9835ac8", + "metadata": { + "editable": true + }, "source": [ "## SGD example\n", "\n", @@ -186,8 +210,10 @@ }, { "cell_type": "markdown", - "id": "46312c82", - "metadata": {}, + "id": "eb114c3d", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\nabla_{\\beta}\n", @@ -199,8 +225,10 @@ }, { "cell_type": "markdown", - "id": "23212add", - "metadata": {}, + "id": "ea5a1182", + "metadata": { + "editable": true + }, "source": [ "## The gradient step\n", "\n", @@ -209,8 +237,10 @@ }, { "cell_type": "markdown", - "id": "b967218f", - "metadata": {}, + "id": "384c0d48", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\beta_{j+1} = \\beta_j - \\gamma_j \\sum_{i \\in B_k}^n \\nabla_\\beta c_i(\\mathbf{x}_i,\n", @@ -220,8 +250,10 @@ }, { "cell_type": "markdown", - "id": "55739075", - "metadata": {}, + "id": "98ad9de5", + "metadata": { + "editable": true + }, "source": [ "where $k$ is picked at random with equal\n", "probability from $[1,n/M]$. An iteration over the number of\n", @@ -232,8 +264,10 @@ }, { "cell_type": "markdown", - "id": "0d959af0", - "metadata": {}, + "id": "a21029a2", + "metadata": { + "editable": true + }, "source": [ "## Simple example code" ] @@ -241,8 +275,11 @@ { "cell_type": "code", "execution_count": 1, - "id": "5dbc2eb6", - "metadata": {}, + "id": "713780cb", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import numpy as np \n", @@ -263,8 +300,10 @@ }, { "cell_type": "markdown", - "id": "9f8fd45d", - "metadata": {}, + "id": "7158b86a", + "metadata": { + "editable": true + }, "source": [ "Taking the gradient only on a subset of the data has two important\n", "benefits. First, it introduces randomness which decreases the chance\n", @@ -277,8 +316,10 @@ }, { "cell_type": "markdown", - "id": "04fcf804", - "metadata": {}, + "id": "820db04e", + "metadata": { + "editable": true + }, "source": [ "## When do we stop?\n", "\n", @@ -296,8 +337,10 @@ }, { "cell_type": "markdown", - "id": "5ffbe7df", - "metadata": {}, + "id": "1396636a", + "metadata": { + "editable": true + }, "source": [ "## Slightly different approach\n", "\n", @@ -317,8 +360,11 @@ { "cell_type": "code", "execution_count": 2, - "id": "92865897", - "metadata": {}, + "id": "cb3a35dd", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import numpy as np \n", @@ -349,55 +395,33 @@ }, { "cell_type": "markdown", - "id": "e0434bc9", - "metadata": {}, + "id": "dcf49716", + "metadata": { + "editable": true + }, "source": [ "We note that we have defined several hyperparameters. These are now the number of epochs, the number of mini-batches and the parameters $t_0$ and $t_1$." ] }, { "cell_type": "markdown", - "id": "1fc573b6", - "metadata": {}, + "id": "90ee483f", + "metadata": { + "editable": true + }, "source": [ "## Program for stochastic gradient" ] }, { "cell_type": "code", - "execution_count": 5, - "id": "09c35f49", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Own inversion\n", - "[[3.9314247 ]\n", - " [3.01955584]]\n", - "Eigenvalues of Hessian Matrix:[0.3051509 4.5708117]\n", - "theta from own gd\n", - "[[-7.30218665e+41]\n", - " [-8.99337173e+41]]\n", - "theta from own sdg\n", - "[[3.91426951]\n", - " [2.96051724]]\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEWCAYAAAB1xKBvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAp2ElEQVR4nO3deZxcVZn/8c/T2UgHCNBBEiBdzeLAsChLBHFAgYgswyI6vxmwQRCcFhjZZFQgKiITZdDfaBR0fhEYwO5hQMcBFXAMSZAd7SCSsCmEJAIBEpIQQgNZ+vn9cW/TlUpV9e2uu9St/r5fr3p19V2ful19n3vOufccc3dEREQG0pR1ACIikg9KGCIiEokShoiIRKKEISIikShhiIhIJEoYIiISiRKGNCwz+7qZdWYdR5zM7FAzeyHrOGR4UsKQVJnZIjN7y8zWmNnLZnaDmW2edVwiMjAlDMnCce6+ObAPsC9wSbbhDE9mNjLrGCRflDAkM+7+MvC/BIkDADO72MyeM7M3zOxJMzuxaN7pZna/mX3HzFaa2fNmdnTR/J3M7LfhurOACcX7M7PjzewJM1tlZveY2V8XzVtkZl80s8fN7E0zu87MtjOzu8Lt3W1mW5f7HH3VRGZ2kZm9amZLzewzRfPvMbPPln6Oot/dzM4xsz+H+7rCzHYxswfNbLWZ3Wpmo0v2eamZLQ/jbi+aPiY8PkvM7BUz+3czG1sS55fN7GXgP8xsgpn9KjwmK8zsPjPTeUHK0hdDMmNmOwJHA88WTX4OOAQYD1wOdJrZpKL5BwLPECSDq4DrzMzCef8JzAvnXQGcVrSvvwJuBi4AtgXuBH5ZciL+JHAE8FfAccBdwKXh8k3AeVU+zsQw5h2AM4FrKiWYCo4E9gc+CHwJmAmcAkwG9gJOLtnXhHBfpwEzzWy3cN6VYfz7ALuGy3ytZN1tgALQAVwEvBB+xu3Cz6v+gqQsJQzJwm1m9gbwF+BV4LK+Ge7+U3d/yd173f0W4M/AAUXrLnb3H7v7BuBGYBKwnZm1Ah8Avuru77j7vcAvi9b7B+AOd5/l7uuA7wBjgQ8VLfMDd3/F3V8E7gMecfc/uPvbwP8QVJ9Vsg74hruvc/c7gTXAblWWL3WVu6929yeABcBv3H2hu79OkLhK9933OX8L3AH8fZg4O4AL3X2Fu78BfBM4qWi9XuCycN23wrgnAYUw9vtcHcxJBUoYkoWPu/sWwKHA7hRVHZnZp83ssbCKZBXB1XVx1dLLfW/cvSd8uzmwPbDS3d8sWnZx0fvti393916ChLVD0TKvFL1/q8zv1RrnX3P39UW/9wywfKnB7Lvc59yeoJTQDMwrOn6/Dqf3WRYmwD7fJijh/cbMFprZxYOIWYYZJQzJTHh1fAPB1T5mVgB+DHweaHH3rQiutq3CJootBbY2s3FF01qL3r9EUA1DuC8jqO55ceifILI3CU7kfSbWuL1yn/MlYDlBctnT3bcKX+PDGwz6bFR6cPc33P0id98ZOB74gplNrTE+aVBKGJK17wFHmNn7gXEEJ7RlAGHD8V5RNuLui4Fu4HIzG21mBxO0Q/S5FfhbM5tqZqMI6u7fAR6M64NU8RjwCTNrNrNdCdo4atX3OQ8BjgV+Gpaafgx818zeA2BmO5jZkZU2YmbHmtmuYQJ9HdhAUG0lsgklDMmUuy8DbgK+5u5PAv8XeIigSmZv4IFBbO5TBI3iKwjaRW4q2s8zBI3IPyC4Ej+O4PbetTF8jIF8F1hL8JluBLpq3N7LwEqCUkUXcJa7Px3O+zJBFdPDZrYauJvqbSnvDZdZQ3Dcf+juc2uMTxqUqX1LRESiUAlDREQiUcIQEZFIlDBERCQSJQwREYkkV52PTZgwwdva2rIOQ0QkV+bNm7fc3bcdeMnqcpUw2tra6O7uzjoMEZFcMbPFAy81MFVJiYhIJEoYIiISiRKGiIhEooQhIiKRKGGIiEgkShgiIhKJEoaIiESihCEiIpEoYYiISCRKGCIiEkniCcPMrjezV81sQZl5F5mZm9mEpOMQEZHapFHCuAE4qnSimU0GPgYsSSEGERGpUeIJw93vJRhjudR3gS8BGiNWRCQHMmnDMLMTgBfd/Y8Rlu0ws24z6162bFkK0YmISDmpJwwzawYuBb4WZXl3n+nuU9x9yrbb1tydu4iIDFEWJYxdgJ2AP5rZImBH4FEzm5hBLCIiElHqAyi5+3zgPX2/h0ljirsvTzsWERGJLo3bam8GHgJ2M7MXzOzMpPcpIiLxS7yE4e4nDzC/LekYRESkdnrSW0REIlHCEBGRSJQwREQkEiUMERGJRAlDREQiUcIQEZFIlDBERCQSJQwREYlECUNERCJRwhARkUiUMEREJBIlDBERiUQJQ0REIlHCEBGRSJQwREQkEiUMERGJRAlDREQiUcIQEZFIlDBERCQSJQwREYkk8YRhZteb2atmtqBo2rfN7Gkze9zM/sfMtko6DhERqU0aJYwbgKNKps0C9nL39wF/Ai5JIQ4REalB4gnD3e8FVpRM+427rw9/fRjYMek4RESkNvXQhnEGcFelmWbWYWbdZta9bNmyFMMSEZFimSYMM5sGrAe6Ki3j7jPdfYq7T9l2223TC05ERDYyMqsdm9npwLHAVHf3rOIQEZFoMkkYZnYU8CXgI+7ek0UMIiIyOGncVnsz8BCwm5m9YGZnAlcDWwCzzOwxM/v3pOMQESmrqwva2qCpKfjZVbGGfNhLvITh7ieXmXxd0vsVERlQVxd0dEBPWNGxeHHwO0B7e3Zx1al6uEtKRCQb06b1J4s+PT3BdNmEEoaIDF9LlgxuetLqvHpMCUNEhq/W1sFNT1Jf9djixeDeXz1WR0lDCUNEhq/p06G5eeNpzc3B9LTloHpMCUNEhq/2dpg5EwoFMAt+zpyZTYN3vVWPlZHZg3siInWhvb0+7ohqbQ2qocpNrxMqYYiI1IN6qh6rQAlDRKQe1FP1WAWqkhIRqRf1Uj1WgUoYIiKNpuR5jgmwTRybVQlDRKRRdHXB+efDa6/1T1u8mFYoxLF5JQwRkUZQ2i9WEYupNklVUiKSL3XefUZmyj34FzOVMEQkP9S7bGUpPOCnEoaI5Eca3WfktQRT5QE/h944dqGEISL5kXT3GTnoALCicg/+AbS0sATKPEI+eEoYIpIfSfcum4MOACsq9+BfZycsX85yWBHHLpQwRCQ/ku4+IwcdAFbV3g6LFkFvb/Az5nYdJQwRyY+ku8+op/Ex6pAShojkS5JX0TnoADBLiScMM7vezF41swVF07Yxs1lm9ufw59ZJxyEiMqCkSzB5vQMrlEYJ4wbgqJJpFwOz3f29wOzwdxGR7CVVgsnzHVihxBOGu9/Lpi30JwA3hu9vBD6edBwiIplK8w6sri680IY3NbF6m/g6H8yqDWM7d18avn8Z2K7SgmbWYWbdZta9bNmydKITkaHJeZVLohK+A8sdnn0W7j6ji7dP68CWLMbc2XJlA3U+6O5uZl5l/kxgJsCUKVMqLiciGVO3HdUlMATr0qUwZw7Mnh28liyB55nGZmxcksl754OvmNkkgPDnqxnFISJxyfNDb2kY6A6sCKWzVavg9tvhvPNgzz1h++3hlFPgtttgyhS45hooWHLPjGRVwvgFcBpwZfjz9oziEJG45P2ht6T1lbKmTQuOSWtrkCza2yuWztauhXsnt79bgpg3L2iLHzsWDjkETjsNpk6FffaBESPC/VxVoSQTA3NPtpbHzG4GDgUmAK8AlwG3AbcCrQR9nPy9uw/46PqUKVO8u7s7sVhFpAZtbeVPVIVCcLdRLbq6yp9oG0WFY7eYAm0sYuRIOPDAIDlMnRq8HzOmwrbKjIuxP/TOcx9RYY3o3D03r/33399FpE51dro3N7sH7a/9r5aWYF6c221urm2bdaK3133+fPdebNPjBt6L+R13uK9ePcgNd3a6FwruZu6Fgk+AhR7DOTjxEkacVMIQqXPlhgiFoK5+qA/AJVlyycCiRf2N1HPmwCuvwPO00VauQ9mYPqOZzXP3KbVuR12DiMjQlGukbW+HzTffdNlaGr/z2DZSdGw2TG7jwc930dEBu+wCO+0En/0szJ0bVC9ddx2M+15OuiSJo5iS1ktVUiJ1olo1kZWvXnGzoe2rUCi/vUIheqxF1TNJV2X1XNvp68ZsfGzW0Oxnju30E05wnzHDfcGCoDqqbJzgPmJE/2eMIV6g22M4B2eeBAbzUsIQqRPVTuK1nuBL1dKGkUL7x9tvu8+d6/6Vr7gfdJD7IgplP39vayGzeJUwRCQ71UoR5U56o0YFjd9DvcofqJRQaX7cycvd1693//3v3a+80v2II9zHjg022dTkfuCBlRuwI5WwEojXXQlDRLI00Imt+ATe0uI+evTGy8V5lT+U6jGInHR6e92fesr96qvdTzzRfaut+jex557u553nfvvt7qtWhdvoq04aykk/7uq8kBKGiGRnMFUnCV01R9p+pXml8Zb5POtGN/s1f9Pp22/vfjKd/jwF34D5snEFv/+cTl+6NMIxqXZsyiUolTCUMEQaUtTG5ISumiNtv9pJvOhEvH7HQtn5S5oK/v0Pdvra0RGSY6WT/YgR5ZNFuYR79tlqw4jrpYQhkkNZljDcg5NthYTRi/m++7pvqPTgXF8yjBL/YBJjtW0mcFdXXAlDz2GISLLKdbo3ejQsXx6MamcGEyYMvSv0gTr1a2/HWwtlV11CK1tuCavHl+8x1lpboz8HMpjxwKttM8khaGukhCEiySod9rSlBTZsgDff7F/mtdfgM58ZWtIoM6xq7/+byR/2aOc734FjjoEzXp7Om2ycVDaMaWbi9dO55x7Y6poqSadSItimZEyiwYwHHnWb9SaOYkpaL1VJiTSAag3RQ6ym6u11/9Of3H/0I/e/+7vgxqy+Te6+u/s//ZP77y7oDNoqBntrbmdncFtwaayjR0ffRqnBbDMGxFQlpb6kRIai0XtPTVJTU3B6LMcsqIqJYOnS/j6ZZs+Gv/wlmL7jjv29uh5+OOywQwwxT5iwaf9YUFtfT0lsswL1JSWSlb7uoxcvDk58fSPL5XU40rSHVa02wlyVeatWBQMFnXsu7LFHMHjQqafCL34BBxwAP/whPPNMkMNvuCGYF0uyAFhRYfSFwfZnVXysyyWLoWwzTXEUU9J6qUpK6kLSd/3EKcoT0ml3Hd7ZuemDfBBU0RTtt6fHfdYs94svdv/AB4InqfvCO/JI96uucp83z33DhuRCfVccf/OBbvFN8HuEbqsVyUjSzxXEJUoyyCr5dXZu3NDQ0uLrb+r0Bx90v+IK90MP7c8pI0e6H3yw+2WXud97r/s77yQbWsV4a02s1dpuEk7WShgiWclLCSNKnHEnvzKJoNIJsLfX/fHH3b/7Xfdjj3XfYov+1fbZx/2ii9zvvNP9jTeGFkrsan0+olo3JQn3pKuEIfmQctfSqcjLCHBRkkGcyS/CnT8LF7r/+MfuJ53k/p739C+y667un/uc+623ui9bFsunrz8ZXmgoYUj9y8uJdSjykAijnKDi/BtVqXJZtnnBd9qpf9LEie7t7e5z/7HT1+1QqO/jGJcM/x+UMKT+5aXqplGVO0GNHr1pN+NxJb8qVS4bMP/4x91//elOf2dSIehyI+lebOvR2Wf392Y7YkTwewoaImEAFwJPAAuAm4HNqi2vhJEzeWkcbgTVHjor7ma8tMqoxhP0W2+5z5njPm2a+0ujCxUTRm9rIdO7hOqCShg1JYsdgOeBseHvtwKnV1tHCSNnVMJIR9QTUQx/j/Xr3X/3O/dvfcv9ox9132wzf/di+Wu7dPo6q9KGEeUuoUa+oGiANoysH9wbCYw1s5FAM/BSxvFInAbTt44M3bRp0NOz8bSenmB6sWod3lV4eM8dnnoKrr4aTjwxeDj5gAPgkkvg5Zfhc58LHpxbsQIuf7adkT/5j6CvqD4tLXD99cFT8FEfSKv2YF+Wan3AMWonhvUsjqwz1BdwPrAGWAZ0VVimA+gGultbW2PNuuLJN97moXE476JW/VW6wm1pqTh40KRJ/ZPb2tzPPNP9gXMG6JOpkgyfQ6hZks9h5KiEkWWy2BqYA2wLjAJuA06pto6qpGLWyHcxDSdRT0QV/t4btmkpu/6SpoKfdFJwG+zChdW3Eek7k8RY32lJ6klvtWFEThj/B7iu6PdPAz+sto4SRszUxtAYBnMi6uz0DZODu5Re26LgF7d2Vh88qFSt35m8ljjjuoEjo8/fCAnjQII7pJoBA24Ezq22jhJGzHQXU+OocpdUb2uQIFaOL/jX/6rTR470d9uiDz3UfeX4QvQkMFy/Mzm/uIorYWTW6O3ujwA/Ax4F5hP0nDszq3iGpcGMECb1rWiUtt6Fi/jDHu386lNdvP3pDmzJYsydrV5fzJee7eAnR3cxaxasXAlz5w4weFCppL8zafecG5Vu4AjEkXXSeqmEETO1YTSE3l73Z55x/+EPNx486HkK0a+KBzPwT1LfmXr/Pua1Os3jK2FEqTqaBbw/jp3V+lLCSECO/wnqTpRjGdPxfvFF95tucj/tNPfJk/vPr5Mnu59+uvtPfuJBG0QS1UdJfWfSrvYZRt/9NBPGfsBc4D+ASXHsdKgvJQypW1Gujmu4gl6xwv3nPw+GGt199/7VW1qCUsWPfhQMUdrbW7RS3urd02wfqffSTMxSSxjvLgifBP4IXEb4dHbaLyWMnGvkK7ooJ+dBnMDffNP9N79x//KX3adM6R88aNw496OPdv/2t90ffXSAwYPydlJMM8HlLZnWKNWEQXAX017AWcBy4AXg1DgCGMxLCSPH8nbyGqwoV8dVllm71v2BBzYdPGjUKPdDDnH/+tfd77vPfd0Ng0y6eUrSaX5HhtndXmlWST1A0GXHLOAK4FhgV+AHwMw4goj6UsLIsUa/oquhhPHK2MK7gweZue+7r/s//7P7XXe5r1lTtI9KnfdVGaQoFXEmpbQSXKN/H0ukmTD2BKzCvKfiCCLqqy4TRp6u4LLU6Fd0Ea6OX/63Tl87euNl1tDsF27X6Wed5f7Tn7ovX15lH9W61siqtJbXkmNe4x6i1Nswyq4MO8cRRNRX3SWMYfalq0mWV3RpJfWS/ay6ptP/8z+D/pfa2oKPezKdvqSp4L2Yv9FS8OUzBhFLtSE+07w6Lv6cfWM75PFKfRhd7NVFwkj7VXcJY5gVa2uSVXJNcb+rVrnffrv7eee577VX/+622sr9xBPdr77a/cknS+5kGoyBOu9Lo7QWdUyLRik5NggljHrQ6NUsccviii7BpP7WW+6zZ7tfeqn7gQf2X2yPHet+xBHuV17p/tw3gq45Yqvfr3ayTuNCJeqYFrpoqitKGPUgyRLGMCouJyrGK+D1690fecT9m990nzp148GDDjrI/StfcZ871/3tt8MVkijddHb2P8qdRVXoQNVifa+Uhh6VaJQw6kFS1R1xbzcPySeJGDs7K5/gIiT13l73J55w//733U84wX38+P7V997b/YIL3H/5S/fXX6+wgUa8oFAJI5eUMOpFEv+4cZ5o8tAwn1SMlY6jWcVtL1rkfv317u3tvtHgQTvv7P7Zz7rffLP7K69E3H8jVlmqDSOXlDAaWZwnmqEkn7SvXpO6Eq9WfRJatsz9llvcOzrcd9mlf/Z227mffLL7tde6P/98nX2urDXKXVLDiBJGI4vzRDPY5JNFiSSpK/EKx/HNbQv+hS+4v//9/ZO33NL9uOPcv/c99/nza7iTqVgeSne1Gg6fsQEoYeRRFl1IDzb5ZHFVnNQ+Ozu9t+Q4rqHZT6bTx4xxP+ww93/5F/eHHnJfty6OD1I+hrpvP6rVcPiMOaeEkTeDTQJx/RMOdr9Z1LvHmCA3bHCfN8/9qqvcjzzS/fRRnf48Bd+A+UujC/5fx3f63Xe79/Qk8DmyoJO1RKCEkTd5edI5qziHeOLr7XV/+mn3a65x/8Qn3LfZpj/kPfZwP/dc99tuc1+5MsngM6LqIIkoroRhwbbyYcqUKd7d3Z11GEPT1BT8S5cyg97e9OOppKsLOjqgp6d/WnMzzJwZDANaB158EWbPDl5z5sALLwTTW1th6tTgdfjhMGlStnEmrq0NFi/edHqhEAzXKhIys3nuPqXW7YyMIxiJoLW1/D93vY2f3ZcUpk0L4h0xIkge06ZtPD9FK1bAPff0J4lnngmmt7QEiaEvSeyyS5B/E9XVFRyLJUuCv9306dkl0iVLBjddpEZKGGmZPr38lXs9DiLfdwIsjnfx4uD34vkJ6emB++/vTxCPPhoUzsaNg498BP7xH4ME8b73BQW31JSWvlI8JmXl5SJEGkamVVJmthVwLcHgTA6c4e4PVVo+11VSUF9XpwNJsbpj3Tr4/e/7E8RDD8HatTBqFBx0UH8J4oADgmmZqbcqoBxUH0p9iKtKKuuEcSNwn7tfa2ajgWZ3X1Vp+dwnjDxJsM2ltxfmz+9PEPfeC8et6eKbTKOVJby+ZStLzprOrl9rZ9y4mnYVr3psh8rTRYhkJq6EkWaBfiNmNh74MHAdgLuvrZYsJGWVqjWGUN3hDs89F1z4/sM/wMSJsM8+cNFF8OyzMOPALm4a3UEbi2nC2Xr1Yt5/dQfjbuuq7TPELcZjMihdXUHppqkp+NlVdFza24PSTW9v8FPJQpIUx61WQ3kB+wC/A24A/kBQNTWuzHIdQDfQ3draGscdZhJFjbdsLl3q3tXlfsYZG9+pu/327qee6n7DDe5/+Uu4cF660MjiNlbdOisxIO/PYQBTgPXAgeHvM4Arqq2T6+cwoqi3h7AGEU/x4EF77tl/btt66+D5iGuuCZ6XKNvlRp466WuUfrZkWGmEhDERWFT0+yHAHdXWySxhpHGSyNmV5Ftvud99t/sllwSDBzU1BSGPHev+sY+5/+u/und3B2NIDKjeT4pZJvI8JVOpW7lPGMFn4D5gt/D914FvV1s+k4SR1om8zk+a69a5P/yw+/Tp7ocf7j5mTBDeiBHuH/qQ+1e/6n7PPeHgQYM9wWZV1ZN2v15DUeffC8mHRkkY+4TtE48DtwFbV1s+k4SR1j9snV1J9va6L1jgPmOG+/HHB7259oX0vve5X3ih+69+5b56dcmKQz3BpnkVXy7GUaOCkexK95/1CTvrhCUNoSESxmBfmSSMtE7k1U5MKZ1MFy1yv+469099yn3ixP4QdtklGC/illsiDB6U9Qk2iiijxvWdlOshkddb25bkjhJGWtI6AVa6kjz77MSuMF99tfLgQZ/6VJA8Fi0a5Ebr4QQ7kKjjUhcK+UiAQ6EkNKwoYZST1LjQaVUJlIs/ygkr4udevTqoRrrwwqBaqW9TW24ZVDvNmBFUQ9U0eFDS41i3tPRvs6Ul3jFCyiW5RqwSasTPJFUpYZRK8p+gnu+SqfK53347aIj+6leDhumRI4PZY8YEDdfTpwcN2bEOHpTU36Gz03306E2Pw6hRg9921HGp+5Jco1yNV7sAaYRSk1SkhFGqUasOKn2uESOqngBe3qzgY8cGvzY1Bbe+Xnqp++zZwS2xiUriBBv3ia44xpaWTZNRo11xR0mS9VRtKLGKK2E0zngY9djPTxzKdTAX8uZm6OmhXI/evRgXntfL1KlBD6/jxycfaqIq/X0hnr9xo/fJVKnjxGIaR6NhaTyMUo3a1XPfSeu002DDho1mWU8P6xnBSDZsslpToZUZM9IIMCWV/r5982rV3t5YCaLUQGNk1GtX+1JXMut8MHbTpwdf+mJJ/RNU6wwuZitWwH9v1o5vKH8FPYIN9G6W0ufO0vTpMHr0ptNHjWq8z5qEakm1UFCX6BJNHPVaab0yuUuq3D4SvMNkzRr3X//a/YtfdN9vv/4278VWqFx/P5inlsstF2X9emj4jesuqeFId0YNa6jROyMxN66vXet+//3ul1/u/uEPBzf9QNAG+5GPuH/jG+4PPOC+7sYa/+Frec5DJ5vGUA9JXzIRV8JonEbvtNTYuN7bC48/DnPm9A8etGZNsPp++/WPLnfwwZvWsNXUMFup0XPEiE3aRoCNG0DrbaQ5ERmUhhhxb7DqImEM8uTpHgwe1De63Ny5sHx5MG+33eDLk7v4+8em0fzaEizJu3Oq3WVUTnECbNQ70ESGidyPuJeqOBupIzSuL10K95/TxfLN2/CmJka+t43fntXFgw/CMcfAjTfCCy/A01/t4jMPdjBu+WLMPUhEHR1wzjnxN6pXavRsqvAV2GabgdfN+x1oIjI4cdRrpfUaUhtGEvXvJXXBa2Z2+m23uZ97rvsee7ifTKevYeN9btis2XtL91mpPaT06e64npQudxzGjSsfQ0vLwOuqDlwkF1Cjd0QJPAHe09M/eNABB/QPHtTc7H7kke6rtoq4z6id4MX1xHq5Rs+onQWqwVQkt+JKGI3fhhFD/fv69dDd3d8O8eCD8M47MHIkHHhgf0P1Bz8YPioQdZ9Rnr4dQryDogZtkYanNoyohlD/7g4LFsCMGXD88dDSAgcdBF/5CqxcCZ//PNx5Z/D+/vvh8svhwx8ueq4s6j7LtYdYuY4+wqCSeEgwzQceRSTXGqdrkHK6uoJ7VkuVOSEuWtRfgpgzB155JZi+665w8slBCeKww2DChAj7nT590/6fyp2E++6GKr5Vtq9VvEzfUe82ihevW6tyMTRaP0oiEovGrZKq1GlfSwvMmMGyj7W/+yzE7NmwcGEwe+LE/iqmqVOHeCNQVxecfz689tpG+4x8Eu573qJSdZWqi0RkENT54ECmTSt7lb5i7eYcdlU7j58S/D5+PBx6KFxwQZAg/vqvK9cKbaLcg3SwaaJ6663Bxd7XEV6ltpCBOpITEUlAw5YwvKkpeLahRC/GkR/t5fDDgwSx335B4/WglSvBNDfD2LH9JYtiQykVqEFaRGLQMCUMMxsBdAMvuvuxQ93Ohg3whz/0VzFdSyutlDnZTm5l1qyhx/uuciWYnp7ybQ8wtFJB1LYQEZEU1MNdUucDTw12JXd4+mm45hr4xCeCxugPfAAuvjh40vqej01n/ZhN7/5p+lZMJ9vBJoChNIa0twfdThcKQT2ZuqEWkQxlWsIwsx2BvwWmA18YaPm1a+GGG/rvZHrppWB6Wxt88pNBFdPhh8N22wG0QxfJ3f1TaUCflpagzSKuUkGjD+wjIrmRaRuGmf0M+BawBfDP5aqkzKwDCO8l3X9/6GbbbXm3DWLqVNh55zSjDlVqw5g5M3iv21RFpE7kvg3DzI4FXnX3eWZ2aKXl3H0mMBNg8uQpfscdsNdelfvMS81Azy8oQYhIg8mshGFm3wJOBdYDmwFbAj9391MqrVMX3ZuLiORM7rsGcfdL3H1Hd28DTgLmVEsWIiKSrawrdgZn/vx4x4gQEZHIMn8OA8Dd7wHuGXDBtWuDn0n0qSQiIlXlq4RRrKcnaHAWEZFU5DdhgPpUEhFJUb4TRr2MKR3nmOEiInWqLtowhqRe+lQqfYBP7Ssi0qDy1VvtmDHevW5dfT09rR5lRaTO5f5J7yHZe+9gcO16UqkdRe0rItJg8t2GUQ+GMGa4iEgeKWHUavr0oD2lWL20r4iIxEgJo1Yas0JEhol8tWHUK41ZISLDQOOUMPQshIhIohqjhKFnIUREEtcYJYxp0zYe+Q7U15SISMwaI2HoWQgRkcQ1RsLQsxAiIolrjIShZyFERBLXGAlDz0KIiCSuMe6SAj0LISKSsMYoYfTRsxgiIolpnBKGnsUQEUlUZiUMM5tsZnPN7Ekze8LMzh9wpfnzK5ce9CyGiEiiMhtAycwmAZPc/VEz2wKYB3zc3Z+stM4UM393NIzm5o0btpuaoNxnMYPe3pijFxHJj7gGUMqshOHuS9390fD9G8BTwA6RN1BaetCzGCIiiaqLRm8zawP2BR4pM6/DzLrNbNOh9oqf5NazGCIiico8YZjZ5sB/Axe4++rS+e4+092nlC1OFZce9CyGiEiiMmvDADCzUcCvgP91938baPmqbRgiIlJW7tswzMyA64CnoiQLAEaPVulBRCQjWT6H8TfAqcB8M3ssnHapu99ZcY2994buTZsyREQkeZklDHe/H7Cs9i8iIoOTeaO3iIjkgxKGiIhEooQhIiKRKGGIiEgkShgiIhKJEoaIiESihCEiIpEoYYiISCRKGCIiEokShoiIRKKEISIikShhiIhIJEoYIiISiRKGiIhEooQhIiKRKGGIiEgkShgiIhKJEoaIiESihCEiIpEoYYiISCSZJgwzO8rMnjGzZ83s4ixjERGR6jJLGGY2ArgGOBrYAzjZzPbIKh4REakuyxLGAcCz7r7Q3dcC/wWckGE8IiJSxcgM970D8Jei318ADixdyMw6gI7w13fMbEEKsdVqArA86yAiUJzxyUOMoDjjlpc4d4tjI1kmjEjcfSYwE8DMut19SsYhDUhxxisPceYhRlCccctTnHFsJ8sqqReByUW/7xhOExGROpRlwvg98F4z28nMRgMnAb/IMB4REakisyopd19vZp8H/hcYAVzv7k8MsNrM5COLheKMVx7izEOMoDjjNqziNHePYzsiItLg9KS3iIhEooQhIiKR1E3CGKibEDMbY2a3hPMfMbO2onmXhNOfMbMjM4zxC2b2pJk9bmazzaxQNG+DmT0WvhJt3I8Q5+lmtqwons8WzTvNzP4cvk7LOM7vFsX4JzNbVTQvleNpZteb2auVnv+xwPfDz/C4me1XNC/NYzlQnO1hfPPN7EEze3/RvEXh9Mfiuv2yhjgPNbPXi/62Xyual1pXQhHi/GJRjAvC7+M24bxUjqeZTTazueE55wkzO7/MMvF+P9098xdBo/dzwM7AaOCPwB4ly5wD/Hv4/iTglvD9HuHyY4Cdwu2MyCjGw4Dm8P3ZfTGGv6+po2N5OnB1mXW3ARaGP7cO32+dVZwly59LcGNE2sfzw8B+wIIK848B7gIM+CDwSNrHMmKcH+rbP0F3PI8UzVsETKiT43ko8Ktavy9Jx1my7HHAnLSPJzAJ2C98vwXwpzL/67F+P+ulhBGlm5ATgBvD9z8DppqZhdP/y93fcffngWfD7aUeo7vPdfee8NeHCZ4tSVstXa4cCcxy9xXuvhKYBRxVJ3GeDNycUCwVufu9wIoqi5wA3OSBh4GtzGwS6R7LAeN09wfDOCC772aU41lJql0JDTLOrL6bS9390fD9G8BTBD1oFIv1+1kvCaNcNyGlH/zdZdx9PfA60BJx3bRiLHYmQWbvs5mZdZvZw2b28QTi6xM1zk+GRdSfmVnfA5RpHctB7Sus2tsJmFM0Oa3jOZBKnyPNYzlYpd9NB35jZvMs6IonaweZ2R/N7C4z2zOcVpfH08yaCU60/100OfXjaUEV/b7AIyWzYv1+1n3XIHlkZqcAU4CPFE0uuPuLZrYzMMfM5rv7c9lEyC+Bm939HTP7HEHJ7fCMYoniJOBn7r6haFo9Hc/cMLPDCBLGwUWTDw6P5XuAWWb2dHiFnYVHCf62a8zsGOA24L0ZxRLFccAD7l5cGkn1eJrZ5gQJ6wJ3X53UfqB+ShhRugl5dxkzGwmMB16LuG5aMWJmHwWmAce7+zt90939xfDnQuAegquBJAwYp7u/VhTbtcD+UddNM84iJ1FS5E/xeA6k0ueou65vzOx9BH/vE9z9tb7pRcfyVeB/SKZKNxJ3X+3ua8L3dwKjzGwCdXg8Q9W+m4kfTzMbRZAsutz952UWiff7mXTDTMTGm5EEjS470d+gtWfJMv/Exo3et4bv92TjRu+FJNPoHSXGfQka5t5bMn1rYEz4fgLwZxJqsIsY56Si9ycCD3t/Q9jzYbxbh++3ySrOcLndCRoRLYvjGe6jjcqNtH/Lxo2Kv0v7WEaMs5Wgfe9DJdPHAVsUvX8QOCrDOCf2/a0JTrRLwmMb6fuSVpzh/PEE7Rzjsjie4XG5CfhelWVi/X4mdrCH8OGPIWjlfw6YFk77BsGVOsBmwE/DL/3vgJ2L1p0WrvcMcHSGMd4NvAI8Fr5+EU7/EDA//JLPB87M+Fh+C3gijGcusHvRumeEx/hZ4DNZxhn+/nXgypL1UjueBFePS4F1BPW8ZwJnAWeF841gILDnwlimZHQsB4rzWmBl0XezO5y+c3gc/xh+J6ZlHOfni76bD1OU4Mp9X7KKM1zmdIIbborXS+14ElQrOvB40d/1mCS/n+oaREREIqmXNgwREalzShgiIhKJEoaIiESihCEiIpEoYYiISCRKGCIiEokShoiIRKKEIVKDcDyCI8L3/2JmP8g6JpGkqPNBkdpcBnwj7GhuX+D4jOMRSYye9BapkZn9FtgcONSDcQlEGpKqpERqYGZ7E4x8tlbJQhqdEobIEIUjl3URjGq2xswSG1FPpB4oYYgMQTjS2s+Bi9z9KeAKgvYMkYalNgwREYlEJQwREYlECUNERCJRwhARkUiUMEREJBIlDBERiUQJQ0REIlHCEBGRSP4/rxiwtdjN6vQAAAAASUVORK5CYII=\n", - "text/plain": [ - "
    " - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], + "execution_count": 3, + "id": "123b0eb1", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], "source": [ "%matplotlib inline\n", "\n", @@ -423,7 +447,7 @@ "print(f\"Eigenvalues of Hessian Matrix:{EigValues}\")\n", "\n", "theta = np.random.randn(2,1)\n", - "eta = 2.1/np.max(EigValues)\n", + "eta = 1.0/np.max(EigValues)\n", "Niterations = 1000\n", "\n", "\n", @@ -474,8 +498,25 @@ }, { "cell_type": "markdown", - "id": "64ed24bb", - "metadata": {}, + "id": "440a3f32", + "metadata": { + "editable": true + }, + "source": [ + "## Replace or not\n", + "\n", + "In the above code, we have use replacement in setting up the\n", + "mini-batches. The discussion\n", + "[here](https://sebastianraschka.com/faq/docs/sgd-methods.html) may be\n", + "useful. More material will be added later." + ] + }, + { + "cell_type": "markdown", + "id": "cb2bcb01", + "metadata": { + "editable": true + }, "source": [ "## Momentum based GD\n", "\n", @@ -487,8 +528,10 @@ }, { "cell_type": "markdown", - "id": "6dae73b6", - "metadata": {}, + "id": "c5f99aba", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\mathbf{v}_{t}=\\gamma \\mathbf{v}_{t-1}+\\eta_{t}\\nabla_\\theta E(\\boldsymbol{\\theta}_t) \\nonumber\n", @@ -497,8 +540,10 @@ }, { "cell_type": "markdown", - "id": "831c5807", - "metadata": {}, + "id": "5e46ef0e", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -513,8 +558,10 @@ }, { "cell_type": "markdown", - "id": "3922d4f8", - "metadata": {}, + "id": "f59073d9", + "metadata": { + "editable": true + }, "source": [ "where we have introduced a momentum parameter $\\gamma$, with\n", "$0\\le\\gamma\\le 1$, and for brevity we dropped the explicit notation to\n", @@ -530,8 +577,10 @@ }, { "cell_type": "markdown", - "id": "d5068c23", - "metadata": {}, + "id": "aacd0142", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\Delta \\boldsymbol{\\theta}_{t+1} = \\gamma \\Delta \\boldsymbol{\\theta}_t -\\ \\eta_{t}\\nabla_\\theta E(\\boldsymbol{\\theta}_t),\n", @@ -540,16 +589,20 @@ }, { "cell_type": "markdown", - "id": "c46fe71c", - "metadata": {}, + "id": "4d5b5e3d", + "metadata": { + "editable": true + }, "source": [ "where we have defined $\\Delta \\boldsymbol{\\theta}_{t}= \\boldsymbol{\\theta}_t-\\boldsymbol{\\theta}_{t-1}$." ] }, { "cell_type": "markdown", - "id": "6692fe1e", - "metadata": {}, + "id": "2ecbf4b0", + "metadata": { + "editable": true + }, "source": [ "## More on momentum based approaches\n", "\n", @@ -562,8 +615,10 @@ }, { "cell_type": "markdown", - "id": "ade434cc", - "metadata": {}, + "id": "76009341", + "metadata": { + "editable": true + }, "source": [ "$$\n", "m {d^2 \\mathbf{w} \\over dt^2} + \\mu {d \\mathbf{w} \\over dt }= -\\nabla_w E(\\mathbf{w}).\n", @@ -572,16 +627,20 @@ }, { "cell_type": "markdown", - "id": "fb546dff", - "metadata": {}, + "id": "f63637ff", + "metadata": { + "editable": true + }, "source": [ "We can discretize this equation in the usual way to get" ] }, { "cell_type": "markdown", - "id": "330ecc06", - "metadata": {}, + "id": "1817279a", + "metadata": { + "editable": true + }, "source": [ "$$\n", "m { \\mathbf{w}_{t+\\Delta t}-2 \\mathbf{w}_{t} +\\mathbf{w}_{t-\\Delta t} \\over (\\Delta t)^2}+\\mu {\\mathbf{w}_{t+\\Delta t}- \\mathbf{w}_{t} \\over \\Delta t} = -\\nabla_w E(\\mathbf{w}).\n", @@ -590,16 +649,20 @@ }, { "cell_type": "markdown", - "id": "e5f8c0be", - "metadata": {}, + "id": "c7e341ca", + "metadata": { + "editable": true + }, "source": [ "Rearranging this equation, we can rewrite this as" ] }, { "cell_type": "markdown", - "id": "c1e8fcb0", - "metadata": {}, + "id": "3e5feaa9", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\Delta \\mathbf{w}_{t +\\Delta t}= - { (\\Delta t)^2 \\over m +\\mu \\Delta t} \\nabla_w E(\\mathbf{w})+ {m \\over m +\\mu \\Delta t} \\Delta \\mathbf{w}_t.\n", @@ -608,8 +671,10 @@ }, { "cell_type": "markdown", - "id": "7f3bd58d", - "metadata": {}, + "id": "bfeef865", + "metadata": { + "editable": true + }, "source": [ "## Momentum parameter\n", "\n", @@ -622,8 +687,10 @@ }, { "cell_type": "markdown", - "id": "39cfb115", - "metadata": {}, + "id": "8b5ff094", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\gamma= {m \\over m +\\mu \\Delta t }, \\qquad \\eta = {(\\Delta t)^2 \\over m +\\mu \\Delta t}.\n", @@ -632,8 +699,10 @@ }, { "cell_type": "markdown", - "id": "f1401af5", - "metadata": {}, + "id": "59b8fce8", + "metadata": { + "editable": true + }, "source": [ "Thus, as the name suggests, the momentum parameter is proportional to\n", "the mass of the particle and effectively provides inertia.\n", @@ -663,8 +732,10 @@ }, { "cell_type": "markdown", - "id": "fa7fc1b4", - "metadata": {}, + "id": "11c55a60", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\mathbf{v}_{t}=\\gamma \\mathbf{v}_{t-1}+\\eta_{t}\\nabla_\\theta E(\\boldsymbol{\\theta}_t +\\gamma \\mathbf{v}_{t-1}) \\nonumber\n", @@ -673,8 +744,10 @@ }, { "cell_type": "markdown", - "id": "4bbf3232", - "metadata": {}, + "id": "ede32c65", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -689,16 +762,20 @@ }, { "cell_type": "markdown", - "id": "1cee2641", - "metadata": {}, + "id": "a6d82191", + "metadata": { + "editable": true + }, "source": [ "One of the major advantages of NAG is that it allows for the use of a larger learning rate than GDM for the same choice of $\\gamma$." ] }, { "cell_type": "markdown", - "id": "54339b58", - "metadata": {}, + "id": "a0f0adf1", + "metadata": { + "editable": true + }, "source": [ "## Second moment of the gradient\n", "\n", @@ -726,8 +803,10 @@ }, { "cell_type": "markdown", - "id": "4d210ce2", - "metadata": {}, + "id": "20a3335c", + "metadata": { + "editable": true + }, "source": [ "## RMS prop\n", "\n", @@ -739,8 +818,10 @@ }, { "cell_type": "markdown", - "id": "cadaff5b", - "metadata": {}, + "id": "1ac93093", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -755,8 +836,10 @@ }, { "cell_type": "markdown", - "id": "0e5a7835", - "metadata": {}, + "id": "203f2000", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\mathbf{s}_t =\\beta \\mathbf{s}_{t-1} +(1-\\beta)\\mathbf{g}_t^2 \\nonumber\n", @@ -765,8 +848,10 @@ }, { "cell_type": "markdown", - "id": "325cbf1a", - "metadata": {}, + "id": "16e820d1", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\boldsymbol{\\theta}_{t+1}=\\boldsymbol{\\theta}_t - \\eta_t { \\mathbf{g}_t \\over \\sqrt{\\mathbf{s}_t +\\epsilon}}, \\nonumber\n", @@ -775,8 +860,10 @@ }, { "cell_type": "markdown", - "id": "cb7f472b", - "metadata": {}, + "id": "72f9127f", + "metadata": { + "editable": true + }, "source": [ "where $\\beta$ controls the averaging time of the second moment and is\n", "typically taken to be about $\\beta=0.9$, $\\eta_t$ is a learning rate\n", @@ -791,8 +878,10 @@ }, { "cell_type": "markdown", - "id": "623c3e4f", - "metadata": {}, + "id": "08c03051", + "metadata": { + "editable": true + }, "source": [ "## ADAM optimizer\n", "\n", @@ -812,8 +901,10 @@ }, { "cell_type": "markdown", - "id": "bca8e3c2", - "metadata": {}, + "id": "69228222", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -828,8 +919,10 @@ }, { "cell_type": "markdown", - "id": "956129dd", - "metadata": {}, + "id": "d7595be9", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\mathbf{m}_t = \\beta_1 \\mathbf{m}_{t-1} + (1-\\beta_1) \\mathbf{g}_t \\nonumber\n", @@ -838,8 +931,10 @@ }, { "cell_type": "markdown", - "id": "c2ec8ca8", - "metadata": {}, + "id": "b3a01d71", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\mathbf{s}_t =\\beta_2 \\mathbf{s}_{t-1} +(1-\\beta_2)\\mathbf{g}_t^2 \\nonumber\n", @@ -848,8 +943,10 @@ }, { "cell_type": "markdown", - "id": "1e8f5983", - "metadata": {}, + "id": "5abb22d3", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\boldsymbol{\\mathbf{m}}_t={\\mathbf{m}_t \\over 1-\\beta_1^t} \\nonumber\n", @@ -858,8 +955,10 @@ }, { "cell_type": "markdown", - "id": "cffa531b", - "metadata": {}, + "id": "b06e5549", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\boldsymbol{\\mathbf{s}}_t ={\\mathbf{s}_t \\over1-\\beta_2^t} \\nonumber\n", @@ -868,8 +967,10 @@ }, { "cell_type": "markdown", - "id": "fd755a07", - "metadata": {}, + "id": "ecb180df", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\boldsymbol{\\theta}_{t+1}=\\boldsymbol{\\theta}_t - \\eta_t { \\boldsymbol{\\mathbf{m}}_t \\over \\sqrt{\\boldsymbol{\\mathbf{s}}_t} +\\epsilon}, \\nonumber\n", @@ -878,8 +979,10 @@ }, { "cell_type": "markdown", - "id": "885b4ca2", - "metadata": {}, + "id": "366b91bf", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -893,8 +996,10 @@ }, { "cell_type": "markdown", - "id": "cc8084d2", - "metadata": {}, + "id": "f849de52", + "metadata": { + "editable": true + }, "source": [ "where $\\beta_1$ and $\\beta_2$ set the memory lifetime of the first and\n", "second moment and are typically taken to be $0.9$ and $0.99$\n", @@ -910,8 +1015,10 @@ }, { "cell_type": "markdown", - "id": "42257d44", - "metadata": {}, + "id": "0697306c", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\Delta \\theta_{t+1}= -\\eta_t { \\boldsymbol{m}_t \\over \\sqrt{\\sigma_t^2 + m_t^2 }+\\epsilon}.\n", @@ -920,8 +1027,10 @@ }, { "cell_type": "markdown", - "id": "25bbb3d9", - "metadata": {}, + "id": "5f67fa08", + "metadata": { + "editable": true + }, "source": [ "## Practical tips\n", "\n", @@ -938,8 +1047,10 @@ }, { "cell_type": "markdown", - "id": "ec2c7d6f", - "metadata": {}, + "id": "54ff6dcf", + "metadata": { + "editable": true + }, "source": [ "## Automatic differentiation\n", "\n", @@ -974,8 +1085,10 @@ }, { "cell_type": "markdown", - "id": "0b8c3ecf", - "metadata": {}, + "id": "12b34a7d", + "metadata": { + "editable": true + }, "source": [ "$$\n", "f(x) = \\sin\\left(2\\pi x + x^2\\right)\n", @@ -984,16 +1097,20 @@ }, { "cell_type": "markdown", - "id": "c32d1c75", - "metadata": {}, + "id": "f07f4801", + "metadata": { + "editable": true + }, "source": [ "which has the following derivative" ] }, { "cell_type": "markdown", - "id": "77bc33e9", - "metadata": {}, + "id": "3b37979c", + "metadata": { + "editable": true + }, "source": [ "$$\n", "f'(x) = \\cos\\left(2\\pi x + x^2\\right)\\left(2\\pi + 2x\\right)\n", @@ -1002,8 +1119,10 @@ }, { "cell_type": "markdown", - "id": "771e53af", - "metadata": {}, + "id": "6ea99838", + "metadata": { + "editable": true + }, "source": [ "Using **autograd** we have" ] @@ -1011,8 +1130,11 @@ { "cell_type": "code", "execution_count": 4, - "id": "95529755", - "metadata": {}, + "id": "c650970d", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1053,8 +1175,10 @@ }, { "cell_type": "markdown", - "id": "55c4b9d9", - "metadata": {}, + "id": "c3f228da", + "metadata": { + "editable": true + }, "source": [ "## Using autograd\n", "\n", @@ -1068,8 +1192,11 @@ { "cell_type": "code", "execution_count": 5, - "id": "93380f99", - "metadata": {}, + "id": "820f0105", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1093,8 +1220,10 @@ }, { "cell_type": "markdown", - "id": "11db92cf", - "metadata": {}, + "id": "9cc4de17", + "metadata": { + "editable": true + }, "source": [ "## Autograd with more complicated functions\n", "\n", @@ -1106,8 +1235,11 @@ { "cell_type": "code", "execution_count": 6, - "id": "eba3b5b0", - "metadata": {}, + "id": "c6620c65", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1147,16 +1279,20 @@ }, { "cell_type": "markdown", - "id": "ca4cdea0", - "metadata": {}, + "id": "6ba5dd8e", + "metadata": { + "editable": true + }, "source": [ "Note that the grad function will not produce the true gradient of the function. The true gradient of a function with two or more variables will produce a vector, where each element is the function differentiated w.r.t a variable." ] }, { "cell_type": "markdown", - "id": "c2beffc7", - "metadata": {}, + "id": "0a435a4e", + "metadata": { + "editable": true + }, "source": [ "## More complicated functions using the elements of their arguments directly" ] @@ -1164,8 +1300,11 @@ { "cell_type": "code", "execution_count": 7, - "id": "6ec33241", - "metadata": {}, + "id": "64fc3e0b", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1189,8 +1328,10 @@ }, { "cell_type": "markdown", - "id": "d69be5df", - "metadata": {}, + "id": "e3c719b1", + "metadata": { + "editable": true + }, "source": [ "Note that in this case, when sending an array as input argument, the\n", "output from Autograd is another array. This is the true gradient of\n", @@ -1202,8 +1343,10 @@ }, { "cell_type": "markdown", - "id": "a2fa242b", - "metadata": {}, + "id": "ff945e63", + "metadata": { + "editable": true + }, "source": [ "## Functions using mathematical functions from Numpy" ] @@ -1211,8 +1354,11 @@ { "cell_type": "code", "execution_count": 8, - "id": "0befa3ff", - "metadata": {}, + "id": "5c07b9f2", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1236,8 +1382,10 @@ }, { "cell_type": "markdown", - "id": "a22bc18d", - "metadata": {}, + "id": "949cbe35", + "metadata": { + "editable": true + }, "source": [ "## More autograd" ] @@ -1245,8 +1393,11 @@ { "cell_type": "code", "execution_count": 9, - "id": "e0acdb7c", - "metadata": {}, + "id": "40ec2a59", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1267,8 +1418,10 @@ }, { "cell_type": "markdown", - "id": "e788436c", - "metadata": {}, + "id": "e844492e", + "metadata": { + "editable": true + }, "source": [ "## And with loops" ] @@ -1276,8 +1429,11 @@ { "cell_type": "code", "execution_count": 10, - "id": "d15a1cd7", - "metadata": {}, + "id": "fd7d256e", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1309,8 +1465,11 @@ { "cell_type": "code", "execution_count": 11, - "id": "25f2c928", - "metadata": {}, + "id": "5a5ec805", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1326,8 +1485,10 @@ }, { "cell_type": "markdown", - "id": "1e108150", - "metadata": {}, + "id": "b44523b2", + "metadata": { + "editable": true + }, "source": [ "## Using recursion" ] @@ -1335,8 +1496,11 @@ { "cell_type": "code", "execution_count": 12, - "id": "98686ee1", - "metadata": {}, + "id": "f5ff508f", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1370,16 +1534,20 @@ }, { "cell_type": "markdown", - "id": "95f2045f", - "metadata": {}, + "id": "03b206f0", + "metadata": { + "editable": true + }, "source": [ "Note that if n is equal to zero or one, Autograd will give an error message. This message appears when the output is independent on input." ] }, { "cell_type": "markdown", - "id": "3107dae1", - "metadata": {}, + "id": "8ab50f5c", + "metadata": { + "editable": true + }, "source": [ "## Unsupported functions\n", "Autograd supports many features. However, there are some functions that is not supported (yet) by Autograd.\n", @@ -1390,8 +1558,11 @@ { "cell_type": "code", "execution_count": 13, - "id": "1bbc93e8", - "metadata": {}, + "id": "9e8ea3cd", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1409,16 +1580,20 @@ }, { "cell_type": "markdown", - "id": "344beeca", - "metadata": {}, + "id": "6b192ce5", + "metadata": { + "editable": true + }, "source": [ "Here, Autograd tells us that an 'ArrayBox' does not support item assignment. The item assignment is done when the program tries to assign x[2] to the value 3. However, Autograd has implemented the computation of the derivative such that this assignment is not possible." ] }, { "cell_type": "markdown", - "id": "d2b53241", - "metadata": {}, + "id": "bf85547c", + "metadata": { + "editable": true + }, "source": [ "## The syntax a.dot(b) when finding the dot product" ] @@ -1426,8 +1601,11 @@ { "cell_type": "code", "execution_count": 14, - "id": "8839a3a8", - "metadata": {}, + "id": "f17b9b3b", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1445,8 +1623,10 @@ }, { "cell_type": "markdown", - "id": "c5096993", - "metadata": {}, + "id": "6646d167", + "metadata": { + "editable": true + }, "source": [ "Here we are told that the 'dot' function does not belong to Autograd's\n", "version of a Numpy array. To overcome this, an alternative syntax\n", @@ -1456,8 +1636,11 @@ { "cell_type": "code", "execution_count": 15, - "id": "9db83bcc", - "metadata": {}, + "id": "37ecb9fa", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1478,8 +1661,10 @@ }, { "cell_type": "markdown", - "id": "df3a3262", - "metadata": {}, + "id": "ce0bd110", + "metadata": { + "editable": true + }, "source": [ "## Recommended to avoid\n", "The documentation recommends to avoid inplace operations such as" @@ -1488,8 +1673,11 @@ { "cell_type": "code", "execution_count": 16, - "id": "3de46d8a", - "metadata": {}, + "id": "91bf14fb", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "a += b\n", @@ -1500,8 +1688,10 @@ }, { "cell_type": "markdown", - "id": "407ca258", - "metadata": {}, + "id": "a3b98001", + "metadata": { + "editable": true + }, "source": [ "## Using Autograd with OLS\n", "\n", @@ -1513,8 +1703,11 @@ { "cell_type": "code", "execution_count": 17, - "id": "a96ae442", - "metadata": {}, + "id": "fc41604b", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "# Using Autograd to calculate gradients for OLS\n", @@ -1570,8 +1763,10 @@ }, { "cell_type": "markdown", - "id": "b9e24580", - "metadata": {}, + "id": "dc3c389c", + "metadata": { + "editable": true + }, "source": [ "## Including Stochastic Gradient Descent with Autograd\n", "In this code we include the stochastic gradient descent approach discussed above. Note here that we specify which argument we are taking the derivative with respect to when using **autograd**." @@ -1580,8 +1775,11 @@ { "cell_type": "code", "execution_count": 18, - "id": "4eb94f4f", - "metadata": {}, + "id": "22482edb", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "# Using Autograd to calculate gradients using SGD\n", @@ -1661,8 +1859,10 @@ }, { "cell_type": "markdown", - "id": "f669467a", - "metadata": {}, + "id": "f0b6ec08", + "metadata": { + "editable": true + }, "source": [ "## And Logistic Regression" ] @@ -1670,8 +1870,11 @@ { "cell_type": "code", "execution_count": 19, - "id": "28babb1b", - "metadata": {}, + "id": "b7e27ca2", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "import autograd.numpy as np\n", @@ -1711,8 +1914,10 @@ }, { "cell_type": "markdown", - "id": "4958f8c1", - "metadata": {}, + "id": "922823f3", + "metadata": { + "editable": true + }, "source": [ "## Videos on Neural Networks\n", "\n", @@ -1723,8 +1928,10 @@ }, { "cell_type": "markdown", - "id": "59db6bbd", - "metadata": {}, + "id": "70f4c5e0", + "metadata": { + "editable": true + }, "source": [ "## Neural networks\n", "\n", @@ -1739,8 +1946,10 @@ }, { "cell_type": "markdown", - "id": "ea10c766", - "metadata": {}, + "id": "3ea0ea35", + "metadata": { + "editable": true + }, "source": [ "## Artificial neurons\n", "\n", @@ -1761,8 +1970,10 @@ }, { "cell_type": "markdown", - "id": "1f7dace3", - "metadata": {}, + "id": "f8b3ff14", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -1777,8 +1988,10 @@ }, { "cell_type": "markdown", - "id": "423135f6", - "metadata": {}, + "id": "3e93adae", + "metadata": { + "editable": true + }, "source": [ "Here, the output $y$ of the neuron is the value of its activation function, which have as input\n", "a weighted sum of signals $x_i, \\dots ,x_n$ received by $n$ other neurons.\n", @@ -1815,8 +2028,10 @@ }, { "cell_type": "markdown", - "id": "2d9ca81c", - "metadata": {}, + "id": "406fddc5", + "metadata": { + "editable": true + }, "source": [ "## Neural network types\n", "\n", @@ -1842,8 +2057,10 @@ }, { "cell_type": "markdown", - "id": "ca5fd1e4", - "metadata": {}, + "id": "383b1c4c", + "metadata": { + "editable": true + }, "source": [ "## Feed-forward neural networks\n", "\n", @@ -1861,8 +2078,10 @@ }, { "cell_type": "markdown", - "id": "2422d4f2", - "metadata": {}, + "id": "0a2ed19b", + "metadata": { + "editable": true + }, "source": [ "## Convolutional Neural Network\n", "\n", @@ -1888,8 +2107,10 @@ }, { "cell_type": "markdown", - "id": "6841ded4", - "metadata": {}, + "id": "e656ed6b", + "metadata": { + "editable": true + }, "source": [ "## Recurrent neural networks\n", "\n", @@ -1907,8 +2128,10 @@ }, { "cell_type": "markdown", - "id": "5e8ecbf3", - "metadata": {}, + "id": "5b956231", + "metadata": { + "editable": true + }, "source": [ "## Other types of networks\n", "\n", @@ -1926,8 +2149,10 @@ }, { "cell_type": "markdown", - "id": "94d4fd33", - "metadata": {}, + "id": "5c0948b1", + "metadata": { + "editable": true + }, "source": [ "## Multilayer perceptrons\n", "\n", @@ -1941,8 +2166,10 @@ }, { "cell_type": "markdown", - "id": "7fb176d9", - "metadata": {}, + "id": "72ef97de", + "metadata": { + "editable": true + }, "source": [ "## Why multilayer perceptrons?\n", "\n", @@ -1960,8 +2187,10 @@ }, { "cell_type": "markdown", - "id": "a6d5a606", - "metadata": {}, + "id": "46192b13", + "metadata": { + "editable": true + }, "source": [ "## Illustration of a single perceptropn model and a multi-perceptron model\n", "\n", @@ -1974,8 +2203,10 @@ }, { "cell_type": "markdown", - "id": "e2b42e71", - "metadata": {}, + "id": "2fffb0a3", + "metadata": { + "editable": true + }, "source": [ "## Examples of XOR, OR and AND gates\n", "\n", @@ -1989,8 +2220,11 @@ { "cell_type": "code", "execution_count": 20, - "id": "30bc30e7", - "metadata": {}, + "id": "eb96e6fa", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "\"\"\"\n", @@ -2027,16 +2261,20 @@ }, { "cell_type": "markdown", - "id": "d2d04274", - "metadata": {}, + "id": "a8bec2ae", + "metadata": { + "editable": true + }, "source": [ "What is happening here?" ] }, { "cell_type": "markdown", - "id": "9020b30b", - "metadata": {}, + "id": "5e1a2a58", + "metadata": { + "editable": true + }, "source": [ "## Does Logistic Regression do a better Job?" ] @@ -2044,8 +2282,11 @@ { "cell_type": "code", "execution_count": 21, - "id": "5e66d354", - "metadata": {}, + "id": "19e05395", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "\"\"\"\n", @@ -2101,16 +2342,20 @@ }, { "cell_type": "markdown", - "id": "663371a3", - "metadata": {}, + "id": "d225a5f9", + "metadata": { + "editable": true + }, "source": [ "Not exactly impressive, but somewhat better." ] }, { "cell_type": "markdown", - "id": "2e4b8494", - "metadata": {}, + "id": "3015a5b2", + "metadata": { + "editable": true + }, "source": [ "## Adding Neural Networks" ] @@ -2118,8 +2363,11 @@ { "cell_type": "code", "execution_count": 22, - "id": "1814b2ea", - "metadata": {}, + "id": "d2a64b90", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "\n", @@ -2135,8 +2383,10 @@ }, { "cell_type": "markdown", - "id": "d986a868", - "metadata": {}, + "id": "4028ff5f", + "metadata": { + "editable": true + }, "source": [ "## Mathematical model\n", "\n", @@ -2145,8 +2395,10 @@ }, { "cell_type": "markdown", - "id": "709c9dea", - "metadata": {}, + "id": "f4810df1", + "metadata": { + "editable": true + }, "source": [ "$$\n", "y = f\\left(\\sum_{i=1}^n w_ix_i + b_i\\right) = f(z),\n", @@ -2155,8 +2407,10 @@ }, { "cell_type": "markdown", - "id": "4254b0ab", - "metadata": {}, + "id": "75a06440", + "metadata": { + "editable": true + }, "source": [ "This function receives $x_i$ as inputs.\n", "Here the activation $z=(\\sum_{i=1}^n w_ix_i+b_i)$. \n", @@ -2168,8 +2422,10 @@ }, { "cell_type": "markdown", - "id": "8857a349", - "metadata": {}, + "id": "9d85c59c", + "metadata": { + "editable": true + }, "source": [ "## Mathematical model\n", "\n", @@ -2178,8 +2434,10 @@ }, { "cell_type": "markdown", - "id": "4c150122", - "metadata": {}, + "id": "f8ef3098", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2193,8 +2451,10 @@ }, { "cell_type": "markdown", - "id": "5cd9f1e4", - "metadata": {}, + "id": "2eb2593d", + "metadata": { + "editable": true + }, "source": [ "Here $b_i$ is the so-called bias which is normally needed in\n", "case of zero activation weights or inputs. How to fix the biases and\n", @@ -2206,8 +2466,10 @@ }, { "cell_type": "markdown", - "id": "085ba7ef", - "metadata": {}, + "id": "5d169956", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2222,8 +2484,10 @@ }, { "cell_type": "markdown", - "id": "94102dba", - "metadata": {}, + "id": "ec9a935b", + "metadata": { + "editable": true + }, "source": [ "where we assume that all nodes in the same layer have identical\n", "activation functions, hence the notation $f$. In general, we could assume in the more general case that different layers have different activation functions.\n", @@ -2232,8 +2496,10 @@ }, { "cell_type": "markdown", - "id": "f7be1a6a", - "metadata": {}, + "id": "1f323e8e", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2248,8 +2514,10 @@ }, { "cell_type": "markdown", - "id": "c62cd931", - "metadata": {}, + "id": "1cd75313", + "metadata": { + "editable": true + }, "source": [ "where $N_l$ is the number of nodes in layer $l$. When the output of\n", "all the nodes in the first hidden layer are computed, the values of\n", @@ -2259,8 +2527,10 @@ }, { "cell_type": "markdown", - "id": "5ba6e940", - "metadata": {}, + "id": "040671b8", + "metadata": { + "editable": true + }, "source": [ "## Mathematical model\n", "\n", @@ -2269,8 +2539,10 @@ }, { "cell_type": "markdown", - "id": "df6992b9", - "metadata": {}, + "id": "7795100f", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2285,8 +2557,10 @@ }, { "cell_type": "markdown", - "id": "04fd00e7", - "metadata": {}, + "id": "a7d319f4", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2301,16 +2575,20 @@ }, { "cell_type": "markdown", - "id": "0de91466", - "metadata": {}, + "id": "aecdbb90", + "metadata": { + "editable": true + }, "source": [ "where we have substituted $y_k^1$ with the inputs $x_k$. Finally, the ANN output reads" ] }, { "cell_type": "markdown", - "id": "9eb9f176", - "metadata": {}, + "id": "41551714", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2325,8 +2603,10 @@ }, { "cell_type": "markdown", - "id": "f61adc0b", - "metadata": {}, + "id": "b6fc5aeb", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2342,8 +2622,10 @@ }, { "cell_type": "markdown", - "id": "7c0aad8c", - "metadata": {}, + "id": "8f35a0af", + "metadata": { + "editable": true + }, "source": [ "## Mathematical model\n", "\n", @@ -2353,8 +2635,10 @@ }, { "cell_type": "markdown", - "id": "ee2df9a8", - "metadata": {}, + "id": "4a9a7323", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2369,8 +2653,10 @@ }, { "cell_type": "markdown", - "id": "a7e1cbb6", - "metadata": {}, + "id": "6a968097", + "metadata": { + "editable": true + }, "source": [ "which illustrates a basic property of MLPs: The only independent\n", "variables are the input values $x_n$." @@ -2378,8 +2664,10 @@ }, { "cell_type": "markdown", - "id": "498e9724", - "metadata": {}, + "id": "63e033e2", + "metadata": { + "editable": true + }, "source": [ "## Mathematical model\n", "\n", @@ -2395,8 +2683,10 @@ }, { "cell_type": "markdown", - "id": "00817577", - "metadata": {}, + "id": "ccf0c287", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2411,8 +2701,10 @@ }, { "cell_type": "markdown", - "id": "324012a8", - "metadata": {}, + "id": "71a805ce", + "metadata": { + "editable": true + }, "source": [ "where the parameters $c_i$ are weights and biases. By adjusting these\n", "parameters, the activation functions can be shifted up and down or\n", @@ -2422,8 +2714,10 @@ }, { "cell_type": "markdown", - "id": "f3d107a5", - "metadata": {}, + "id": "cc1067c5", + "metadata": { + "editable": true + }, "source": [ "### Matrix-vector notation\n", "\n", @@ -2440,8 +2734,10 @@ }, { "cell_type": "markdown", - "id": "4e46d94b", - "metadata": {}, + "id": "4fa6bc8e", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2471,8 +2767,10 @@ }, { "cell_type": "markdown", - "id": "60c72663", - "metadata": {}, + "id": "b5b3fe8f", + "metadata": { + "editable": true + }, "source": [ "### Matrix-vector notation and activation\n", "\n", @@ -2481,8 +2779,10 @@ }, { "cell_type": "markdown", - "id": "49b8e555", - "metadata": {}, + "id": "91fd1ca1", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -2498,8 +2798,10 @@ }, { "cell_type": "markdown", - "id": "fb36a61b", - "metadata": {}, + "id": "278721d3", + "metadata": { + "editable": true + }, "source": [ "This is not just a convenient and compact notation, but also a useful\n", "and intuitive way to think about MLPs: The output is calculated by a\n", @@ -2510,8 +2812,10 @@ }, { "cell_type": "markdown", - "id": "f6b8fdcc", - "metadata": {}, + "id": "833061c7", + "metadata": { + "editable": true + }, "source": [ "### Activation functions\n", "\n", @@ -2531,8 +2835,10 @@ }, { "cell_type": "markdown", - "id": "985d1cf2", - "metadata": {}, + "id": "e2de808c", + "metadata": { + "editable": true + }, "source": [ "### Activation functions, Logistic and Hyperbolic ones\n", "\n", @@ -2548,8 +2854,10 @@ }, { "cell_type": "markdown", - "id": "9cf30088", - "metadata": {}, + "id": "94060f6b", + "metadata": { + "editable": true + }, "source": [ "$$\n", "f(x) = \\frac{1}{1 + e^{-x}},\n", @@ -2558,16 +2866,20 @@ }, { "cell_type": "markdown", - "id": "2536e875", - "metadata": {}, + "id": "6796c468", + "metadata": { + "editable": true + }, "source": [ "and the *hyperbolic tangent* function" ] }, { "cell_type": "markdown", - "id": "2428ac57", - "metadata": {}, + "id": "6ba625d1", + "metadata": { + "editable": true + }, "source": [ "$$\n", "f(x) = \\tanh(x)\n", @@ -2576,8 +2888,10 @@ }, { "cell_type": "markdown", - "id": "0429f882", - "metadata": {}, + "id": "bf1f8378", + "metadata": { + "editable": true + }, "source": [ "### Relevance\n", "\n", @@ -2591,8 +2905,11 @@ { "cell_type": "code", "execution_count": 23, - "id": "4b81f111", - "metadata": {}, + "id": "d2874b9e", + "metadata": { + "collapsed": false, + "editable": true + }, "outputs": [], "source": [ "\"\"\"The sigmoid function (or the logistic curve) is a \n", @@ -2670,8 +2987,10 @@ }, { "cell_type": "markdown", - "id": "5942f6ae", - "metadata": {}, + "id": "e70474f3", + "metadata": { + "editable": true + }, "source": [ "## The multilayer perceptron (MLP)\n", "\n", @@ -2706,8 +3025,10 @@ }, { "cell_type": "markdown", - "id": "d8c8f241", - "metadata": {}, + "id": "674bdb91", + "metadata": { + "editable": true + }, "source": [ "## From one to many layers, the universal approximation theorem\n", "\n", @@ -2734,8 +3055,10 @@ }, { "cell_type": "markdown", - "id": "fbc4bb7f", - "metadata": {}, + "id": "c73b02e0", + "metadata": { + "editable": true + }, "source": [ "## Deriving the back propagation code for a multilayer perceptron model\n", "\n", @@ -2753,8 +3076,10 @@ }, { "cell_type": "markdown", - "id": "9007a7e1", - "metadata": {}, + "id": "8af35b7c", + "metadata": { + "editable": true + }, "source": [ "$$\n", "{\\cal C}(\\hat{W}) = \\frac{1}{2}\\sum_{i=1}^n\\left(y_i - t_i\\right)^2,\n", @@ -2763,8 +3088,10 @@ }, { "cell_type": "markdown", - "id": "9416d184", - "metadata": {}, + "id": "1adc2cd8", + "metadata": { + "editable": true + }, "source": [ "where the $t_i$s are our $n$ targets (the values we want to\n", "reproduce), while the outputs of the network after having propagated\n", @@ -2776,8 +3103,10 @@ }, { "cell_type": "markdown", - "id": "be124c7b", - "metadata": {}, + "id": "2d719214", + "metadata": { + "editable": true + }, "source": [ "## Definitions\n", "\n", @@ -2791,8 +3120,10 @@ }, { "cell_type": "markdown", - "id": "f900b0e2", - "metadata": {}, + "id": "7f8daaf1", + "metadata": { + "editable": true + }, "source": [ "$$\n", "z_j^l = \\sum_{i=1}^{M_{l-1}}w_{ij}^la_i^{l-1}+b_j^l,\n", @@ -2801,8 +3132,10 @@ }, { "cell_type": "markdown", - "id": "ae026bf6", - "metadata": {}, + "id": "64c6ed49", + "metadata": { + "editable": true + }, "source": [ "where $b_k^l$ are the biases from layer $l$. Here $M_{l-1}$\n", "represents the total number of nodes/neurons/units of layer $l-1$. The\n", @@ -2812,8 +3145,10 @@ }, { "cell_type": "markdown", - "id": "bd53f785", - "metadata": {}, + "id": "9ce66935", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\hat{z}^l = \\left(\\hat{W}^l\\right)^T\\hat{a}^{l-1}+\\hat{b}^l.\n", @@ -2822,8 +3157,10 @@ }, { "cell_type": "markdown", - "id": "82ab1706", - "metadata": {}, + "id": "7fe13bec", + "metadata": { + "editable": true + }, "source": [ "With the activation values $\\hat{z}^l$ we can in turn define the\n", "output of layer $l$ as $\\hat{a}^l = f(\\hat{z}^l)$ where $f$ is our\n", @@ -2834,8 +3171,10 @@ }, { "cell_type": "markdown", - "id": "0a64ba41", - "metadata": {}, + "id": "0f6ddecc", + "metadata": { + "editable": true + }, "source": [ "$$\n", "a_j^l = f(z_j^l) = \\frac{1}{1+\\exp{-(z_j^l)}}.\n", @@ -2844,8 +3183,10 @@ }, { "cell_type": "markdown", - "id": "7ef830c1", - "metadata": {}, + "id": "abc1e05f", + "metadata": { + "editable": true + }, "source": [ "## Derivatives and the chain rule\n", "\n", @@ -2854,8 +3195,10 @@ }, { "cell_type": "markdown", - "id": "5e41dbc7", - "metadata": {}, + "id": "f8a4b8e0", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial z_j^l}{\\partial w_{ij}^l} = a_i^{l-1},\n", @@ -2864,16 +3207,20 @@ }, { "cell_type": "markdown", - "id": "6e9ee76a", - "metadata": {}, + "id": "896e3b50", + "metadata": { + "editable": true + }, "source": [ "and" ] }, { "cell_type": "markdown", - "id": "8fc731d6", - "metadata": {}, + "id": "2c4fcf9b", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial z_j^l}{\\partial a_i^{l-1}} = w_{ji}^l.\n", @@ -2882,16 +3229,20 @@ }, { "cell_type": "markdown", - "id": "c235c716", - "metadata": {}, + "id": "a25cfb52", + "metadata": { + "editable": true + }, "source": [ "With our definition of the activation function we have that (note that this function depends only on $z_j^l$)" ] }, { "cell_type": "markdown", - "id": "dd5cd724", - "metadata": {}, + "id": "53c29147", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial a_j^l}{\\partial z_j^{l}} = a_j^l(1-a_j^l)=f(z_j^l)(1-f(z_j^l)).\n", @@ -2900,8 +3251,10 @@ }, { "cell_type": "markdown", - "id": "6c3eba41", - "metadata": {}, + "id": "56bd646e", + "metadata": { + "editable": true + }, "source": [ "## Derivative of the cost function\n", "\n", @@ -2912,8 +3265,10 @@ }, { "cell_type": "markdown", - "id": "3bef1f38", - "metadata": {}, + "id": "ab32773e", + "metadata": { + "editable": true + }, "source": [ "$$\n", "{\\cal C}(\\hat{W^L}) = \\frac{1}{2}\\sum_{i=1}^n\\left(y_i - t_i\\right)^2=\\frac{1}{2}\\sum_{i=1}^n\\left(a_i^L - t_i\\right)^2,\n", @@ -2922,16 +3277,20 @@ }, { "cell_type": "markdown", - "id": "2063e479", - "metadata": {}, + "id": "a80f2f9c", + "metadata": { + "editable": true + }, "source": [ "The derivative of this function with respect to the weights is" ] }, { "cell_type": "markdown", - "id": "32081e17", - "metadata": {}, + "id": "f0d2e34f", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial{\\cal C}(\\hat{W^L})}{\\partial w_{jk}^L} = \\left(a_j^L - t_j\\right)\\frac{\\partial a_j^L}{\\partial w_{jk}^{L}},\n", @@ -2940,16 +3299,20 @@ }, { "cell_type": "markdown", - "id": "c4c03ac0", - "metadata": {}, + "id": "a21db4b0", + "metadata": { + "editable": true + }, "source": [ "The last partial derivative can easily be computed and reads (by applying the chain rule)" ] }, { "cell_type": "markdown", - "id": "852f8a23", - "metadata": {}, + "id": "c43900c7", + "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", @@ -2958,8 +3321,10 @@ }, { "cell_type": "markdown", - "id": "77c328d5", - "metadata": {}, + "id": "e1c9778a", + "metadata": { + "editable": true + }, "source": [ "## Bringing it together, first back propagation equation\n", "\n", @@ -2968,8 +3333,10 @@ }, { "cell_type": "markdown", - "id": "cc4c3eb8", - "metadata": {}, + "id": "3cf5b00c", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial{\\cal C}(\\hat{W^L})}{\\partial w_{jk}^L} = \\left(a_j^L - t_j\\right)a_j^L(1-a_j^L)a_k^{L-1},\n", @@ -2978,16 +3345,20 @@ }, { "cell_type": "markdown", - "id": "c3185717", - "metadata": {}, + "id": "1b347cdb", + "metadata": { + "editable": true + }, "source": [ "Defining" ] }, { "cell_type": "markdown", - "id": "62aad72f", - "metadata": {}, + "id": "7a9a53d7", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\delta_j^L = a_j^L(1-a_j^L)\\left(a_j^L - t_j\\right) = f'(z_j^L)\\frac{\\partial {\\cal C}}{\\partial (a_j^L)},\n", @@ -2996,16 +3367,20 @@ }, { "cell_type": "markdown", - "id": "80363a1c", - "metadata": {}, + "id": "f70884cb", + "metadata": { + "editable": true + }, "source": [ "and using the Hadamard product of two vectors we can write this as" ] }, { "cell_type": "markdown", - "id": "8681d308", - "metadata": {}, + "id": "f350e0e5", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\hat{\\delta}^L = f'(\\hat{z}^L)\\circ\\frac{\\partial {\\cal C}}{\\partial (\\hat{a}^L)}.\n", @@ -3014,8 +3389,10 @@ }, { "cell_type": "markdown", - "id": "fbc68aef", - "metadata": {}, + "id": "b007cd8a", + "metadata": { + "editable": true + }, "source": [ "This is an important expression. The second term on the right handside\n", "measures how fast the cost function is changing as a function of the $j$th\n", @@ -3036,8 +3413,10 @@ }, { "cell_type": "markdown", - "id": "d25efc85", - "metadata": {}, + "id": "b3498a77", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial {\\cal C}}{\\partial (a_j^L)}\n", @@ -3046,16 +3425,20 @@ }, { "cell_type": "markdown", - "id": "0a9568a0", - "metadata": {}, + "id": "98a2d7dc", + "metadata": { + "editable": true + }, "source": [ "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" ] }, { "cell_type": "markdown", - "id": "effdc44a", - "metadata": {}, + "id": "d5ea7c10", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\frac{\\partial{\\cal C}(\\hat{W^L})}{\\partial w_{jk}^L} = \\delta_j^La_k^{L-1}.\n", @@ -3064,8 +3447,10 @@ }, { "cell_type": "markdown", - "id": "8cdfa62d", - "metadata": {}, + "id": "4ad9d8a8", + "metadata": { + "editable": true + }, "source": [ "## Derivatives in terms of $z_j^L$\n", "\n", @@ -3074,8 +3459,10 @@ }, { "cell_type": "markdown", - "id": "842ac6aa", - "metadata": {}, + "id": "19aab871", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\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},\n", @@ -3084,16 +3471,20 @@ }, { "cell_type": "markdown", - "id": "f4f40e9d", - "metadata": {}, + "id": "344ed8fd", + "metadata": { + "editable": true + }, "source": [ "which can also be interpreted as the partial derivative of the cost function with respect to the biases $b_j^L$, namely" ] }, { "cell_type": "markdown", - "id": "7c3f7692", - "metadata": {}, + "id": "2d3f0276", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\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},\n", @@ -3102,16 +3493,20 @@ }, { "cell_type": "markdown", - "id": "38d73332", - "metadata": {}, + "id": "f57b1bca", + "metadata": { + "editable": true + }, "source": [ "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." ] }, { "cell_type": "markdown", - "id": "32266730", - "metadata": {}, + "id": "359908a2", + "metadata": { + "editable": true + }, "source": [ "## Bringing it together\n", "\n", @@ -3122,8 +3517,10 @@ }, { "cell_type": "markdown", - "id": "90e5e922", - "metadata": {}, + "id": "eac4906a", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -3138,16 +3535,20 @@ }, { "cell_type": "markdown", - "id": "55a6708f", - "metadata": {}, + "id": "06f990d7", + "metadata": { + "editable": true + }, "source": [ "and" ] }, { "cell_type": "markdown", - "id": "4958b0bc", - "metadata": {}, + "id": "41b70a53", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -3162,16 +3563,20 @@ }, { "cell_type": "markdown", - "id": "f7dab092", - "metadata": {}, + "id": "dc8d4ec0", + "metadata": { + "editable": true + }, "source": [ "and" ] }, { "cell_type": "markdown", - "id": "10787835", - "metadata": {}, + "id": "34b68d55", + "metadata": { + "editable": true + }, "source": [ "\n", "
    \n", @@ -3186,8 +3591,10 @@ }, { "cell_type": "markdown", - "id": "a5349b20", - "metadata": {}, + "id": "96b4c71f", + "metadata": { + "editable": true + }, "source": [ "An interesting consequence of the above equations is that when the\n", "activation $a_k^{L-1}$ is small, the gradient term, that is the\n", @@ -3211,8 +3618,10 @@ }, { "cell_type": "markdown", - "id": "ac5b120e", - "metadata": {}, + "id": "9e1573a1", + "metadata": { + "editable": true + }, "source": [ "## Final back propagating equation\n", "\n", @@ -3221,8 +3630,10 @@ }, { "cell_type": "markdown", - "id": "5c822241", - "metadata": {}, + "id": "f3396fba", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\delta_j^l =\\frac{\\partial {\\cal C}}{\\partial z_j^l}.\n", @@ -3231,16 +3642,20 @@ }, { "cell_type": "markdown", - "id": "15efeef8", - "metadata": {}, + "id": "74487eb3", + "metadata": { + "editable": true + }, "source": [ "We want to express this in terms of the equations for layer $l+1$. Using the chain rule and summing over all $k$ entries we have" ] }, { "cell_type": "markdown", - "id": "f34ad50c", - "metadata": {}, + "id": "b39271c5", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\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}},\n", @@ -3249,16 +3664,20 @@ }, { "cell_type": "markdown", - "id": "f3a4c387", - "metadata": {}, + "id": "8c84be38", + "metadata": { + "editable": true + }, "source": [ "and recalling that" ] }, { "cell_type": "markdown", - "id": "0b810b9a", - "metadata": {}, + "id": "42ae0cdf", + "metadata": { + "editable": true + }, "source": [ "$$\n", "z_j^{l+1} = \\sum_{i=1}^{M_{l}}w_{ij}^{l+1}a_i^{l}+b_j^{l+1},\n", @@ -3267,16 +3686,20 @@ }, { "cell_type": "markdown", - "id": "f7a3bf81", - "metadata": {}, + "id": "bd4140eb", + "metadata": { + "editable": true + }, "source": [ "with $M_l$ being the number of nodes in layer $l$, we obtain" ] }, { "cell_type": "markdown", - "id": "d599b0a2", - "metadata": {}, + "id": "a9629dd7", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\delta_j^l =\\sum_k \\delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l),\n", @@ -3285,8 +3708,10 @@ }, { "cell_type": "markdown", - "id": "64cbb773", - "metadata": {}, + "id": "154d20a8", + "metadata": { + "editable": true + }, "source": [ "This is our final equation.\n", "\n", @@ -3295,8 +3720,10 @@ }, { "cell_type": "markdown", - "id": "e69ed5e5", - "metadata": {}, + "id": "41bc04fb", + "metadata": { + "editable": true + }, "source": [ "## Setting up the Back propagation algorithm\n", "\n", @@ -3316,8 +3743,10 @@ }, { "cell_type": "markdown", - "id": "bc52c09f", - "metadata": {}, + "id": "1f6d86dd", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\delta_j^L = f'(z_j^L)\\frac{\\partial {\\cal C}}{\\partial (a_j^L)}.\n", @@ -3326,16 +3755,20 @@ }, { "cell_type": "markdown", - "id": "05e6d24f", - "metadata": {}, + "id": "2184ad0b", + "metadata": { + "editable": true + }, "source": [ "Then we compute the back propagate error for each $l=L-1,L-2,\\dots,2$ as" ] }, { "cell_type": "markdown", - "id": "a33e6684", - "metadata": {}, + "id": "6ce690fe", + "metadata": { + "editable": true + }, "source": [ "$$\n", "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}f'(z_j^l).\n", @@ -3344,16 +3777,20 @@ }, { "cell_type": "markdown", - "id": "0e0090b2", - "metadata": {}, + "id": "383fb718", + "metadata": { + "editable": true + }, "source": [ "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" ] }, { "cell_type": "markdown", - "id": "a559b53f", - "metadata": {}, + "id": "d1dd9f65", + "metadata": { + "editable": true + }, "source": [ "$$\n", "w_{jk}^l\\leftarrow = w_{jk}^l- \\eta \\delta_j^la_k^{l-1},\n", @@ -3362,8 +3799,10 @@ }, { "cell_type": "markdown", - "id": "493fddb7", - "metadata": {}, + "id": "272288c5", + "metadata": { + "editable": true + }, "source": [ "$$\n", "b_j^l \\leftarrow b_j^l-\\eta \\frac{\\partial {\\cal C}}{\\partial b_j^l}=b_j^l-\\eta \\delta_j^l,\n", @@ -3372,33 +3811,17 @@ }, { "cell_type": "markdown", - "id": "dfc0b1d9", - "metadata": {}, + "id": "c0e318dc", + "metadata": { + "editable": true + }, "source": [ "The parameter $\\eta$ is the learning parameter discussed in connection with the gradient descent methods.\n", "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." ] } ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.7" - } - }, + "metadata": {}, "nbformat": 4, "nbformat_minor": 5 } diff --git a/doc/src/week40/week40.do.txt b/doc/src/week40/week40.do.txt index 630545efd..831110c0c 100644 --- a/doc/src/week40/week40.do.txt +++ b/doc/src/week40/week40.do.txt @@ -302,7 +302,13 @@ plt.show() !ec +!split +===== Replace or not ===== +In the above code, we have use replacement in setting up the +mini-batches. The discussion +"here":"https://sebastianraschka.com/faq/docs/sgd-methods.html" may be +useful. More material will be added later. !split