From 9cece36bbf45ad2277ef945a09ca3ec0a1761433 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 06:59:44 +0200 Subject: [PATCH 01/14] updating notes --- .../{ => Previousversions}/backup2022.do.txt | 0 .../{ => Previousversions}/version2021.do.txt | 0 doc/src/week43/Previousversions/week43.do.txt | 5076 +++++++++++++++++ 3 files changed, 5076 insertions(+) rename doc/src/week43/{ => Previousversions}/backup2022.do.txt (100%) rename doc/src/week43/{ => Previousversions}/version2021.do.txt (100%) create mode 100644 doc/src/week43/Previousversions/week43.do.txt diff --git a/doc/src/week43/backup2022.do.txt b/doc/src/week43/Previousversions/backup2022.do.txt similarity index 100% rename from doc/src/week43/backup2022.do.txt rename to doc/src/week43/Previousversions/backup2022.do.txt diff --git a/doc/src/week43/version2021.do.txt b/doc/src/week43/Previousversions/version2021.do.txt similarity index 100% rename from doc/src/week43/version2021.do.txt rename to doc/src/week43/Previousversions/version2021.do.txt diff --git a/doc/src/week43/Previousversions/week43.do.txt b/doc/src/week43/Previousversions/week43.do.txt new file mode 100644 index 000000000..4fb97b4f8 --- /dev/null +++ b/doc/src/week43/Previousversions/week43.do.txt @@ -0,0 +1,5076 @@ +TITLE: Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations +AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo, Norway +DATE: October 20, 2025 + +!split +===== Plans for week 43 ===== + +!bblock Material for the lecture on Monday October 20, 2025 + * Building our own Feed-forward Neural Network with intro to Tensorflow + * Solving differential equations with Neural Networks +# * Video of lecture at URL:"https://youtu.be/vkBNTn-MLqs" +# * Video os second part, solving differential equations with neural networks at URL:"https://youtu.be/2N8To65I2wQ" +# * Whiteboard notes on solving differential equations at URL:"https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2024/NotesOct21.pdf" +!eblock + + + +!split +===== Exercises and lab session week 43 ===== +!bblock Lab sessions on Tuesday and Wednesday + * Exercise on writing your own neural network code + * The exercises this week will be continued next week as well + * Discussion of project 2 +!eblock + + + +!split +===== Mathematics of deep learning ===== + +!bblock Two recent books online +o The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at URL:"https://arxiv.org/abs/2105.04026", published as "Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022":"https://doi.org/10.1017/9781009025096.002" + +o Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at URL:"https://doi.org/10.48550/arXiv.2310.20360" +!eblock + + +!split +===== Reminder on books with hands-on material and codes ===== +!bblock +* Sebastian Rashcka et al, Machine learning with Scikit-Learn and PyTorch at URL:"https://sebastianraschka.com/blog/2022/ml-pytorch-book.html" +!eblock + + +!split +===== Reading recommendations ===== + +o Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at URL:"https://github.com/rasbt/machine-learning-book". See also chapters 12 and 13 on using Pytorch to make a Neural network code. +o Goodfellow et al, chapter 6 and 7 contain most of the neural network background. + + +!split +===== Using Automatic differentiation ===== + +In our discussions of ordinary differential equations and neural network codes +we will also study the usage of Autograd, see for example URL:"https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola" in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from "week 39":"https://compphysics.github.io/MachineLearning/doc/pub/week39/html/week39.html" and the Autograd documentation at URL:"https://github.com/HIPS/autograd". + + +!split +===== Back propagation and automatic differentiation ===== + +For more details on the back propagation algorithm and automatic differentiation see +o URL:"https://www.jmlr.org/papers/volume18/17-468/17-468.pdf" +o URL:"https://deepimaging.github.io/lectures/lecture_11_Backpropagation.pdf" +o Slides 12-44 at URL:"http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture4.pdf" + + + +!split +===== Lecture Monday October 21 ===== + + +!split +===== Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations ===== +This is a reminder from where we ended last week. + +!bblock The architecture (our model) +o Set up your inputs and outputs (scalars, vectors, matrices or higher-order arrays) +o Define the number of hidden layers and hidden nodes +o Define activation functions for hidden layers and output layers +o Define optimizer (plan learning rate, momentum, ADAgrad, RMSprop, ADAM etc) and array of initial learning rates +o Define cost function and possible regularization terms with hyperparameters +o Initialize weights and biases +o Fix number of iterations for the feed forward part and back propagation part +!eblock + +!split +===== Setting up the back propagation algorithm, part 1 ===== + +Let us write this out in the form of an algorithm. + +_First_, we set up the input data $\bm{x}$ and the activations +$\bm{z}_1$ of the input layer and compute the activation function and +the pertinent outputs $\bm{a}^1$. + +_Secondly_, we perform then the feed forward till we reach the output +layer and compute all $\bm{z}_l$ of the input layer and compute the +activation function and the pertinent outputs $\bm{a}^l$ for +$l=1,2,3,\dots,L$. + + +_Notation_: The first hidden layer has $l=1$ as label and the final output layer has $l=L$. + +!split +===== Setting up the back propagation algorithm, part 2 ===== + + +Thereafter we compute the ouput error $\bm{\delta}^L$ by computing all +!bt +\[ +\delta_j^L = \sigma'(z_j^L)\frac{\partial {\cal C}}{\partial (a_j^L)}. +\] +!et + +Then we compute the back propagate error for each $l=L-1,L-2,\dots,1$ as +!bt +\[ +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l). +\] +!et + +!split +===== Setting up the Back propagation algorithm, part 3 ===== + + +Finally, we update the weights and the biases using gradient descent +for each $l=L-1,L-2,\dots,1$ (the first hidden layer) and update the weights and biases +according to the rules + +!bt +\[ +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, +\] +!et + +!bt +\[ +b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, +\] +!et +with $\eta$ being the learning rate. + +!split +===== Updating the gradients ===== + +With the back propagate error for each $l=L-1,L-2,\dots,1$ as +!bt +\[ +\delta_j^l = \sum_k \delta_k^{l+1}w_{kj}^{l+1}\sigma'(z_j^l), +\] +!et +we update the weights and the biases using gradient descent for each $l=L-1,L-2,\dots,1$ and update the weights and biases according to the rules +!bt +\[ +w_{ij}^l\leftarrow = w_{ij}^l- \eta \delta_j^la_i^{l-1}, +\] +!et + +!bt +\[ +b_j^l \leftarrow b_j^l-\eta \frac{\partial {\cal C}}{\partial b_j^l}=b_j^l-\eta \delta_j^l, +\] +!et + + + +!split +===== Activation functions ===== + + +A property that characterizes a neural network, other than its +connectivity, is the choice of activation function(s). The following +restrictions are imposed on an activation function for an FFNN to +fulfill the universal approximation theorem + + * Non-constant + + * Bounded + + * Monotonically-increasing + + * Continuous + +!split +=== Activation functions, examples === + +Typical examples are the logistic *Sigmoid* + +!bt +\[ + \sigma(x) = \frac{1}{1 + e^{-x}}, +\] +!et +and the *hyperbolic tangent* function +!bt +\[ + \sigma(x) = \tanh(x) +\] +!et + + +!split +===== The RELU function family ===== + +The ReLU activation function suffers from a problem known as the dying +ReLUs: during training, some neurons effectively die, meaning they +stop outputting anything other than 0. + +In some cases, you may find that half of your network’s neurons are +dead, especially if you used a large learning rate. During training, +if a neuron’s weights get updated such that the weighted sum of the +neuron’s inputs is negative, it will start outputting 0. When this +happen, the neuron is unlikely to come back to life since the gradient +of the ReLU function is 0 when its input is negative. + +!split +===== ELU function ===== + +To solve this problem, nowadays practitioners use a variant of the +ReLU function, such as the leaky ReLU discussed above or the so-called +exponential linear unit (ELU) function + + +!bt +\[ +ELU(z) = \left\{\begin{array}{cc} \alpha\left( \exp{(z)}-1\right) & z < 0,\\ z & z \ge 0.\end{array}\right. +\] +!et + +!split +===== Which activation function should we use? ===== + +In general it seems that the ELU activation function is better than +the leaky ReLU function (and its variants), which is better than +ReLU. ReLU performs better than $\tanh$ which in turn performs better +than the logistic function. + +If runtime performance is an issue, then you may opt for the leaky +ReLU function over the ELU function If you don’t want to tweak yet +another hyperparameter, you may just use the default $\alpha$ of +$0.01$ for the leaky ReLU, and $1$ for ELU. If you have spare time and +computing power, you can use cross-validation or bootstrap to evaluate +other activation functions. + + +!split +===== More on activation functions, output layers ===== + +In most cases you can use the ReLU activation function in the hidden +layers (or one of its variants). + +It is a bit faster to compute than other activation functions, and the +gradient descent optimization does in general not get stuck. + +_For the output layer:_ + +* For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive). +* For regression tasks, you can simply use no activation function at all. + + + + +!split +===== Setting up a Multi-layer perceptron model for classification ===== + +We are now gong to develop an example based on the MNIST data +base. This is a classification problem and we need to use our +cross-entropy function we discussed in connection with logistic +regression. The cross-entropy defines our cost function for the +classificaton problems with neural networks. + +In binary classification with two classes $(0, 1)$ we define the +logistic/sigmoid function as the probability that a particular input +is in class $0$ or $1$. This is possible because the logistic +function takes any input from the real numbers and inputs a number +between 0 and 1, and can therefore be interpreted as a probability. It +also has other nice properties, such as a derivative that is simple to +calculate. + +For an input $\boldsymbol{a}$ from the hidden layer, the probability that the input $\boldsymbol{x}$ +is in class 0 or 1 is just. We let $\theta$ represent the unknown weights and biases to be adjusted by our equations). The variable $x$ +represents our activation values $z$. We have +!bt +\[ +P(y = 0 \mid \bm{x}, \bm{\theta}) = \frac{1}{1 + \exp{(- \bm{x}})} , +\] +!et +and +!bt +\[ +P(y = 1 \mid \bm{x}, \bm{\theta}) = 1 - P(y = 0 \mid \bm{x}, \bm{\theta}) , +\] +!et + +where $y \in \{0, 1\}$ and $\bm{\theta}$ represents the weights and biases +of our network. + + +!split +===== Defining the cost function ===== + +Our cost function is given as (see the Logistic regression lectures) +!bt +\[ +\mathcal{C}(\bm{\theta}) = - \ln P(\mathcal{D} \mid \bm{\theta}) = - \sum_{i=1}^n +y_i \ln[P(y_i = 0)] + (1 - y_i) \ln [1 - P(y_i = 0)] = \sum_{i=1}^n \mathcal{L}_i(\bm{\theta}) . +\] +!et + +This last equality means that we can interpret our *cost* function as a sum over the *loss* function +for each point in the dataset $\mathcal{L}_i(\bm{\theta})$. +The negative sign is just so that we can think about our algorithm as minimizing a positive number, rather +than maximizing a negative number. + +In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: + +$y = 5 \quad \rightarrow \quad \bm{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$ and + + +$y = 1 \quad \rightarrow \quad \bm{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$ + + +i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset (numbers from $0$ to $9$).. + +If $\bm{x}_i$ is the $i$-th input (image), $y_{ic}$ refers to the $c$-th component of the $i$-th +output vector $\bm{y}_i$. +The probability of $\bm{x}_i$ being in class $c$ will be given by the softmax function: + +!bt +\[ +P(y_{ic} = 1 \mid \bm{x}_i, \bm{\theta}) = \frac{\exp{((\bm{a}_i^{hidden})^T \bm{w}_c)}} +{\sum_{c'=0}^{C-1} \exp{((\bm{a}_i^{hidden})^T \bm{w}_{c'})}} , +\] +!et + +which reduces to the logistic function in the binary case. +The likelihood of this $C$-class classifier +is now given as: + +!bt +\[ +P(\mathcal{D} \mid \bm{\theta}) = \prod_{i=1}^n \prod_{c=0}^{C-1} [P(y_{ic} = 1)]^{y_{ic}} . +\] +!et +Again we take the negative log-likelihood to define our cost function: + +!bt +\[ +\mathcal{C}(\bm{\theta}) = - \log{P(\mathcal{D} \mid \bm{\theta})}. +\] +!et +See the logistic regression lectures for a full definition of the cost function. + +The back propagation equations need now only a small change, namely the definition of a new cost function. We are thus ready to use the same equations as before! + +!split +===== Example: binary classification problem ===== + +As an example of the above, relevant for project 2 as well, let us consider a binary class. As discussed in our logistic regression lectures, we defined a cost function in terms of the parameters $\beta$ as +!bt +\[ +\mathcal{C}(\bm{\beta}) = - \sum_{i=1}^n \left(y_i\log{p(y_i \vert x_i,\bm{\beta})}+(1-y_i)\log{1-p(y_i \vert x_i,\bm{\beta})}\right), +\] +!et +where we had defined the logistic (sigmoid) function +!bt +\[ +p(y_i =1\vert x_i,\bm{\beta})=\frac{\exp{(\beta_0+\beta_1 x_i)}}{1+\exp{(\beta_0+\beta_1 x_i)}}, +\] +!et +and +!bt +\[ +p(y_i =0\vert x_i,\bm{\beta})=1-p(y_i =1\vert x_i,\bm{\beta}). +\] +!et +The parameters $\bm{\beta}$ were defined using a minimization method like gradient descent or Newton-Raphson's method. + +Now we replace $x_i$ with the activation $z_i^l$ for a given layer $l$ and the outputs as $y_i=a_i^l=f(z_i^l)$, with $z_i^l$ now being a function of the weights $w_{ij}^l$ and biases $b_i^l$. +We have then +!bt +\[ +a_i^l = y_i = \frac{\exp{(z_i^l)}}{1+\exp{(z_i^l)}}, +\] +!et +with +!bt +\[ +z_i^l = \sum_{j}w_{ij}^l a_j^{l-1}+b_i^l, +\] +!et +where the superscript $l-1$ indicates that these are the outputs from layer $l-1$. +Our cost function at the final layer $l=L$ is now +!bt +\[ +\mathcal{C}(\bm{W}) = - \sum_{i=1}^n \left(t_i\log{a_i^L}+(1-t_i)\log{(1-a_i^L)}\right), +\] +!et +where we have defined the targets $t_i$. The derivatives of the cost function with respect to the output $a_i^L$ are then easily calculated and we get +!bt +\[ +\frac{\partial \mathcal{C}(\bm{W})}{\partial a_i^L} = \frac{a_i^L-t_i}{a_i^L(1-a_i^L)}. +\] +!et +In case we use another activation function than the logistic one, we need to evaluate other derivatives. + + +!split +===== The Softmax function ===== +In case we employ the more general case given by the Softmax equation, we need to evaluate the derivative of the activation function with respect to the activation $z_i^l$, that is we need +!bt +\[ +\frac{\partial f(z_i^l)}{\partial w_{jk}^l} = +\frac{\partial f(z_i^l)}{\partial z_j^l} \frac{\partial z_j^l}{\partial w_{jk}^l}= \frac{\partial f(z_i^l)}{\partial z_j^l}a_k^{l-1}. +\] +!et +For the Softmax function we have +!bt +\[ +f(z_i^l) = \frac{\exp{(z_i^l)}}{\sum_{m=1}^K\exp{(z_m^l)}}. +\] +!et +Its derivative with respect to $z_j^l$ gives +!bt +\[ +\frac{\partial f(z_i^l)}{\partial z_j^l}= f(z_i^l)\left(\delta_{ij}-f(z_j^l)\right), +\] +!et +which in case of the simply binary model reduces to having $i=j$. + +!split +===== Developing a code for doing neural networks with back propagation ===== + + +One can identify a set of key steps when using neural networks to solve supervised learning problems: + +o Collect and pre-process data +o Define model and architecture +o Choose cost function and optimizer +o Train the model +o Evaluate model performance on test data +o Adjust hyperparameters (if necessary, network architecture) + +!split +===== Collect and pre-process data ===== + +Here we will be using the MNIST dataset, which is readily available through the _scikit-learn_ +package. You may also find it for example "here":"http://yann.lecun.com/exdb/mnist/". +The *MNIST* (Modified National Institute of Standards and Technology) database is a large database +of handwritten digits that is commonly used for training various image processing systems. +The MNIST dataset consists of 70 000 images of size $28\times 28$ pixels, each labeled from 0 to 9. +The scikit-learn dataset we will use consists of a selection of 1797 images of size $8\times 8$ collected and processed from this database. + +To feed data into a feed-forward neural network we need to represent +the inputs as a design/feature matrix $X = (n_{inputs}, n_{features})$. Each +row represents an *input*, in this case a handwritten digit, and +each column represents a *feature*, in this case a pixel. The +correct answers, also known as *labels* or *targets* are +represented as a 1D array of integers +$Y = (n_{inputs}) = (5, 3, 1, 8,...)$. + +As an example, say we want to build a neural network using supervised learning to predict Body-Mass Index (BMI) from +measurements of height (in m) +and weight (in kg). If we have measurements of 5 people the design/feature matrix could be for example: + +$$ X = \begin{bmatrix} +1.85 & 81\\ +1.71 & 65\\ +1.95 & 103\\ +1.55 & 42\\ +1.63 & 56 +\end{bmatrix} ,$$ + +and the targets would be: + +$$ Y = (23.7, 22.2, 27.1, 17.5, 21.1) $$ + +Since each input image is a 2D matrix, we need to flatten the image +(i.e. "unravel" the 2D matrix into a 1D array) to turn the data into a +design/feature matrix. This means we lose all spatial information in the +image, such as locality and translational invariance. More complicated +architectures such as Convolutional Neural Networks can take advantage +of such information, and are most commonly applied when analyzing +images. + + +!bc pycod +# import necessary packages +import numpy as np +import matplotlib.pyplot as plt +from sklearn import datasets + + +# ensure the same random numbers appear every time +np.random.seed(0) + +# display images in notebook +%matplotlib inline +plt.rcParams['figure.figsize'] = (12,12) + + +# download MNIST dataset +digits = datasets.load_digits() + +# define inputs and labels +inputs = digits.images +labels = digits.target + +print("inputs = (n_inputs, pixel_width, pixel_height) = " + str(inputs.shape)) +print("labels = (n_inputs) = " + str(labels.shape)) + + +# flatten the image +# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64 +n_inputs = len(inputs) +inputs = inputs.reshape(n_inputs, -1) +print("X = (n_inputs, n_features) = " + str(inputs.shape)) + + +# choose some random images to display +indices = np.arange(n_inputs) +random_indices = np.random.choice(indices, size=5) + +for i, image in enumerate(digits.images[random_indices]): + plt.subplot(1, 5, i+1) + plt.axis('off') + plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest') + plt.title("Label: %d" % digits.target[random_indices[i]]) +plt.show() +!ec + +!split +===== Train and test datasets ===== + +Performing analysis before partitioning the dataset is a major error, that can lead to incorrect conclusions. + +We will reserve $80 \%$ of our dataset for training and $20 \%$ for testing. + +It is important that the train and test datasets are drawn randomly from our dataset, to ensure +no bias in the sampling. +Say you are taking measurements of weather data to predict the weather in the coming 5 days. +You don't want to train your model on measurements taken from the hours 00.00 to 12.00, and then test it on data +collected from 12.00 to 24.00. + + +!bc pycod +from sklearn.model_selection import train_test_split + +# one-liner from scikit-learn library +train_size = 0.8 +test_size = 1 - train_size +X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size, + test_size=test_size) + +# equivalently in numpy +def train_test_split_numpy(inputs, labels, train_size, test_size): + n_inputs = len(inputs) + inputs_shuffled = inputs.copy() + labels_shuffled = labels.copy() + + np.random.shuffle(inputs_shuffled) + np.random.shuffle(labels_shuffled) + + train_end = int(n_inputs*train_size) + X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:] + Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:] + + return X_train, X_test, Y_train, Y_test + +#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size) + +print("Number of training images: " + str(len(X_train))) +print("Number of test images: " + str(len(X_test))) +!ec + +!split +===== Define model and architecture ===== + +Our simple feed-forward neural network will consist of an *input* layer, a single *hidden* layer and an *output* layer. The activation $y$ of each neuron is a weighted sum of inputs, passed through an activation function. In case of the simple perceptron model we have + +$$ z = \sum_{i=1}^n w_i a_i ,$$ + +$$ y = f(z) ,$$ + +where $f$ is the activation function, $a_i$ represents input from neuron $i$ in the preceding layer +and $w_i$ is the weight to input $i$. +The activation of the neurons in the input layer is just the features (e.g. a pixel value). + +The simplest activation function for a neuron is the *Heaviside* function: + +$$ f(z) = +\begin{cases} +1, & z > 0\\ +0, & \text{otherwise} +\end{cases} +$$ + +A feed-forward neural network with this activation is known as a *perceptron*. +For a binary classifier (i.e. two classes, 0 or 1, dog or not-dog) we can also use this in our output layer. +This activation can be generalized to $k$ classes (using e.g. the *one-against-all* strategy), +and we call these architectures *multiclass perceptrons*. + +However, it is now common to use the terms Single Layer Perceptron (SLP) (1 hidden layer) and +Multilayer Perceptron (MLP) (2 or more hidden layers) to refer to feed-forward neural networks with any activation function. + +Typical choices for activation functions include the sigmoid function, hyperbolic tangent, and Rectified Linear Unit (ReLU). +We will be using the sigmoid function $\sigma(x)$: + +$$ f(x) = \sigma(x) = \frac{1}{1 + e^{-x}} ,$$ + +which is inspired by probability theory (see logistic regression) and was most commonly used until about 2011. See the discussion below concerning other activation functions. + +!split +===== Layers ===== + +* Input +Since each input image has 8x8 = 64 pixels or features, we have an input layer of 64 neurons. + +* Hidden layer +We will use 50 neurons in the hidden layer receiving input from the neurons in the input layer. +Since each neuron in the hidden layer is connected to the 64 inputs we have 64x50 = 3200 weights to the hidden layer. + +* Output +If we were building a binary classifier, it would be sufficient with a single neuron in the output layer, +which could output 0 or 1 according to the Heaviside function. This would be an example of a *hard* classifier, meaning it outputs the class of the input directly. However, if we are dealing with noisy data it is often beneficial to use a *soft* classifier, which outputs the probability of being in class 0 or 1. + +For a soft binary classifier, we could use a single neuron and interpret the output as either being the probability of being in class 0 or the probability of being in class 1. Alternatively we could use 2 neurons, and interpret each neuron as the probability of being in each class. + +Since we are doing multiclass classification, with 10 categories, it is natural to use 10 neurons in the output layer. We number the neurons $j = 0,1,...,9$. The activation of each output neuron $j$ will be according to the *softmax* function: + +$$ P(\text{class $j$} \mid \text{input $\bm{a}$}) = \frac{\exp{(\bm{a}^T \bm{w}_j)}} +{\sum_{c=0}^{9} \exp{(\bm{a}^T \bm{w}_c)}} ,$$ + +i.e. each neuron $j$ outputs the probability of being in class $j$ given an input from the hidden layer $\bm{a}$, with $\bm{w}_j$ the weights of neuron $j$ to the inputs. +The denominator is a normalization factor to ensure the outputs (probabilities) sum up to 1. +The exponent is just the weighted sum of inputs as before: + +$$ z_j = \sum_{i=1}^n w_ {ij} a_i+b_j.$$ + +Since each neuron in the output layer is connected to the 50 inputs from the hidden layer we have 50x10 = 500 +weights to the output layer. + +!split +===== Weights and biases ===== + +Typically weights are initialized with small values distributed around zero, drawn from a uniform +or normal distribution. Setting all weights to zero means all neurons give the same output, making the network useless. + +Adding a bias value to the weighted sum of inputs allows the neural network to represent a greater range +of values. Without it, any input with the value 0 will be mapped to zero (before being passed through the activation). The bias unit has an output of 1, and a weight to each neuron $j$, $b_j$: + +$$ z_j = \sum_{i=1}^n w_ {ij} a_i + b_j.$$ + +The bias weights $\bm{b}$ are often initialized to zero, but a small value like $0.01$ ensures all neurons have some output which can be backpropagated in the first training cycle. +!bc pycod +# building our neural network + +n_inputs, n_features = X_train.shape +n_hidden_neurons = 50 +n_categories = 10 + +# we make the weights normally distributed using numpy.random.randn + +# weights and bias in the hidden layer +hidden_weights = np.random.randn(n_features, n_hidden_neurons) +hidden_bias = np.zeros(n_hidden_neurons) + 0.01 + +# weights and bias in the output layer +output_weights = np.random.randn(n_hidden_neurons, n_categories) +output_bias = np.zeros(n_categories) + 0.01 +!ec + +!split +===== Feed-forward pass ===== + +Denote $F$ the number of features, $H$ the number of hidden neurons and $C$ the number of categories. +For each input image we calculate a weighted sum of input features (pixel values) to each neuron $j$ in the hidden layer $l$: + +$$ z_{j}^{l} = \sum_{i=1}^{F} w_{ij}^{l} x_i + b_{j}^{l},$$ + +this is then passed through our activation function + +$$ a_{j}^{l} = f(z_{j}^{l}) .$$ + +We calculate a weighted sum of inputs (activations in the hidden layer) to each neuron $j$ in the output layer: + +$$ z_{j}^{L} = \sum_{i=1}^{H} w_{ij}^{L} a_{i}^{l} + b_{j}^{L}.$$ + +Finally we calculate the output of neuron $j$ in the output layer using the softmax function: + +$$ a_{j}^{L} = \frac{\exp{(z_j^{L})}} +{\sum_{c=0}^{C-1} \exp{(z_c^{L})}} .$$ + +!split +===== Matrix multiplications ===== + +Since our data has the dimensions $X = (n_{inputs}, n_{features})$ and our weights to the hidden +layer have the dimensions +$W_{hidden} = (n_{features}, n_{hidden})$, +we can easily feed the network all our training data in one go by taking the matrix product + +$$ X W^{h} = (n_{inputs}, n_{hidden}),$$ + +and obtain a matrix that holds the weighted sum of inputs to the hidden layer +for each input image and each hidden neuron. +We also add the bias to obtain a matrix of weighted sums to the hidden layer $Z^{h}$: + +$$ \bm{z}^{l} = \bm{X} \bm{W}^{l} + \bm{b}^{l} ,$$ + +meaning the same bias (1D array with size equal number of hidden neurons) is added to each input image. +This is then passed through the activation: + +$$ \bm{a}^{l} = f(\bm{z}^l) .$$ + +This is fed to the output layer: + +$$ \bm{z}^{L} = \bm{a}^{L} \bm{W}^{L} + \bm{b}^{L} .$$ + +Finally we receive our output values for each image and each category by passing it through the softmax function: + +$$ output = softmax (\bm{z}^{L}) = (n_{inputs}, n_{categories}) .$$ + + +!bc pycod +# setup the feed-forward pass, subscript h = hidden layer + +def sigmoid(x): + return 1/(1 + np.exp(-x)) + +def feed_forward(X): + # weighted sum of inputs to the hidden layer + z_h = np.matmul(X, hidden_weights) + hidden_bias + # activation in the hidden layer + a_h = sigmoid(z_h) + + # weighted sum of inputs to the output layer + z_o = np.matmul(a_h, output_weights) + output_bias + # softmax output + # axis 0 holds each input and axis 1 the probabilities of each category + exp_term = np.exp(z_o) + probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) + + return probabilities + +probabilities = feed_forward(X_train) +print("probabilities = (n_inputs, n_categories) = " + str(probabilities.shape)) +print("probability that image 0 is in category 0,1,2,...,9 = \n" + str(probabilities[0])) +print("probabilities sum up to: " + str(probabilities[0].sum())) +print() + +# we obtain a prediction by taking the class with the highest likelihood +def predict(X): + probabilities = feed_forward(X) + return np.argmax(probabilities, axis=1) + +predictions = predict(X_train) +print("predictions = (n_inputs) = " + str(predictions.shape)) +print("prediction for image 0: " + str(predictions[0])) +print("correct label for image 0: " + str(Y_train[0])) +!ec + +!split +===== Choose cost function and optimizer ===== + +To measure how well our neural network is doing we need to introduce a cost function. +We will call the function that gives the error of a single sample output the *loss* function, and the function +that gives the total error of our network across all samples the *cost* function. +A typical choice for multiclass classification is the *cross-entropy* loss, also known as the negative log likelihood. + +In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: + +$$ y = 5 \quad \rightarrow \quad \bm{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$$ + + +$$ y = 1 \quad \rightarrow \quad \bm{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$$ + + +i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset. + +Let $y_{ic}$ denote the $c$-th component of the $i$-th one-hot vector. +We define the cost function $\mathcal{C}$ as a sum over the cross-entropy loss for each point $\bm{x}_i$ in the dataset. + +In the one-hot representation only one of the terms in the loss function is non-zero, namely the +probability of the correct category $c'$ +(i.e. the category $c'$ such that $y_{ic'} = 1$). This means that the cross entropy loss only punishes you for how wrong +you got the correct label. The probability of category $c$ is given by the softmax function. The vector $\bm{\theta}$ represents the parameters of our network, i.e. all the weights and biases. + + +!split +===== Optimizing the cost function ===== + +The network is trained by finding the weights and biases that minimize the cost function. One of the most widely used classes of methods is *gradient descent* and its generalizations. The idea behind gradient descent +is simply to adjust the weights in the direction where the gradient of the cost function is large and negative. This ensures we flow toward a *local* minimum of the cost function. +Each parameter $\theta$ is iteratively adjusted according to the rule + +$$ \theta_{i+1} = \theta_i - \eta \nabla \mathcal{C}(\theta_i) ,$$ + +where $\eta$ is known as the *learning rate*, which controls how big a step we take towards the minimum. +This update can be repeated for any number of iterations, or until we are satisfied with the result. + +A simple and effective improvement is a variant called *Batch Gradient Descent*. +Instead of calculating the gradient on the whole dataset, we calculate an approximation of the gradient +on a subset of the data called a *minibatch*. +If there are $N$ data points and we have a minibatch size of $M$, the total number of batches +is $N/M$. +We denote each minibatch $B_k$, with $k = 1, 2,...,N/M$. The gradient then becomes: + +$$ \nabla \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \nabla \mathcal{L}_i(\theta) \quad \rightarrow \quad +\frac{1}{M} \sum_{i \in B_k} \nabla \mathcal{L}_i(\theta) ,$$ + +i.e. instead of averaging the loss over the entire dataset, we average over a minibatch. + +This has two important benefits: +o Introducing stochasticity decreases the chance that the algorithm becomes stuck in a local minima. +o It significantly speeds up the calculation, since we do not have to use the entire dataset to calculate the gradient. + +The various optmization methods, with codes and algorithms, are discussed in our lectures on "Gradient descent approaches":"https://compphysics.github.io/MachineLearning/doc/pub/Splines/html/Splines-bs.html". + +!split +===== Regularization ===== + +It is common to add an extra term to the cost function, proportional +to the size of the weights. This is equivalent to constraining the +size of the weights, so that they do not grow out of control. +Constraining the size of the weights means that the weights cannot +grow arbitrarily large to fit the training data, and in this way +reduces *overfitting*. + +We will measure the size of the weights using the so called *L2-norm*, meaning our cost function becomes: + +$$ \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) \quad \rightarrow \quad +\frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) + \lambda \lvert \lvert \bm{w} \rvert \rvert_2^2 += \frac{1}{N} \sum_{i=1}^N \mathcal{L}(\theta) + \lambda \sum_{ij} w_{ij}^2,$$ + +i.e. we sum up all the weights squared. The factor $\lambda$ is known as a regularization parameter. + + +In order to train the model, we need to calculate the derivative of +the cost function with respect to every bias and weight in the +network. In total our network has $(64 + 1)\times 50=3250$ weights in +the hidden layer and $(50 + 1)\times 10=510$ weights to the output +layer ($+1$ for the bias), and the gradient must be calculated for +every parameter. We use the *backpropagation* algorithm discussed +above. This is a clever use of the chain rule that allows us to +calculate the gradient efficently. + + +!split +===== Matrix multiplication ===== + +To more efficently train our network these equations are implemented using matrix operations. +The error in the output layer is calculated simply as, with $\bm{t}$ being our targets, + +$$ \delta_L = \bm{t} - \bm{y} = (n_{inputs}, n_{categories}) .$$ + +The gradient for the output weights is calculated as + +$$ \nabla W_{L} = \bm{a}^T \delta_L = (n_{hidden}, n_{categories}) ,$$ + +where $\bm{a} = (n_{inputs}, n_{hidden})$. This simply means that we are summing up the gradients for each input. +Since we are going backwards we have to transpose the activation matrix. + +The gradient with respect to the output bias is then + +$$ \nabla \bm{b}_{L} = \sum_{i=1}^{n_{inputs}} \delta_L = (n_{categories}) .$$ + +The error in the hidden layer is + +$$ \Delta_h = \delta_L W_{L}^T \circ f'(z_{h}) = \delta_L W_{L}^T \circ a_{h} \circ (1 - a_{h}) = (n_{inputs}, n_{hidden}) ,$$ + +where $f'(a_{h})$ is the derivative of the activation in the hidden layer. The matrix products mean +that we are summing up the products for each neuron in the output layer. The symbol $\circ$ denotes +the *Hadamard product*, meaning element-wise multiplication. + +This again gives us the gradients in the hidden layer: + +$$ \nabla W_{h} = X^T \delta_h = (n_{features}, n_{hidden}) ,$$ + +$$ \nabla b_{h} = \sum_{i=1}^{n_{inputs}} \delta_h = (n_{hidden}) .$$ + + +!bc pycod +# to categorical turns our integer vector into a onehot representation +from sklearn.metrics import accuracy_score + +# one-hot in numpy +def to_categorical_numpy(integer_vector): + n_inputs = len(integer_vector) + n_categories = np.max(integer_vector) + 1 + onehot_vector = np.zeros((n_inputs, n_categories)) + onehot_vector[range(n_inputs), integer_vector] = 1 + + return onehot_vector + +#Y_train_onehot, Y_test_onehot = to_categorical(Y_train), to_categorical(Y_test) +Y_train_onehot, Y_test_onehot = to_categorical_numpy(Y_train), to_categorical_numpy(Y_test) + +def feed_forward_train(X): + # weighted sum of inputs to the hidden layer + z_h = np.matmul(X, hidden_weights) + hidden_bias + # activation in the hidden layer + a_h = sigmoid(z_h) + + # weighted sum of inputs to the output layer + z_o = np.matmul(a_h, output_weights) + output_bias + # softmax output + # axis 0 holds each input and axis 1 the probabilities of each category + exp_term = np.exp(z_o) + probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) + + # for backpropagation need activations in hidden and output layers + return a_h, probabilities + +def backpropagation(X, Y): + a_h, probabilities = feed_forward_train(X) + + # error in the output layer + error_output = probabilities - Y + # error in the hidden layer + error_hidden = np.matmul(error_output, output_weights.T) * a_h * (1 - a_h) + + # gradients for the output layer + output_weights_gradient = np.matmul(a_h.T, error_output) + output_bias_gradient = np.sum(error_output, axis=0) + + # gradient for the hidden layer + hidden_weights_gradient = np.matmul(X.T, error_hidden) + hidden_bias_gradient = np.sum(error_hidden, axis=0) + + return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient + +print("Old accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train))) + +eta = 0.01 +lmbd = 0.01 +for i in range(1000): + # calculate gradients + dWo, dBo, dWh, dBh = backpropagation(X_train, Y_train_onehot) + + # regularization term gradients + dWo += lmbd * output_weights + dWh += lmbd * hidden_weights + + # update weights and biases + output_weights -= eta * dWo + output_bias -= eta * dBo + hidden_weights -= eta * dWh + hidden_bias -= eta * dBh + +print("New accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train))) +!ec + +!split +===== Improving performance ===== + +As we can see the network does not seem to be learning at all. It seems to be just guessing the label for each image. +In order to obtain a network that does something useful, we will have to do a bit more work. + +The choice of *hyperparameters* such as learning rate and regularization parameter is hugely influential for the performance of the network. Typically a *grid-search* is performed, wherein we test different hyperparameters separated by orders of magnitude. For example we could test the learning rates $\eta = 10^{-6}, 10^{-5},...,10^{-1}$ with different regularization parameters $\lambda = 10^{-6},...,10^{-0}$. + +Next, we haven't implemented minibatching yet, which introduces stochasticity and is though to act as an important regularizer on the weights. We call a feed-forward + backward pass with a minibatch an *iteration*, and a full training period +going through the entire dataset ($n/M$ batches) an *epoch*. + +If this does not improve network performance, you may want to consider altering the network architecture, adding more neurons or hidden layers. +Andrew Ng goes through some of these considerations in this "video":"https://youtu.be/F1ka6a13S9I". You can find a summary of the video "here":"https://kevinzakka.github.io/2016/09/26/applying-deep-learning/". + +!split +===== Full object-oriented implementation ===== + +It is very natural to think of the network as an object, with specific instances of the network +being realizations of this object with different hyperparameters. An implementation using Python classes provides a clean structure and interface, and the full implementation of our neural network is given below. + + +!bc pycod +class NeuralNetwork: + def __init__( + self, + X_data, + Y_data, + n_hidden_neurons=50, + n_categories=10, + epochs=10, + batch_size=100, + eta=0.1, + lmbd=0.0): + + self.X_data_full = X_data + self.Y_data_full = Y_data + + self.n_inputs = X_data.shape[0] + self.n_features = X_data.shape[1] + self.n_hidden_neurons = n_hidden_neurons + self.n_categories = n_categories + + self.epochs = epochs + self.batch_size = batch_size + self.iterations = self.n_inputs // self.batch_size + self.eta = eta + self.lmbd = lmbd + + self.create_biases_and_weights() + + def create_biases_and_weights(self): + self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons) + self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01 + + self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories) + self.output_bias = np.zeros(self.n_categories) + 0.01 + + def feed_forward(self): + # feed-forward for training + self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias + self.a_h = sigmoid(self.z_h) + + self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias + + exp_term = np.exp(self.z_o) + self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) + + def feed_forward_out(self, X): + # feed-forward for output + z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias + a_h = sigmoid(z_h) + + z_o = np.matmul(a_h, self.output_weights) + self.output_bias + + exp_term = np.exp(z_o) + probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) + return probabilities + + def backpropagation(self): + error_output = self.probabilities - self.Y_data + error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h) + + self.output_weights_gradient = np.matmul(self.a_h.T, error_output) + self.output_bias_gradient = np.sum(error_output, axis=0) + + self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden) + self.hidden_bias_gradient = np.sum(error_hidden, axis=0) + + if self.lmbd > 0.0: + self.output_weights_gradient += self.lmbd * self.output_weights + self.hidden_weights_gradient += self.lmbd * self.hidden_weights + + self.output_weights -= self.eta * self.output_weights_gradient + self.output_bias -= self.eta * self.output_bias_gradient + self.hidden_weights -= self.eta * self.hidden_weights_gradient + self.hidden_bias -= self.eta * self.hidden_bias_gradient + + def predict(self, X): + probabilities = self.feed_forward_out(X) + return np.argmax(probabilities, axis=1) + + def predict_probabilities(self, X): + probabilities = self.feed_forward_out(X) + return probabilities + + def train(self): + data_indices = np.arange(self.n_inputs) + + for i in range(self.epochs): + for j in range(self.iterations): + # pick datapoints with replacement + chosen_datapoints = np.random.choice( + data_indices, size=self.batch_size, replace=False + ) + + # minibatch training data + self.X_data = self.X_data_full[chosen_datapoints] + self.Y_data = self.Y_data_full[chosen_datapoints] + + self.feed_forward() + self.backpropagation() +!ec + +!split +===== Evaluate model performance on test data ===== + +To measure the performance of our network we evaluate how well it does it data it has never seen before, i.e. the test data. +We measure the performance of the network using the *accuracy* score. +The accuracy is as you would expect just the number of images correctly labeled divided by the total number of images. A perfect classifier will have an accuracy score of $1$. + +$$ \text{Accuracy} = \frac{\sum_{i=1}^n I(\tilde{y}_i = y_i)}{n} ,$$ + +where $I$ is the indicator function, $1$ if $\tilde{y}_i = y_i$ and $0$ otherwise. + + +!bc pycod +epochs = 100 +batch_size = 100 + +dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size, + n_hidden_neurons=n_hidden_neurons, n_categories=n_categories) +dnn.train() +test_predict = dnn.predict(X_test) + +# accuracy score from scikit library +print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict)) + +# equivalent in numpy +def accuracy_score_numpy(Y_test, Y_pred): + return np.sum(Y_test == Y_pred) / len(Y_test) + +#print("Accuracy score on test set: ", accuracy_score_numpy(Y_test, test_predict)) +!ec + +!split +===== Adjust hyperparameters ===== + +We now perform a grid search to find the optimal hyperparameters for the network. +Note that we are only using 1 layer with 50 neurons, and human performance is estimated to be around $98\%$ ($2\%$ error rate). + +!bc pycod +eta_vals = np.logspace(-5, 1, 7) +lmbd_vals = np.logspace(-5, 1, 7) +# store the models for later use +DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) + +# grid search +for i, eta in enumerate(eta_vals): + for j, lmbd in enumerate(lmbd_vals): + dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size, + n_hidden_neurons=n_hidden_neurons, n_categories=n_categories) + dnn.train() + + DNN_numpy[i][j] = dnn + + test_predict = dnn.predict(X_test) + + print("Learning rate = ", eta) + print("Lambda = ", lmbd) + print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict)) + print() +!ec + +!split +===== Visualization ===== + +!bc pycod +# visual representation of grid search +# uses seaborn heatmap, you can also do this with matplotlib imshow +import seaborn as sns + +sns.set() + +train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) + +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + dnn = DNN_numpy[i][j] + + train_pred = dnn.predict(X_train) + test_pred = dnn.predict(X_test) + + train_accuracy[i][j] = accuracy_score(Y_train, train_pred) + test_accuracy[i][j] = accuracy_score(Y_test, test_pred) + + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Training Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() +!ec + +!split +===== scikit-learn implementation ===== + +_scikit-learn_ focuses more +on traditional machine learning methods, such as regression, +clustering, decision trees, etc. As such, it has only two types of +neural networks: Multi Layer Perceptron outputting continuous values, +*MPLRegressor*, and Multi Layer Perceptron outputting labels, +*MLPClassifier*. We will see how simple it is to use these classes. + +_scikit-learn_ implements a few improvements from our neural network, +such as early stopping, a varying learning rate, different +optimization methods, etc. We would therefore expect a better +performance overall. + +!bc pycod +from sklearn.neural_network import MLPClassifier +# store models for later use +DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) + +for i, eta in enumerate(eta_vals): + for j, lmbd in enumerate(lmbd_vals): + dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic', + alpha=lmbd, learning_rate_init=eta, max_iter=epochs) + dnn.fit(X_train, Y_train) + + DNN_scikit[i][j] = dnn + + print("Learning rate = ", eta) + print("Lambda = ", lmbd) + print("Accuracy score on test set: ", dnn.score(X_test, Y_test)) + print() +!ec + + +!split +===== Visualization ===== +!bc pycod +# optional +# visual representation of grid search +# uses seaborn heatmap, could probably do this in matplotlib +import seaborn as sns + +sns.set() + +train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) + +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + dnn = DNN_scikit[i][j] + + train_pred = dnn.predict(X_train) + test_pred = dnn.predict(X_test) + + train_accuracy[i][j] = accuracy_score(Y_train, train_pred) + test_accuracy[i][j] = accuracy_score(Y_test, test_pred) + + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Training Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() +!ec + + + + + + + + + +!split +===== Building neural networks in Tensorflow and Keras ===== + +Now we want to build on the experience gained from our neural network implementation in NumPy and scikit-learn +and use it to construct a neural network in Tensorflow. Once we have constructed a neural network in NumPy +and Tensorflow, building one in Keras is really quite trivial, though the performance may suffer. + +In our previous example we used only one hidden layer, and in this we will use two. From this it should be quite +clear how to build one using an arbitrary number of hidden layers, using data structures such as Python lists or +NumPy arrays. + +!split +===== Tensorflow ===== + +Tensorflow is an open source library machine learning library +developed by the Google Brain team for internal use. It was released +under the Apache 2.0 open source license in November 9, 2015. + +Tensorflow is a computational framework that allows you to construct +machine learning models at different levels of abstraction, from +high-level, object-oriented APIs like Keras, down to the C++ kernels +that Tensorflow is built upon. The higher levels of abstraction are +simpler to use, but less flexible, and our choice of implementation +should reflect the problems we are trying to solve. + +"Tensorflow uses":"https://www.tensorflow.org/guide/graphs" so-called graphs to represent your computation +in terms of the dependencies between individual operations, such that you first build a Tensorflow *graph* +to represent your model, and then create a Tensorflow *session* to run the graph. + +In this guide we will analyze the same data as we did in our NumPy and +scikit-learn tutorial, gathered from the MNIST database of images. We +will give an introduction to the lower level Python Application +Program Interfaces (APIs), and see how we use them to build our graph. +Then we will build (effectively) the same graph in Keras, to see just +how simple solving a machine learning problem can be. + +To install tensorflow on Unix/Linux systems, use pip as +!bc pycod +pip3 install tensorflow +!ec +and/or if you use _anaconda_, just write (or install from the graphical user interface) +(current release of CPU-only TensorFlow) +!bc pycod +conda create -n tf tensorflow +conda activate tf +!ec +To install the current release of GPU TensorFlow +!bc pycod +conda create -n tf-gpu tensorflow-gpu +conda activate tf-gpu +!ec + +!split +===== Using Keras ===== + +Keras is a high level "neural network":"https://en.wikipedia.org/wiki/Application_programming_interface" +that supports Tensorflow, CTNK and Theano as backends. +If you have Anaconda installed you may run the following command +!bc pycod +conda install keras +!ec +You can look up the "instructions here":"https://keras.io/" for more information. + +We will to a large extent use _keras_ in this course. + +!split +===== Collect and pre-process data ===== + +Let us look again at the MINST data set. + +!bc pycod +# import necessary packages +import numpy as np +import matplotlib.pyplot as plt +import tensorflow as tf +from sklearn import datasets + + +# ensure the same random numbers appear every time +np.random.seed(0) + +# display images in notebook +%matplotlib inline +plt.rcParams['figure.figsize'] = (12,12) + + +# download MNIST dataset +digits = datasets.load_digits() + +# define inputs and labels +inputs = digits.images +labels = digits.target + +print("inputs = (n_inputs, pixel_width, pixel_height) = " + str(inputs.shape)) +print("labels = (n_inputs) = " + str(labels.shape)) + + +# flatten the image +# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64 +n_inputs = len(inputs) +inputs = inputs.reshape(n_inputs, -1) +print("X = (n_inputs, n_features) = " + str(inputs.shape)) + + +# choose some random images to display +indices = np.arange(n_inputs) +random_indices = np.random.choice(indices, size=5) + +for i, image in enumerate(digits.images[random_indices]): + plt.subplot(1, 5, i+1) + plt.axis('off') + plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest') + plt.title("Label: %d" % digits.target[random_indices[i]]) +plt.show() +!ec + +!bc pycod +from tensorflow.keras.layers import Input +from tensorflow.keras.models import Sequential #This allows appending layers to existing models +from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer +from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop) +from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2) +from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function + +from sklearn.model_selection import train_test_split + +# one-hot representation of labels +labels = to_categorical(labels) + +# split into train and test data +train_size = 0.8 +test_size = 1 - train_size +X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size, + test_size=test_size) +!ec + + + +!bc pycod + +epochs = 100 +batch_size = 100 +n_neurons_layer1 = 100 +n_neurons_layer2 = 50 +n_categories = 10 +eta_vals = np.logspace(-5, 1, 7) +lmbd_vals = np.logspace(-5, 1, 7) +def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd): + model = Sequential() + model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd))) + model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd))) + model.add(Dense(n_categories, activation='softmax')) + + sgd = optimizers.SGD(learning_rate=eta) + model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy']) + + return model +!ec + +!bc pycod +DNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) + +for i, eta in enumerate(eta_vals): + for j, lmbd in enumerate(lmbd_vals): + DNN = create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, + eta=eta, lmbd=lmbd) + DNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0) + scores = DNN.evaluate(X_test, Y_test) + + DNN_keras[i][j] = DNN + + print("Learning rate = ", eta) + print("Lambda = ", lmbd) + print("Test accuracy: %.3f" % scores[1]) + print() +!ec + + + +!bc pycod +# optional +# visual representation of grid search +# uses seaborn heatmap, could probably do this in matplotlib +import seaborn as sns + +sns.set() + +train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) + +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + DNN = DNN_keras[i][j] + + train_accuracy[i][j] = DNN.evaluate(X_train, Y_train)[1] + test_accuracy[i][j] = DNN.evaluate(X_test, Y_test)[1] + + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Training Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() +!ec + + + +!split +===== The Breast Cancer Data, now with Keras ===== + +!bc pycod + +import tensorflow as tf +from tensorflow.keras.layers import Input +from tensorflow.keras.models import Sequential #This allows appending layers to existing models +from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer +from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop) +from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2) +from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function +import numpy as np +import matplotlib.pyplot as plt +import seaborn as sns +from sklearn.model_selection import train_test_split as splitter +from sklearn.datasets import load_breast_cancer +import pickle +import os + + +"""Load breast cancer dataset""" + +np.random.seed(0) #create same seed for random number every time + +cancer=load_breast_cancer() #Download breast cancer dataset + +inputs=cancer.data #Feature matrix of 569 rows (samples) and 30 columns (parameters) +outputs=cancer.target #Label array of 569 rows (0 for benign and 1 for malignant) +labels=cancer.feature_names[0:30] + +print('The content of the breast cancer dataset is:') #Print information about the datasets +print(labels) +print('-------------------------') +print("inputs = " + str(inputs.shape)) +print("outputs = " + str(outputs.shape)) +print("labels = "+ str(labels.shape)) + +x=inputs #Reassign the Feature and Label matrices to other variables +y=outputs + +#%% + +# Visualisation of dataset (for correlation analysis) + +plt.figure() +plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral) +plt.xlabel('Mean radius',fontweight='bold') +plt.ylabel('Mean perimeter',fontweight='bold') +plt.show() + +plt.figure() +plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral) +plt.xlabel('Mean compactness',fontweight='bold') +plt.ylabel('Mean concavity',fontweight='bold') +plt.show() + + +plt.figure() +plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral) +plt.xlabel('Mean radius',fontweight='bold') +plt.ylabel('Mean texture',fontweight='bold') +plt.show() + +plt.figure() +plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral) +plt.xlabel('Mean perimeter',fontweight='bold') +plt.ylabel('Mean compactness',fontweight='bold') +plt.show() + + +# Generate training and testing datasets + +#Select features relevant to classification (texture,perimeter,compactness and symmetery) +#and add to input matrix + +temp1=np.reshape(x[:,1],(len(x[:,1]),1)) +temp2=np.reshape(x[:,2],(len(x[:,2]),1)) +X=np.hstack((temp1,temp2)) +temp=np.reshape(x[:,5],(len(x[:,5]),1)) +X=np.hstack((X,temp)) +temp=np.reshape(x[:,8],(len(x[:,8]),1)) +X=np.hstack((X,temp)) + +X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1) #Split datasets into training and testing + +y_train=to_categorical(y_train) #Convert labels to categorical when using categorical cross entropy +y_test=to_categorical(y_test) + +del temp1,temp2,temp + +# %% + +# Define tunable parameters" + +eta=np.logspace(-3,-1,3) #Define vector of learning rates (parameter to SGD optimiser) +lamda=0.01 #Define hyperparameter +n_layers=2 #Define number of hidden layers in the model +n_neuron=np.logspace(0,3,4,dtype=int) #Define number of neurons per layer +epochs=100 #Number of reiterations over the input data +batch_size=100 #Number of samples per gradient update + +# %% + +"""Define function to return Deep Neural Network model""" + +def NN_model(inputsize,n_layers,n_neuron,eta,lamda): + model=Sequential() + for i in range(n_layers): #Run loop to add hidden layers to the model + if (i==0): #First layer requires input dimensions + model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize)) + else: #Subsequent layers are capable of automatic shape inferencing + model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda))) + model.add(Dense(2,activation='softmax')) #2 outputs - ordered and disordered (softmax for prob) + sgd=optimizers.SGD(learning_rate=eta) + model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy']) + return model + + +Train_accuracy=np.zeros((len(n_neuron),len(eta))) #Define matrices to store accuracy scores as a function +Test_accuracy=np.zeros((len(n_neuron),len(eta))) #of learning rate and number of hidden neurons for + +for i in range(len(n_neuron)): #run loops over hidden neurons and learning rates to calculate + for j in range(len(eta)): #accuracy scores + DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda) + DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1) + Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1] + Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1] + + +def plot_data(x,y,data,title=None): + + # plot results + fontsize=16 + + + fig = plt.figure() + ax = fig.add_subplot(111) + cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1) + + cbar=fig.colorbar(cax) + cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize) + cbar.set_ticks([0,.2,.4,0.6,0.8,1.0]) + cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%']) + + # put text on matrix elements + for i, x_val in enumerate(np.arange(len(x))): + for j, y_val in enumerate(np.arange(len(y))): + c = "${0:.1f}\\%$".format( 100*data[j,i]) + ax.text(x_val, y_val, c, va='center', ha='center') + + # convert axis vaues to to string labels + x=[str(i) for i in x] + y=[str(i) for i in y] + + + ax.set_xticklabels(['']+x) + ax.set_yticklabels(['']+y) + + ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize) + ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize) + if title is not None: + ax.set_title(title) + + plt.tight_layout() + + plt.show() + +plot_data(eta,n_neuron,Train_accuracy, 'training') +plot_data(eta,n_neuron,Test_accuracy, 'testing') + +!ec + + + + + +!split +===== Building a neural network code ===== + +Here we present a flexible object oriented codebase +for a feed forward neural network, along with a demonstration of how +to use it. Before we get into the details of the neural network, we +will first present some implementations of various schedulers, cost +functions and activation functions that can be used together with the +neural network. + +The codes here were developed by Eric Reber and Gregor Kajda during spring 2023. + +=== Learning rate methods === + +The code below shows object oriented implementations of the Constant, +Momentum, Adagrad, AdagradMomentum, RMS prop and Adam schedulers. All +of the classes belong to the shared abstract Scheduler class, and +share the update_change() and reset() methods allowing for any of the +schedulers to be seamlessly used during the training stage, as will +later be shown in the fit() method of the neural +network. Update_change() only has one parameter, the gradient +($δ^l_ja^{l−1}_k$), and returns the change which will be subtracted +from the weights. The reset() function takes no parameters, and resets +the desired variables. For Constant and Momentum, reset does nothing. + + +!bc pycod +import autograd.numpy as np + +class Scheduler: + """ + Abstract class for Schedulers + """ + + def __init__(self, eta): + self.eta = eta + + # should be overwritten + def update_change(self, gradient): + raise NotImplementedError + + # overwritten if needed + def reset(self): + pass + + +class Constant(Scheduler): + def __init__(self, eta): + super().__init__(eta) + + def update_change(self, gradient): + return self.eta * gradient + + def reset(self): + pass + + +class Momentum(Scheduler): + def __init__(self, eta: float, momentum: float): + super().__init__(eta) + self.momentum = momentum + self.change = 0 + + def update_change(self, gradient): + self.change = self.momentum * self.change + self.eta * gradient + return self.change + + def reset(self): + pass + + +class Adagrad(Scheduler): + def __init__(self, eta): + super().__init__(eta) + self.G_t = None + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + if self.G_t is None: + self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) + + self.G_t += gradient @ gradient.T + + G_t_inverse = 1 / ( + delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) + ) + return self.eta * gradient * G_t_inverse + + def reset(self): + self.G_t = None + + +class AdagradMomentum(Scheduler): + def __init__(self, eta, momentum): + super().__init__(eta) + self.G_t = None + self.momentum = momentum + self.change = 0 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + if self.G_t is None: + self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) + + self.G_t += gradient @ gradient.T + + G_t_inverse = 1 / ( + delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) + ) + self.change = self.change * self.momentum + self.eta * gradient * G_t_inverse + return self.change + + def reset(self): + self.G_t = None + + +class RMS_prop(Scheduler): + def __init__(self, eta, rho): + super().__init__(eta) + self.rho = rho + self.second = 0.0 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + self.second = self.rho * self.second + (1 - self.rho) * gradient * gradient + return self.eta * gradient / (np.sqrt(self.second + delta)) + + def reset(self): + self.second = 0.0 + + +class Adam(Scheduler): + def __init__(self, eta, rho, rho2): + super().__init__(eta) + self.rho = rho + self.rho2 = rho2 + self.moment = 0 + self.second = 0 + self.n_epochs = 1 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + self.moment = self.rho * self.moment + (1 - self.rho) * gradient + self.second = self.rho2 * self.second + (1 - self.rho2) * gradient * gradient + + moment_corrected = self.moment / (1 - self.rho**self.n_epochs) + second_corrected = self.second / (1 - self.rho2**self.n_epochs) + + return self.eta * moment_corrected / (np.sqrt(second_corrected + delta)) + + def reset(self): + self.n_epochs += 1 + self.moment = 0 + self.second = 0 + +!ec + +=== Usage of the above learning rate schedulers === + +To initalize a scheduler, simply create the object and pass in the +necessary parameters such as the learning rate and the momentum as +shown below. As the Scheduler class is an abstract class it should not +called directly, and will raise an error upon usage. + +!bc pycod +momentum_scheduler = Momentum(eta=1e-3, momentum=0.9) +adam_scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) +!ec + +Here is a small example for how a segment of code using schedulers +could look. Switching out the schedulers is simple. + +!bc pycod +weights = np.ones((3,3)) +print(f"Before scheduler:\n{weights=}") + +epochs = 10 +for e in range(epochs): + gradient = np.random.rand(3, 3) + change = adam_scheduler.update_change(gradient) + weights = weights - change + adam_scheduler.reset() + +print(f"\nAfter scheduler:\n{weights=}") +!ec + + +=== Cost functions === + +Here we discuss cost functions that can be used when creating the +neural network. Every cost function takes the target vector as its +parameter, and returns a function valued only at $x$ such that it may +easily be differentiated. + + +!bc pycod +import autograd.numpy as np + +def CostOLS(target): + + def func(X): + return (1.0 / target.shape[0]) * np.sum((target - X) ** 2) + + return func + + +def CostLogReg(target): + + def func(X): + + return -(1.0 / target.shape[0]) * np.sum( + (target * np.log(X + 10e-10)) + ((1 - target) * np.log(1 - X + 10e-10)) + ) + + return func + + +def CostCrossEntropy(target): + + def func(X): + return -(1.0 / target.size) * np.sum(target * np.log(X + 10e-10)) + + return func +!ec + + +Below we give a short example of how these cost function may be used +to obtain results if you wish to test them out on your own using +AutoGrad's automatics differentiation. + +!bc pycod +from autograd import grad + +target = np.array([[1, 2, 3]]).T +a = np.array([[4, 5, 6]]).T + +cost_func = CostCrossEntropy +cost_func_derivative = grad(cost_func(target)) + +valued_at_a = cost_func_derivative(a) +print(f"Derivative of cost function {cost_func.__name__} valued at a:\n{valued_at_a}") +!ec + + +=== Activation functions === + +Finally, before we look at the neural network, we will look at the +activation functions which can be specified between the hidden layers +and as the output function. Each function can be valued for any given +vector or matrix X, and can be differentiated via derivate(). + +!bc pycod +import autograd.numpy as np +from autograd import elementwise_grad + +def identity(X): + return X + + +def sigmoid(X): + try: + return 1.0 / (1 + np.exp(-X)) + except FloatingPointError: + return np.where(X > np.zeros(X.shape), np.ones(X.shape), np.zeros(X.shape)) + + +def softmax(X): + X = X - np.max(X, axis=-1, keepdims=True) + delta = 10e-10 + return np.exp(X) / (np.sum(np.exp(X), axis=-1, keepdims=True) + delta) + + +def RELU(X): + return np.where(X > np.zeros(X.shape), X, np.zeros(X.shape)) + + +def LRELU(X): + delta = 10e-4 + return np.where(X > np.zeros(X.shape), X, delta * X) + + +def derivate(func): + if func.__name__ == "RELU": + + def func(X): + return np.where(X > 0, 1, 0) + + return func + + elif func.__name__ == "LRELU": + + def func(X): + delta = 10e-4 + return np.where(X > 0, 1, delta) + + return func + + else: + return elementwise_grad(func) +!ec + +Below follows a short demonstration of how to use an activation +function. The derivative of the activation function will be important +when calculating the output delta term during backpropagation. Note +that derivate() can also be used for cost functions for a more +generalized approach. + +!bc pycod +z = np.array([[4, 5, 6]]).T +print(f"Input to activation function:\n{z}") + +act_func = sigmoid +a = act_func(z) +print(f"\nOutput from {act_func.__name__} activation function:\n{a}") + +act_func_derivative = derivate(act_func) +valued_at_z = act_func_derivative(a) +print(f"\nDerivative of {act_func.__name__} activation function valued at z:\n{valued_at_z}") +!ec + +=== The Neural Network === + +Now that we have gotten a good understanding of the implementation of +some important components, we can take a look at an object oriented +implementation of a feed forward neural network. The feed forward +neural network has been implemented as a class named FFNN, which can +be initiated as a regressor or classifier dependant on the choice of +cost function. The FFNN can have any number of input nodes, hidden +layers with any amount of hidden nodes, and any amount of output nodes +meaning it can perform multiclass classification as well as binary +classification and regression problems. Although there is a lot of +code present, it makes for an easy to use and generalizeable interface +for creating many types of neural networks as will be demonstrated +below. + +!bc pycod +import math +import autograd.numpy as np +import sys +import warnings +from autograd import grad, elementwise_grad +from random import random, seed +from copy import deepcopy, copy +from typing import Tuple, Callable +from sklearn.utils import resample + +warnings.simplefilter("error") + + +class FFNN: + """ + Description: + ------------ + Feed Forward Neural Network with interface enabling flexible design of a + nerual networks architecture and the specification of activation function + in the hidden layers and output layer respectively. This model can be used + for both regression and classification problems, depending on the output function. + + Attributes: + ------------ + I dimensions (tuple[int]): A list of positive integers, which specifies the + number of nodes in each of the networks layers. The first integer in the array + defines the number of nodes in the input layer, the second integer defines number + of nodes in the first hidden layer and so on until the last number, which + specifies the number of nodes in the output layer. + II hidden_func (Callable): The activation function for the hidden layers + III output_func (Callable): The activation function for the output layer + IV cost_func (Callable): Our cost function + V seed (int): Sets random seed, makes results reproducible + """ + + def __init__( + self, + dimensions: tuple[int], + hidden_func: Callable = sigmoid, + output_func: Callable = lambda x: x, + cost_func: Callable = CostOLS, + seed: int = None, + ): + self.dimensions = dimensions + self.hidden_func = hidden_func + self.output_func = output_func + self.cost_func = cost_func + self.seed = seed + self.weights = list() + self.schedulers_weight = list() + self.schedulers_bias = list() + self.a_matrices = list() + self.z_matrices = list() + self.classification = None + + self.reset_weights() + self._set_classification() + + def fit( + self, + X: np.ndarray, + t: np.ndarray, + scheduler: Scheduler, + batches: int = 1, + epochs: int = 100, + lam: float = 0, + X_val: np.ndarray = None, + t_val: np.ndarray = None, + ): + """ + Description: + ------------ + This function performs the training the neural network by performing the feedforward and backpropagation + algorithm to update the networks weights. + + Parameters: + ------------ + I X (np.ndarray) : training data + II t (np.ndarray) : target data + III scheduler (Scheduler) : specified scheduler (algorithm for optimization of gradient descent) + IV scheduler_args (list[int]) : list of all arguments necessary for scheduler + + Optional Parameters: + ------------ + V batches (int) : number of batches the datasets are split into, default equal to 1 + VI epochs (int) : number of iterations used to train the network, default equal to 100 + VII lam (float) : regularization hyperparameter lambda + VIII X_val (np.ndarray) : validation set + IX t_val (np.ndarray) : validation target set + + Returns: + ------------ + I scores (dict) : A dictionary containing the performance metrics of the model. + The number of the metrics depends on the parameters passed to the fit-function. + + """ + + # setup + if self.seed is not None: + np.random.seed(self.seed) + + val_set = False + if X_val is not None and t_val is not None: + val_set = True + + # creating arrays for score metrics + train_errors = np.empty(epochs) + train_errors.fill(np.nan) + val_errors = np.empty(epochs) + val_errors.fill(np.nan) + + train_accs = np.empty(epochs) + train_accs.fill(np.nan) + val_accs = np.empty(epochs) + val_accs.fill(np.nan) + + self.schedulers_weight = list() + self.schedulers_bias = list() + + batch_size = X.shape[0] // batches + + X, t = resample(X, t) + + # this function returns a function valued only at X + cost_function_train = self.cost_func(t) + if val_set: + cost_function_val = self.cost_func(t_val) + + # create schedulers for each weight matrix + for i in range(len(self.weights)): + self.schedulers_weight.append(copy(scheduler)) + self.schedulers_bias.append(copy(scheduler)) + + print(f"{scheduler.__class__.__name__}: Eta={scheduler.eta}, Lambda={lam}") + + try: + for e in range(epochs): + for i in range(batches): + # allows for minibatch gradient descent + if i == batches - 1: + # If the for loop has reached the last batch, take all thats left + X_batch = X[i * batch_size :, :] + t_batch = t[i * batch_size :, :] + else: + X_batch = X[i * batch_size : (i + 1) * batch_size, :] + t_batch = t[i * batch_size : (i + 1) * batch_size, :] + + self._feedforward(X_batch) + self._backpropagate(X_batch, t_batch, lam) + + # reset schedulers for each epoch (some schedulers pass in this call) + for scheduler in self.schedulers_weight: + scheduler.reset() + + for scheduler in self.schedulers_bias: + scheduler.reset() + + # computing performance metrics + pred_train = self.predict(X) + train_error = cost_function_train(pred_train) + + train_errors[e] = train_error + if val_set: + + pred_val = self.predict(X_val) + val_error = cost_function_val(pred_val) + val_errors[e] = val_error + + if self.classification: + train_acc = self._accuracy(self.predict(X), t) + train_accs[e] = train_acc + if val_set: + val_acc = self._accuracy(pred_val, t_val) + val_accs[e] = val_acc + + # printing progress bar + progression = e / epochs + print_length = self._progress_bar( + progression, + train_error=train_errors[e], + train_acc=train_accs[e], + val_error=val_errors[e], + val_acc=val_accs[e], + ) + except KeyboardInterrupt: + # allows for stopping training at any point and seeing the result + pass + + # visualization of training progression (similiar to tensorflow progression bar) + sys.stdout.write("\r" + " " * print_length) + sys.stdout.flush() + self._progress_bar( + 1, + train_error=train_errors[e], + train_acc=train_accs[e], + val_error=val_errors[e], + val_acc=val_accs[e], + ) + sys.stdout.write("") + + # return performance metrics for the entire run + scores = dict() + + scores["train_errors"] = train_errors + + if val_set: + scores["val_errors"] = val_errors + + if self.classification: + scores["train_accs"] = train_accs + + if val_set: + scores["val_accs"] = val_accs + + return scores + + def predict(self, X: np.ndarray, *, threshold=0.5): + """ + Description: + ------------ + Performs prediction after training of the network has been finished. + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each + + Optional Parameters: + ------------ + II threshold (float) : sets minimal value for a prediction to be predicted as the positive class + in classification problems + + Returns: + ------------ + I z (np.ndarray): A prediction vector (row) for each row in our design matrix + This vector is thresholded if regression=False, meaning that classification results + in a vector of 1s and 0s, while regressions in an array of decimal numbers + + """ + + predict = self._feedforward(X) + + if self.classification: + return np.where(predict > threshold, 1, 0) + else: + return predict + + def reset_weights(self): + """ + Description: + ------------ + Resets/Reinitializes the weights in order to train the network for a new problem. + + """ + if self.seed is not None: + np.random.seed(self.seed) + + self.weights = list() + for i in range(len(self.dimensions) - 1): + weight_array = np.random.randn( + self.dimensions[i] + 1, self.dimensions[i + 1] + ) + weight_array[0, :] = np.random.randn(self.dimensions[i + 1]) * 0.01 + + self.weights.append(weight_array) + + def _feedforward(self, X: np.ndarray): + """ + Description: + ------------ + Calculates the activation of each layer starting at the input and ending at the output. + Each following activation is calculated from a weighted sum of each of the preceeding + activations (except in the case of the input layer). + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each + + Returns: + ------------ + I z (np.ndarray): A prediction vector (row) for each row in our design matrix + """ + + # reset matrices + self.a_matrices = list() + self.z_matrices = list() + + # if X is just a vector, make it into a matrix + if len(X.shape) == 1: + X = X.reshape((1, X.shape[0])) + + # Add a coloumn of zeros as the first coloumn of the design matrix, in order + # to add bias to our data + bias = np.ones((X.shape[0], 1)) * 0.01 + X = np.hstack([bias, X]) + + # a^0, the nodes in the input layer (one a^0 for each row in X - where the + # exponent indicates layer number). + a = X + self.a_matrices.append(a) + self.z_matrices.append(a) + + # The feed forward algorithm + for i in range(len(self.weights)): + if i < len(self.weights) - 1: + z = a @ self.weights[i] + self.z_matrices.append(z) + a = self.hidden_func(z) + # bias column again added to the data here + bias = np.ones((a.shape[0], 1)) * 0.01 + a = np.hstack([bias, a]) + self.a_matrices.append(a) + else: + try: + # a^L, the nodes in our output layers + z = a @ self.weights[i] + a = self.output_func(z) + self.a_matrices.append(a) + self.z_matrices.append(z) + except Exception as OverflowError: + print( + "OverflowError in fit() in FFNN\nHOW TO DEBUG ERROR: Consider lowering your learning rate or scheduler specific parameters such as momentum, or check if your input values need scaling" + ) + + # this will be a^L + return a + + def _backpropagate(self, X, t, lam): + """ + Description: + ------------ + Performs the backpropagation algorithm. In other words, this method + calculates the gradient of all the layers starting at the + output layer, and moving from right to left accumulates the gradient until + the input layer is reached. Each layers respective weights are updated while + the algorithm propagates backwards from the output layer (auto-differentation in reverse mode). + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each. + II t (np.ndarray): The target vector, with n rows of p targets. + III lam (float32): regularization parameter used to punish the weights in case of overfitting + + Returns: + ------------ + No return value. + + """ + out_derivative = derivate(self.output_func) + hidden_derivative = derivate(self.hidden_func) + + for i in range(len(self.weights) - 1, -1, -1): + # delta terms for output + if i == len(self.weights) - 1: + # for multi-class classification + if ( + self.output_func.__name__ == "softmax" + ): + delta_matrix = self.a_matrices[i + 1] - t + # for single class classification + else: + cost_func_derivative = grad(self.cost_func(t)) + delta_matrix = out_derivative( + self.z_matrices[i + 1] + ) * cost_func_derivative(self.a_matrices[i + 1]) + + # delta terms for hidden layer + else: + delta_matrix = ( + self.weights[i + 1][1:, :] @ delta_matrix.T + ).T * hidden_derivative(self.z_matrices[i + 1]) + + # calculate gradient + gradient_weights = self.a_matrices[i][:, 1:].T @ delta_matrix + gradient_bias = np.sum(delta_matrix, axis=0).reshape( + 1, delta_matrix.shape[1] + ) + + # regularization term + gradient_weights += self.weights[i][1:, :] * lam + + # use scheduler + update_matrix = np.vstack( + [ + self.schedulers_bias[i].update_change(gradient_bias), + self.schedulers_weight[i].update_change(gradient_weights), + ] + ) + + # update weights and bias + self.weights[i] -= update_matrix + + def _accuracy(self, prediction: np.ndarray, target: np.ndarray): + """ + Description: + ------------ + Calculates accuracy of given prediction to target + + Parameters: + ------------ + I prediction (np.ndarray): vector of predicitons output network + (1s and 0s in case of classification, and real numbers in case of regression) + II target (np.ndarray): vector of true values (What the network ideally should predict) + + Returns: + ------------ + A floating point number representing the percentage of correctly classified instances. + """ + assert prediction.size == target.size + return np.average((target == prediction)) + def _set_classification(self): + """ + Description: + ------------ + Decides if FFNN acts as classifier (True) og regressor (False), + sets self.classification during init() + """ + self.classification = False + if ( + self.cost_func.__name__ == "CostLogReg" + or self.cost_func.__name__ == "CostCrossEntropy" + ): + self.classification = True + + def _progress_bar(self, progression, **kwargs): + """ + Description: + ------------ + Displays progress of training + """ + print_length = 40 + num_equals = int(progression * print_length) + num_not = print_length - num_equals + arrow = ">" if num_equals > 0 else "" + bar = "[" + "=" * (num_equals - 1) + arrow + "-" * num_not + "]" + perc_print = self._format(progression * 100, decimals=5) + line = f" {bar} {perc_print}% " + + for key in kwargs: + if not np.isnan(kwargs[key]): + value = self._format(kwargs[key], decimals=4) + line += f"| {key}: {value} " + sys.stdout.write("\r" + line) + sys.stdout.flush() + return len(line) + + def _format(self, value, decimals=4): + """ + Description: + ------------ + Formats decimal numbers for progress bar + """ + if value > 0: + v = value + elif value < 0: + v = -10 * value + else: + v = 1 + n = 1 + math.floor(math.log10(v)) + if n >= decimals - 1: + return str(round(value)) + return f"{value:.{decimals-n-1}f}" +!ec + +Before we make a model, we will quickly generate a dataset we can use +for our linear regression problem as shown below + +!bc pycod +import autograd.numpy as np +from sklearn.model_selection import train_test_split + +def SkrankeFunction(x, y): + return np.ravel(0 + 1*x + 2*y + 3*x**2 + 4*x*y + 5*y**2) + +def create_X(x, y, n): + if len(x.shape) > 1: + x = np.ravel(x) + y = np.ravel(y) + + N = len(x) + l = int((n + 1) * (n + 2) / 2) # Number of elements in beta + X = np.ones((N, l)) + + for i in range(1, n + 1): + q = int((i) * (i + 1) / 2) + for k in range(i + 1): + X[:, q + k] = (x ** (i - k)) * (y**k) + + return X + +step=0.5 +x = np.arange(0, 1, step) +y = np.arange(0, 1, step) +x, y = np.meshgrid(x, y) +target = SkrankeFunction(x, y) +target = target.reshape(target.shape[0], 1) + +poly_degree=3 +X = create_X(x, y, poly_degree) + +X_train, X_test, t_train, t_test = train_test_split(X, target) + +!ec + +Now that we have our dataset ready for the regression, we can create +our regressor. Note that with the seed parameter, we can make sure our +results stay the same every time we run the neural network. For +inititialization, we simply specify the dimensions (we wish the amount +of input nodes to be equal to the datapoints, and the output to +predict one value). + + +!bc pycod +input_nodes = X_train.shape[1] +output_nodes = 1 + +linear_regression = FFNN((input_nodes, output_nodes), output_func=identity, cost_func=CostOLS, seed=2023) + +!ec + +We then fit our model with our training data using the scheduler of our choice. + +!bc pycod +linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Constant(eta=1e-3) +scores = linear_regression.fit(X_train, t_train, scheduler) + + +!ec + +Due to the progress bar we can see the MSE (train_error) throughout +the FFNN's training. Note that the fit() function has some optional +parameters with defualt arguments. For example, the regularization +hyperparameter can be left ignored if not needed, and equally the FFNN +will by default run for 100 epochs. These can easily be changed, such +as for example: + +!bc pycod +linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scores = linear_regression.fit(X_train, t_train, scheduler, lam=1e-4, epochs=1000) + +!ec + +We see that given more epochs to train on, the regressor reaches a lower MSE. + +Let us then switch to a binary classification. We use a binary +classification dataset, and follow a similar setup to the regression +case. + + + +!bc pycod +from sklearn.datasets import load_breast_cancer +from sklearn.preprocessing import MinMaxScaler + +wisconsin = load_breast_cancer() +X = wisconsin.data +target = wisconsin.target +target = target.reshape(target.shape[0], 1) + +X_train, X_val, t_train, t_val = train_test_split(X, target) + +scaler = MinMaxScaler() +scaler.fit(X_train) +X_train = scaler.transform(X_train) +X_val = scaler.transform(X_val) + + +!ec + +!bc pycod +input_nodes = X_train.shape[1] +output_nodes = 1 + +logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) + +!ec + +We will now make use of our validation data by passing it into our fit function as a keyword argument + +!bc pycod +logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) +scores = logistic_regression.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) + + +!ec + +Finally, we will create a neural network with 2 hidden layers with activation functions. +!bc pycod +input_nodes = X_train.shape[1] +hidden_nodes1 = 100 +hidden_nodes2 = 30 +output_nodes = 1 + +dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) + +neural_network = FFNN(dims, hidden_func=RELU, output_func=sigmoid, cost_func=CostLogReg, seed=2023) + + +!ec + +!bc pycod +neural_network.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) +scores = neural_network.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) + +!ec + +=== Multiclass classification === + +Finally, we will demonstrate the use case of multiclass classification +using our FFNN with the famous MNIST dataset, which contain images of +digits between the range of 0 to 9. + + +!bc pycod +from sklearn.datasets import load_digits + +def onehot(target: np.ndarray): + onehot = np.zeros((target.size, target.max() + 1)) + onehot[np.arange(target.size), target] = 1 + return onehot + +digits = load_digits() + +X = digits.data +target = digits.target +target = onehot(target) + +input_nodes = 64 +hidden_nodes1 = 100 +hidden_nodes2 = 30 +output_nodes = 10 + +dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) + +multiclass = FFNN(dims, hidden_func=LRELU, output_func=softmax, cost_func=CostCrossEntropy) + +multiclass.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) +scores = multiclass.fit(X, target, scheduler, epochs=1000) + +!ec + + + +!split +===== Testing the XOR gate and other gates ===== + +Let us now use our code to test the XOR gate. + +!bc pycod +X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) + +# The XOR gate +yXOR = np.array( [[ 0], [1] ,[1], [0]]) + +input_nodes = X.shape[1] +output_nodes = 1 + +logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) +logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights +scheduler = Adam(eta=1e-1, rho=0.9, rho2=0.999) +scores = logistic_regression.fit(X, yXOR, scheduler, epochs=1000) +!ec +Not bad, but the results depend strongly on the learning reate. Try different learning rates. + + + + + + +!split +===== Solving differential equations with Deep Learning ===== + +!bblock +The Universal Approximation Theorem states that a neural network can +approximate any function at a single hidden layer along with one input +and output layer to any given precision. +!eblock + +!bblock Book on solving differential equations with ML methods +"An Introduction to Neural Network Methods for Differential Equations":"https://www.springer.com/gp/book/9789401798150", by Yadav and Kumar. +!eblock + +!bblock Physics informed neural networks +"Scientific Machine Learning Through Physics–Informed Neural Networks: Where we are and What’s Next":"https://link.springer.com/article/10.1007/s10915-022-01939-z", by Cuomo et al +!eblock + + + +!bblock Thanks to Kristine Baluka Hein +The lectures on differential equations were developed by Kristine Baluka Hein, now PhD student at IFI. +A great thanks to Kristine. +!eblock + +!split +===== Ordinary Differential Equations first ===== + +An ordinary differential equation (ODE) is an equation involving functions having one variable. + +In general, an ordinary differential equation looks like + +!bt +\begin{equation} \label{ode} +f\left(x, \, g(x), \, g'(x), \, g''(x), \, \dots \, , \, g^{(n)}(x)\right) = 0 +\end{equation} +!et + +where $g(x)$ is the function to find, and $g^{(n)}(x)$ is the $n$-th derivative of $g(x)$. + +The $f\left(x, g(x), g'(x), g''(x), \, \dots \, , g^{(n)}(x)\right)$ is just a way to write that there is an expression involving $x$ and $g(x), \ g'(x), \ g''(x), \, \dots \, , \text{ and } g^{(n)}(x)$ on the left side of the equality sign in (ref{ode}). +The highest order of derivative, that is the value of $n$, determines to the order of the equation. +The equation is referred to as a $n$-th order ODE. +Along with (ref{ode}), some additional conditions of the function $g(x)$ are typically given +for the solution to be unique. + +!split +===== The trial solution ===== + +Let the trial solution $g_t(x)$ be + +!bt +\begin{equation} + g_t(x) = h_1(x) + h_2(x,N(x,P)) +\end{equation} +!et + + +where $h_1(x)$ is a function that makes $g_t(x)$ satisfy a given set +of conditions, $N(x,P)$ a neural network with weights and biases +described by $P$ and $h_2(x, N(x,P))$ some expression involving the +neural network. The role of the function $h_2(x, N(x,P))$, is to +ensure that the output from $N(x,P)$ is zero when $g_t(x)$ is +evaluated at the values of $x$ where the given conditions must be +satisfied. The function $h_1(x)$ should alone make $g_t(x)$ satisfy +the conditions. + +But what about the network $N(x,P)$? + + +As described previously, an optimization method could be used to minimize the parameters of a neural network, that being its weights and biases, through backward propagation. + + +!split +===== Minimization process ===== + +For the minimization to be defined, we need to have a cost function at hand to minimize. + +It is given that $f\left(x, \, g(x), \, g'(x), \, g''(x), \, \dots \, , \, g^{(n)}(x)\right)$ should be equal to zero in (ref{ode}). +We can choose to consider the mean squared error as the cost function for an input $x$. +Since we are looking at one input, the cost function is just $f$ squared. +The cost function $c\left(x, P \right)$ can therefore be expressed as + +!bt +C\left(x, P\right) = \big(f\left(x, \, g(x), \, g'(x), \, g''(x), \, \dots \, , \, g^{(n)}(x)\right)\big)^2 +!et + +If $N$ inputs are given as a vector $\bm{x}$ with elements $x_i$ for $i = 1,\dots,N$, +the cost function becomes + +!bt +\begin{equation} \label{cost} + C\left(\bm{x}, P\right) = \frac{1}{N} \sum_{i=1}^N \big(f\left(x_i, \, g(x_i), \, g'(x_i), \, g''(x_i), \, \dots \, , \, g^{(n)}(x_i)\right)\big)^2 +\end{equation} +!et + +The neural net should then find the parameters $P$ that minimizes the cost function in +(ref{cost}) for a set of $N$ training samples $x_i$. + +!split +===== Minimizing the cost function using gradient descent and automatic differentiation ===== + +To perform the minimization using gradient descent, the gradient of $C\left(\bm{x}, P\right)$ is needed. +It might happen so that finding an analytical expression of the gradient of $C(\bm{x}, P)$ from (ref{cost}) gets too messy, depending on which cost function one desires to use. + +Luckily, there exists libraries that makes the job for us through automatic differentiation. +Automatic differentiation is a method of finding the derivatives numerically with very high precision. + + +!split +===== Example: Exponential decay ===== + +An exponential decay of a quantity $g(x)$ is described by the equation + +!bt +\begin{equation} \label{solve_expdec} + g'(x) = -\gamma g(x) +\end{equation} +!et + +with $g(0) = g_0$ for some chosen initial value $g_0$. + +The analytical solution of (ref{solve_expdec}) is + +!bt +\begin{equation} + g(x) = g_0 \exp\left(-\gamma x\right) +\end{equation} +!et + +Having an analytical solution at hand, it is possible to use it to compare how well a neural network finds a solution of (ref{solve_expdec}). + + +!split +===== The function to solve for ===== + +The program will use a neural network to solve + +!bt +\begin{equation} \label{solveode} +g'(x) = -\gamma g(x) +\end{equation} +!et + +where $g(0) = g_0$ with $\gamma$ and $g_0$ being some chosen values. + +In this example, $\gamma = 2$ and $g_0 = 10$. + +!split +===== The trial solution ===== +To begin with, a trial solution $g_t(t)$ must be chosen. A general trial solution for ordinary differential equations could be + +!bt +g_t(x, P) = h_1(x) + h_2(x, N(x, P)) +!et + +with $h_1(x)$ ensuring that $g_t(x)$ satisfies some conditions and $h_2(x,N(x, P))$ an expression involving $x$ and the output from the neural network $N(x,P)$ with $P $ being the collection of the weights and biases for each layer. For now, it is assumed that the network consists of one input layer, one hidden layer, and one output layer. + +!split +===== Setup of Network ===== + +In this network, there are no weights and bias at the input layer, so $P = \{ P_{\text{hidden}}, P_{\text{output}} \}$. +If there are $N_{\text{hidden} }$ neurons in the hidden layer, then $P_{\text{hidden}}$ is a $N_{\text{hidden} } \times (1 + N_{\text{input}})$ matrix, given that there are $N_{\text{input}}$ neurons in the input layer. + +The first column in $P_{\text{hidden} }$ represents the bias for each neuron in the hidden layer and the second column represents the weights for each neuron in the hidden layer from the input layer. +If there are $N_{\text{output} }$ neurons in the output layer, then $P_{\text{output}} $ is a $N_{\text{output} } \times (1 + N_{\text{hidden} })$ matrix. + +Its first column represents the bias of each neuron and the remaining columns represents the weights to each neuron. + +It is given that $g(0) = g_0$. The trial solution must fulfill this condition to be a proper solution of (ref{solveode}). A possible way to ensure that $g_t(0, P) = g_0$, is to let $F(N(x,P)) = x \cdot N(x,P)$ and $A(x) = g_0$. This gives the following trial solution: + +!bt +\begin{equation} \label{trial} +g_t(x, P) = g_0 + x \cdot N(x, P) +\end{equation} +!et + +!split +===== Reformulating the problem ===== + +We wish that our neural network manages to minimize a given cost function. + +A reformulation of out equation, (ref{solveode}), must therefore be done, +such that it describes the problem a neural network can solve for. + +The neural network must find the set of weights and biases $P$ such that the trial solution in (ref{trial}) satisfies (ref{solveode}). + +The trial solution + +!bt +g_t(x, P) = g_0 + x \cdot N(x, P) +!et + +has been chosen such that it already solves the condition $g(0) = g_0$. What remains, is to find $P$ such that + +!bt +\begin{equation} \label{nnmin} +g_t'(x, P) = - \gamma g_t(x, P) +\end{equation} +!et + +is fulfilled as *best as possible*. + +!split +===== More technicalities ===== + +The left hand side and right hand side of (ref{nnmin}) must be computed separately, and then the neural network must choose weights and biases, contained in $P$, such that the sides are equal as best as possible. +This means that the absolute or squared difference between the sides must be as close to zero, ideally equal to zero. +In this case, the difference squared shows to be an appropriate measurement of how erroneous the trial solution is with respect to $P$ of the neural network. + +This gives the following cost function our neural network must solve for: + +!bt +\min_{P}\Big\{ \big(g_t'(x, P) - ( -\gamma g_t(x, P) \big)^2 \Big\} +!et + +(the notation $\min_{P}\{ f(x, P) \}$ means that we desire to find $P$ that yields the minimum of $f(x, P)$) + +or, in terms of weights and biases for the hidden and output layer in our network: + +!bt +\min_{P_{\text{hidden} }, \ P_{\text{output} }}\Big\{ \big(g_t'(x, \{ P_{\text{hidden} }, P_{\text{output} }\}) - ( -\gamma g_t(x, \{ P_{\text{hidden} }, P_{\text{output} }\}) \big)^2 \Big\} +!et + +for an input value $x$. + +!split +===== More details ===== + +If the neural network evaluates $g_t(x, P)$ at more values for $x$, say $N$ values $x_i$ for $i = 1, \dots, N$, then the *total* error to minimize becomes + +!bt +\begin{equation} \label{min} +\min_{P}\Big\{\frac{1}{N} \sum_{i=1}^N \big(g_t'(x_i, P) - ( -\gamma g_t(x_i, P) \big)^2 \Big\} +\end{equation} +!et + +Letting $\bm{x}$ be a vector with elements $x_i$ and $C(\bm{x}, P) = \frac{1}{N} \sum_i \big(g_t'(x_i, P) - ( -\gamma g_t(x_i, P) \big)^2$ denote the cost function, the minimization problem that our network must solve, becomes + +!bt +\min_{P} C(\bm{x}, P) +!et + +In terms of $P_{\text{hidden} }$ and $P_{\text{output} }$, this could also be expressed as + +$$ +\min_{P_{\text{hidden} }, \ P_{\text{output} }} C(\bm{x}, \{P_{\text{hidden} }, P_{\text{output} }\}) +$$ + +!split +===== A possible implementation of a neural network ===== + +For simplicity, it is assumed that the input is an array $\bm{x} = (x_1, \dots, x_N)$ with $N$ elements. It is at these points the neural network should find $P$ such that it fulfills (ref{min}). + +First, the neural network must feed forward the inputs. +This means that $\bm{x}s$ must be passed through an input layer, a hidden layer and a output layer. The input layer in this case, does not need to process the data any further. +The input layer will consist of $N_{\text{input} }$ neurons, passing its element to each neuron in the hidden layer. The number of neurons in the hidden layer will be $N_{\text{hidden} }$. + +!split +===== Technicalities ===== + +For the $i$-th in the hidden layer with weight $w_i^{\text{hidden} }$ and bias $b_i^{\text{hidden} }$, the weighting from the $j$-th neuron at the input layer is: + +!bt +\begin{aligned} +z_{i,j}^{\text{hidden}} &= b_i^{\text{hidden}} + w_i^{\text{hidden}}x_j \\ +&= +\begin{pmatrix} +b_i^{\text{hidden}} & w_i^{\text{hidden}} +\end{pmatrix} +\begin{pmatrix} +1 \\ +x_j +\end{pmatrix} +\end{aligned} +!et + +!split +===== Final technicalities I ===== + +The result after weighting the inputs at the $i$-th hidden neuron can be written as a vector: + +!bt +\begin{aligned} +\bm{z}_{i}^{\text{hidden}} &= \Big( b_i^{\text{hidden}} + w_i^{\text{hidden}}x_1 , \ b_i^{\text{hidden}} + w_i^{\text{hidden}} x_2, \ \dots \, , \ b_i^{\text{hidden}} + w_i^{\text{hidden}} x_N\Big) \\ +&= +\begin{pmatrix} + b_i^{\text{hidden}} & w_i^{\text{hidden}} +\end{pmatrix} +\begin{pmatrix} +1 & 1 & \dots & 1 \\ +x_1 & x_2 & \dots & x_N +\end{pmatrix} \\ +&= \bm{p}_{i, \text{hidden}}^T X +\end{aligned} +!et + +!split +===== Final technicalities II ===== + +The vector $\bm{p}_{i, \text{hidden}}^T$ constitutes each row in $P_{\text{hidden} }$, which contains the weights for the neural network to minimize according to (ref{min}). + +After having found $\bm{z}_{i}^{\text{hidden}} $ for every $i$-th neuron within the hidden layer, the vector will be sent to an activation function $a_i(\bm{z})$. + +In this example, the sigmoid function has been chosen to be the activation function for each hidden neuron: + +!bt +f(z) = \frac{1}{1 + \exp{(-z)}} +!et + +It is possible to use other activations functions for the hidden layer also. + +The output $\bm{x}_i^{\text{hidden}}$ from each $i$-th hidden neuron is: + +$$ +\bm{x}_i^{\text{hidden} } = f\big( \bm{z}_{i}^{\text{hidden}} \big) +$$ + +The outputs $\bm{x}_i^{\text{hidden} } $ are then sent to the output layer. + +The output layer consists of one neuron in this case, and combines the +output from each of the neurons in the hidden layers. The output layer +combines the results from the hidden layer using some weights $w_i^{\text{output}}$ +and biases $b_i^{\text{output}}$. In this case, +it is assumes that the number of neurons in the output layer is one. + +!split +===== Final technicalities III ===== + + +The procedure of weighting the output neuron $j$ in the hidden layer to the $i$-th neuron in the output layer is similar as for the hidden layer described previously. + +!bt +\begin{aligned} +z_{1,j}^{\text{output}} & = +\begin{pmatrix} +b_1^{\text{output}} & \bm{w}_1^{\text{output}} +\end{pmatrix} +\begin{pmatrix} +1 \\ +\bm{x}_j^{\text{hidden}} +\end{pmatrix} +\end{aligned} +!et + +!split +===== Final technicalities IV ===== + +Expressing $z_{1,j}^{\text{output}}$ as a vector gives the following way of weighting the inputs from the hidden layer: + +!bt +\bm{z}_{1}^{\text{output}} = +\begin{pmatrix} +b_1^{\text{output}} & \bm{w}_1^{\text{output}} +\end{pmatrix} +\begin{pmatrix} +1 & 1 & \dots & 1 \\ +\bm{x}_1^{\text{hidden}} & \bm{x}_2^{\text{hidden}} & \dots & \bm{x}_N^{\text{hidden}} +\end{pmatrix} +!et + +In this case we seek a continuous range of values since we are approximating a function. This means that after computing $\bm{z}_{1}^{\text{output}}$ the neural network has finished its feed forward step, and $\bm{z}_{1}^{\text{output}}$ is the final output of the network. + +!split +===== Back propagation ===== + +The next step is to decide how the parameters should be changed such that they minimize the cost function. + +The chosen cost function for this problem is + +!bt +C(\bm{x}, P) = \frac{1}{N} \sum_i \big(g_t'(x_i, P) - ( -\gamma g_t(x_i, P) \big)^2 +!et + +In order to minimize the cost function, an optimization method must be chosen. + +Here, gradient descent with a constant step size has been chosen. + +!split +===== Gradient descent ===== + +The idea of the gradient descent algorithm is to update parameters in +a direction where the cost function decreases goes to a minimum. + +In general, the update of some parameters $\bm{\omega}$ given a cost +function defined by some weights $\bm{\omega}$, $C(\bm{x}, +\bm{\omega})$, goes as follows: + +!bt +\bm{\omega}_{\text{new} } = \bm{\omega} - \lambda \nabla_{\bm{\omega}} C(\bm{x}, \bm{\omega}) +!et + +for a number of iterations or until $ \big|\big| \bm{\omega}_{\text{new} } - \bm{\omega} \big|\big|$ becomes smaller than some given tolerance. + +The value of $\lambda$ decides how large steps the algorithm must take +in the direction of $ \nabla_{\bm{\omega}} C(\bm{x}, \bm{\omega})$. +The notation $\nabla_{\bm{\omega}}$ express the gradient with respect +to the elements in $\bm{\omega}$. + +In our case, we have to minimize the cost function $C(\bm{x}, P)$ with +respect to the two sets of weights and biases, that is for the hidden +layer $P_{\text{hidden} }$ and for the output layer $P_{\text{output} +}$ . + +This means that $P_{\text{hidden} }$ and $P_{\text{output} }$ is updated by + +!bt +\begin{aligned} +P_{\text{hidden},\text{new}} &= P_{\text{hidden}} - \lambda \nabla_{P_{\text{hidden}}} C(\bm{x}, P) \\ +P_{\text{output},\text{new}} &= P_{\text{output}} - \lambda \nabla_{P_{\text{output}}} C(\bm{x}, P) +\end{aligned} +!et + +!split +===== The code for solving the ODE ===== + +!bc pycod +import autograd.numpy as np +from autograd import grad, elementwise_grad +import autograd.numpy.random as npr +from matplotlib import pyplot as plt + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +# Assuming one input, hidden, and output layer +def neural_network(params, x): + + # Find the weights (including and biases) for the hidden and output layer. + # Assume that params is a list of parameters for each layer. + # The biases are the first element for each array in params, + # and the weights are the remaning elements in each array in params. + + w_hidden = params[0] + w_output = params[1] + + # Assumes input x being an one-dimensional array + num_values = np.size(x) + x = x.reshape(-1, num_values) + + # Assume that the input layer does nothing to the input x + x_input = x + + ## Hidden layer: + + # Add a row of ones to include bias + x_input = np.concatenate((np.ones((1,num_values)), x_input ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_input) + x_hidden = sigmoid(z_hidden) + + ## Output layer: + + # Include bias: + x_hidden = np.concatenate((np.ones((1,num_values)), x_hidden ), axis = 0) + + z_output = np.matmul(w_output, x_hidden) + x_output = z_output + + return x_output + +# The trial solution using the deep neural network: +def g_trial(x,params, g0 = 10): + return g0 + x*neural_network(params,x) + +# The right side of the ODE: +def g(x, g_trial, gamma = 2): + return -gamma*g_trial + +# The cost function: +def cost_function(P, x): + + # Evaluate the trial function with the current parameters P + g_t = g_trial(x,P) + + # Find the derivative w.r.t x of the neural network + d_net_out = elementwise_grad(neural_network,1)(P,x) + + # Find the derivative w.r.t x of the trial function + d_g_t = elementwise_grad(g_trial,0)(x,P) + + # The right side of the ODE + func = g(x, g_t) + + err_sqr = (d_g_t - func)**2 + cost_sum = np.sum(err_sqr) + + return cost_sum / np.size(err_sqr) + +# Solve the exponential decay ODE using neural network with one input, hidden, and output layer +def solve_ode_neural_network(x, num_neurons_hidden, num_iter, lmb): + ## Set up initial weights and biases + + # For the hidden layer + p0 = npr.randn(num_neurons_hidden, 2 ) + + # For the output layer + p1 = npr.randn(1, num_neurons_hidden + 1 ) # +1 since bias is included + + P = [p0, p1] + + print('Initial cost: %g'%cost_function(P, x)) + + ## Start finding the optimal weights using gradient descent + + # Find the Python function that represents the gradient of the cost function + # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer + cost_function_grad = grad(cost_function,0) + + # Let the update be done num_iter times + for i in range(num_iter): + # Evaluate the gradient at the current weights and biases in P. + # The cost_grad consist now of two arrays; + # one for the gradient w.r.t P_hidden and + # one for the gradient w.r.t P_output + cost_grad = cost_function_grad(P, x) + + P[0] = P[0] - lmb * cost_grad[0] + P[1] = P[1] - lmb * cost_grad[1] + + print('Final cost: %g'%cost_function(P, x)) + + return P + +def g_analytic(x, gamma = 2, g0 = 10): + return g0*np.exp(-gamma*x) + +# Solve the given problem +if __name__ == '__main__': + # Set seed such that the weight are initialized + # with same weights and biases for every run. + npr.seed(15) + + ## Decide the vales of arguments to the function to solve + N = 10 + x = np.linspace(0, 1, N) + + ## Set up the initial parameters + num_hidden_neurons = 10 + num_iter = 10000 + lmb = 0.001 + + # Use the network + P = solve_ode_neural_network(x, num_hidden_neurons, num_iter, lmb) + + # Print the deviation from the trial solution and true solution + res = g_trial(x,P) + res_analytical = g_analytic(x) + + print('Max absolute difference: %g'%np.max(np.abs(res - res_analytical))) + + # Plot the results + plt.figure(figsize=(10,10)) + + plt.title('Performance of neural network solving an ODE compared to the analytical solution') + plt.plot(x, res_analytical) + plt.plot(x, res[0,:]) + plt.legend(['analytical','nn']) + plt.xlabel('x') + plt.ylabel('g(x)') + plt.show() +!ec + + +!split +===== The network with one input layer, specified number of hidden layers, and one output layer ===== + +It is also possible to extend the construction of our network into a more general one, allowing the network to contain more than one hidden layers. + +The number of neurons within each hidden layer are given as a list of integers in the program below. + +!bc pycod +import autograd.numpy as np +from autograd import grad, elementwise_grad +import autograd.numpy.random as npr +from matplotlib import pyplot as plt + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +# The neural network with one input layer and one output layer, +# but with number of hidden layers specified by the user. +def deep_neural_network(deep_params, x): + # N_hidden is the number of hidden layers + # deep_params is a list, len() should be used + N_hidden = len(deep_params) - 1 # -1 since params consists of + # parameters to all the hidden + # layers AND the output layer. + + # Assumes input x being an one-dimensional array + num_values = np.size(x) + x = x.reshape(-1, num_values) + + # Assume that the input layer does nothing to the input x + x_input = x + + # Due to multiple hidden layers, define a variable referencing to the + # output of the previous layer: + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output + +# The trial solution using the deep neural network: +def g_trial_deep(x,params, g0 = 10): + return g0 + x*deep_neural_network(params, x) + +# The right side of the ODE: +def g(x, g_trial, gamma = 2): + return -gamma*g_trial + +# The same cost function as before, but calls deep_neural_network instead. +def cost_function_deep(P, x): + + # Evaluate the trial function with the current parameters P + g_t = g_trial_deep(x,P) + + # Find the derivative w.r.t x of the neural network + d_net_out = elementwise_grad(deep_neural_network,1)(P,x) + + # Find the derivative w.r.t x of the trial function + d_g_t = elementwise_grad(g_trial_deep,0)(x,P) + + # The right side of the ODE + func = g(x, g_t) + + err_sqr = (d_g_t - func)**2 + cost_sum = np.sum(err_sqr) + + return cost_sum / np.size(err_sqr) + +# Solve the exponential decay ODE using neural network with one input and one output layer, +# but with specified number of hidden layers from the user. +def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb): + # num_hidden_neurons is now a list of number of neurons within each hidden layer + + # The number of elements in the list num_hidden_neurons thus represents + # the number of hidden layers. + + # Find the number of hidden layers: + N_hidden = np.size(num_neurons) + + ## Set up initial weights and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 ) + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: %g'%cost_function_deep(P, x)) + + ## Start finding the optimal weights using gradient descent + + # Find the Python function that represents the gradient of the cost function + # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer + cost_function_deep_grad = grad(cost_function_deep,0) + + # Let the update be done num_iter times + for i in range(num_iter): + # Evaluate the gradient at the current weights and biases in P. + # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases + # in the hidden layers and output layers evaluated at x. + cost_deep_grad = cost_function_deep_grad(P, x) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_deep_grad[l] + + print('Final cost: %g'%cost_function_deep(P, x)) + + return P + +def g_analytic(x, gamma = 2, g0 = 10): + return g0*np.exp(-gamma*x) + +# Solve the given problem +if __name__ == '__main__': + npr.seed(15) + + ## Decide the vales of arguments to the function to solve + N = 10 + x = np.linspace(0, 1, N) + + ## Set up the initial parameters + num_hidden_neurons = np.array([10,10]) + num_iter = 10000 + lmb = 0.001 + + P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb) + + res = g_trial_deep(x,P) + res_analytical = g_analytic(x) + + plt.figure(figsize=(10,10)) + + plt.title('Performance of a deep neural network solving an ODE compared to the analytical solution') + plt.plot(x, res_analytical) + plt.plot(x, res[0,:]) + plt.legend(['analytical','dnn']) + plt.ylabel('g(x)') + plt.show() +!ec + + +!split +===== Example: Population growth ===== + +A logistic model of population growth assumes that a population converges toward an equilibrium. +The population growth can be modeled by + +!bt +\begin{equation} \label{log} + g'(t) = \alpha g(t)(A - g(t)) +\end{equation} +!et + +where $g(t)$ is the population density at time $t$, $\alpha > 0$ the growth rate and $A > 0$ is the maximum population number in the environment. +Also, at $t = 0$ the population has the size $g(0) = g_0$, where $g_0$ is some chosen constant. + +In this example, similar network as for the exponential decay using Autograd has been used to solve the equation. However, as the implementation might suffer from e.g numerical instability +and high execution time (this might be more apparent in the examples solving PDEs), +using a library like TensorFlow is recommended. +Here, we stay with a more simple approach and implement for comparison, the simple forward Euler method. + +!split +===== Setting up the problem ===== + +Here, we will model a population $g(t)$ in an environment having carrying capacity $A$. +The population follows the model + +!bt +\begin{equation} \label{solveode_population} +g'(t) = \alpha g(t)(A - g(t)) +\end{equation} +!et + +where $g(0) = g_0$. + +In this example, we let $\alpha = 2$, $A = 1$, and $g_0 = 1.2$. + +!split +===== The trial solution ===== + +We will get a slightly different trial solution, as the boundary conditions are different +compared to the case for exponential decay. + +A possible trial solution satisfying the condition $g(0) = g_0$ could be + +$$ +h_1(t) = g_0 + t \cdot N(t,P) +$$ + +with $N(t,P)$ being the output from the neural network with weights and biases for each layer collected in the set $P$. + +The analytical solution is + +$$ +g(t) = \frac{Ag_0}{g_0 + (A - g_0)\exp(-\alpha A t)} +$$ + +!split +===== The program using Autograd ===== + +The network will be the similar as for the exponential decay example, but with some small modifications for our problem. + +!bc pycod +import autograd.numpy as np +from autograd import grad, elementwise_grad +import autograd.numpy.random as npr +from matplotlib import pyplot as plt + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +# Function to get the parameters. +# Done such that one can easily change the paramaters after one's liking. +def get_parameters(): + alpha = 2 + A = 1 + g0 = 1.2 + return alpha, A, g0 + +def deep_neural_network(deep_params, x): + # N_hidden is the number of hidden layers + # deep_params is a list, len() should be used + N_hidden = len(deep_params) - 1 # -1 since params consists of + # parameters to all the hidden + # layers AND the output layer. + + # Assumes input x being an one-dimensional array + num_values = np.size(x) + x = x.reshape(-1, num_values) + + # Assume that the input layer does nothing to the input x + x_input = x + + # Due to multiple hidden layers, define a variable referencing to the + # output of the previous layer: + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output + + + + +def cost_function_deep(P, x): + + # Evaluate the trial function with the current parameters P + g_t = g_trial_deep(x,P) + + # Find the derivative w.r.t x of the trial function + d_g_t = elementwise_grad(g_trial_deep,0)(x,P) + + # The right side of the ODE + func = f(x, g_t) + + err_sqr = (d_g_t - func)**2 + cost_sum = np.sum(err_sqr) + + return cost_sum / np.size(err_sqr) + +# The right side of the ODE: +def f(x, g_trial): + alpha,A, g0 = get_parameters() + return alpha*g_trial*(A - g_trial) + +# The trial solution using the deep neural network: +def g_trial_deep(x, params): + alpha,A, g0 = get_parameters() + return g0 + x*deep_neural_network(params,x) + +# The analytical solution: +def g_analytic(t): + alpha,A, g0 = get_parameters() + return A*g0/(g0 + (A - g0)*np.exp(-alpha*A*t)) + +def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb): + # num_hidden_neurons is now a list of number of neurons within each hidden layer + + # Find the number of hidden layers: + N_hidden = np.size(num_neurons) + + ## Set up initial weigths and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 ) + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: %g'%cost_function_deep(P, x)) + + ## Start finding the optimal weigths using gradient descent + + # Find the Python function that represents the gradient of the cost function + # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer + cost_function_deep_grad = grad(cost_function_deep,0) + + # Let the update be done num_iter times + for i in range(num_iter): + # Evaluate the gradient at the current weights and biases in P. + # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases + # in the hidden layers and output layers evaluated at x. + cost_deep_grad = cost_function_deep_grad(P, x) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_deep_grad[l] + + print('Final cost: %g'%cost_function_deep(P, x)) + + return P + +if __name__ == '__main__': + npr.seed(4155) + + ## Decide the vales of arguments to the function to solve + Nt = 10 + T = 1 + t = np.linspace(0,T, Nt) + + ## Set up the initial parameters + num_hidden_neurons = [100, 50, 25] + num_iter = 1000 + lmb = 1e-3 + + P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb) + + g_dnn_ag = g_trial_deep(t,P) + g_analytical = g_analytic(t) + + # Find the maximum absolute difference between the solutons: + diff_ag = np.max(np.abs(g_dnn_ag - g_analytical)) + print("The max absolute difference between the solutions is: %g"%diff_ag) + + plt.figure(figsize=(10,10)) + + plt.title('Performance of neural network solving an ODE compared to the analytical solution') + plt.plot(t, g_analytical) + plt.plot(t, g_dnn_ag[0,:]) + plt.legend(['analytical','nn']) + plt.xlabel('t') + plt.ylabel('g(t)') + + plt.show() +!ec + +!split +===== Using forward Euler to solve the ODE ===== + +A straightforward way of solving an ODE numerically, is to use Euler's method. + +Euler's method uses Taylor series to approximate the value at a function $f$ at a step $\Delta x$ from $x$: + +$$ +f(x + \Delta x) \approx f(x) + \Delta x f'(x) +$$ + +In our case, using Euler's method to approximate the value of $g$ at a step $\Delta t$ from $t$ yields + +!bt +\begin{aligned} + g(t + \Delta t) &\approx g(t) + \Delta t g'(t) \\ + &= g(t) + \Delta t \big(\alpha g(t)(A - g(t))\big) +\end{aligned} +!et +along with the condition that $g(0) = g_0$. + +Let $t_i = i \cdot \Delta t$ where $\Delta t = \frac{T}{N_t-1}$ where $T$ is the final time our solver must solve for and $N_t$ the number of values for $t \in [0, T]$ for $i = 0, \dots, N_t-1$. + +For $i \geq 1$, we have that +!bt +\begin{aligned} +t_i &= i\Delta t \\ +&= (i - 1)\Delta t + \Delta t \\ +&= t_{i-1} + \Delta t +\end{aligned} +!et + +Now, if $g_i = g(t_i)$ then + +!bt +\begin{equation} + \begin{aligned} + g_i &= g(t_i) \\ + &= g(t_{i-1} + \Delta t) \\ + &\approx g(t_{i-1}) + \Delta t \big(\alpha g(t_{i-1})(A - g(t_{i-1}))\big) \\ + &= g_{i-1} + \Delta t \big(\alpha g_{i-1}(A - g_{i-1})\big) + \end{aligned} +\end{equation} \label{odenum} +!et +for $i \geq 1$ and $g_0 = g(t_0) = g(0) = g_0$. + +Equation (ref{odenum}) could be implemented in the following way, +extending the program that uses the network using Autograd: + +!bc pycod +# Assume that all function definitions from the example program using Autograd +# are located here. + +if __name__ == '__main__': + npr.seed(4155) + + ## Decide the vales of arguments to the function to solve + Nt = 10 + T = 1 + t = np.linspace(0,T, Nt) + + ## Set up the initial parameters + num_hidden_neurons = [100,50,25] + num_iter = 1000 + lmb = 1e-3 + + P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb) + + g_dnn_ag = g_trial_deep(t,P) + g_analytical = g_analytic(t) + + # Find the maximum absolute difference between the solutons: + diff_ag = np.max(np.abs(g_dnn_ag - g_analytical)) + print("The max absolute difference between the solutions is: %g"%diff_ag) + + plt.figure(figsize=(10,10)) + + plt.title('Performance of neural network solving an ODE compared to the analytical solution') + plt.plot(t, g_analytical) + plt.plot(t, g_dnn_ag[0,:]) + plt.legend(['analytical','nn']) + plt.xlabel('t') + plt.ylabel('g(t)') + + ## Find an approximation to the funtion using forward Euler + + alpha, A, g0 = get_parameters() + dt = T/(Nt - 1) + + # Perform forward Euler to solve the ODE + g_euler = np.zeros(Nt) + g_euler[0] = g0 + + for i in range(1,Nt): + g_euler[i] = g_euler[i-1] + dt*(alpha*g_euler[i-1]*(A - g_euler[i-1])) + + # Print the errors done by each method + diff1 = np.max(np.abs(g_euler - g_analytical)) + diff2 = np.max(np.abs(g_dnn_ag[0,:] - g_analytical)) + + print('Max absolute difference between Euler method and analytical: %g'%diff1) + print('Max absolute difference between deep neural network and analytical: %g'%diff2) + + # Plot results + plt.figure(figsize=(10,10)) + + plt.plot(t,g_euler) + plt.plot(t,g_analytical) + plt.plot(t,g_dnn_ag[0,:]) + + plt.legend(['euler','analytical','dnn']) + plt.xlabel('Time t') + plt.ylabel('g(t)') + + plt.show() +!ec + + + +!split +===== Example: Solving the one dimensional Poisson equation ===== + +The Poisson equation for $g(x)$ in one dimension is + +!bt +\begin{equation} \label{poisson} + -g''(x) = f(x) +\end{equation} +!et + +where $f(x)$ is a given function for $x \in (0,1)$. + +The conditions that $g(x)$ is chosen to fulfill, are +!bt +\begin{align*} + g(0) &= 0 \\ + g(1) &= 0 +\end{align*} +!et + +This equation can be solved numerically using programs where e.g Autograd and TensorFlow are used. +The results from the networks can then be compared to the analytical solution. +In addition, it could be interesting to see how a typical method for numerically solving second order ODEs compares to the neural networks. + +!split +===== The specific equation to solve for ===== + +Here, the function $g(x)$ to solve for follows the equation + +!bt +-g''(x) = f(x),\qquad x \in (0,1) +!et + +where $f(x)$ is a given function, along with the chosen conditions + +!bt +\begin{aligned} +g(0) = g(1) = 0 +\end{aligned}\label{cond} +!et + +In this example, we consider the case when $f(x) = (3x + x^2)\exp(x)$. + +For this case, a possible trial solution satisfying the conditions could be + +!bt +g_t(x) = x \cdot (1-x) \cdot N(P,x) +!et + +The analytical solution for this problem is + +!bt +g(x) = x(1 - x)\exp(x) +!et + +!split +===== Solving the equation using Autograd ===== + +!bc pycod +import autograd.numpy as np +from autograd import grad, elementwise_grad +import autograd.numpy.random as npr +from matplotlib import pyplot as plt + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +def deep_neural_network(deep_params, x): + # N_hidden is the number of hidden layers + # deep_params is a list, len() should be used + N_hidden = len(deep_params) - 1 # -1 since params consists of + # parameters to all the hidden + # layers AND the output layer. + + # Assumes input x being an one-dimensional array + num_values = np.size(x) + x = x.reshape(-1, num_values) + + # Assume that the input layer does nothing to the input x + x_input = x + + # Due to multiple hidden layers, define a variable referencing to the + # output of the previous layer: + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output + + +def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb): + # num_hidden_neurons is now a list of number of neurons within each hidden layer + + # Find the number of hidden layers: + N_hidden = np.size(num_neurons) + + ## Set up initial weigths and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 ) + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: %g'%cost_function_deep(P, x)) + + ## Start finding the optimal weigths using gradient descent + + # Find the Python function that represents the gradient of the cost function + # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer + cost_function_deep_grad = grad(cost_function_deep,0) + + # Let the update be done num_iter times + for i in range(num_iter): + # Evaluate the gradient at the current weights and biases in P. + # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases + # in the hidden layers and output layers evaluated at x. + cost_deep_grad = cost_function_deep_grad(P, x) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_deep_grad[l] + + print('Final cost: %g'%cost_function_deep(P, x)) + + return P + +## Set up the cost function specified for this Poisson equation: + +# The right side of the ODE +def f(x): + return (3*x + x**2)*np.exp(x) + +def cost_function_deep(P, x): + + # Evaluate the trial function with the current parameters P + g_t = g_trial_deep(x,P) + + # Find the derivative w.r.t x of the trial function + d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P) + + right_side = f(x) + + err_sqr = (-d2_g_t - right_side)**2 + cost_sum = np.sum(err_sqr) + + return cost_sum/np.size(err_sqr) + +# The trial solution: +def g_trial_deep(x,P): + return x*(1-x)*deep_neural_network(P,x) + +# The analytic solution; +def g_analytic(x): + return x*(1-x)*np.exp(x) + +if __name__ == '__main__': + npr.seed(4155) + + ## Decide the vales of arguments to the function to solve + Nx = 10 + x = np.linspace(0,1, Nx) + + ## Set up the initial parameters + num_hidden_neurons = [200,100] + num_iter = 1000 + lmb = 1e-3 + + P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb) + + g_dnn_ag = g_trial_deep(x,P) + g_analytical = g_analytic(x) + + # Find the maximum absolute difference between the solutons: + max_diff = np.max(np.abs(g_dnn_ag - g_analytical)) + print("The max absolute difference between the solutions is: %g"%max_diff) + + plt.figure(figsize=(10,10)) + + plt.title('Performance of neural network solving an ODE compared to the analytical solution') + plt.plot(x, g_analytical) + plt.plot(x, g_dnn_ag[0,:]) + plt.legend(['analytical','nn']) + plt.xlabel('x') + plt.ylabel('g(x)') + plt.show() +!ec + +!split +===== Comparing with a numerical scheme ===== + +The Poisson equation is possible to solve using Taylor series to approximate the second derivative. + +Using Taylor series, the second derivative can be expressed as + +$$ +g''(x) = \frac{g(x + \Delta x) - 2g(x) + g(x-\Delta x)}{\Delta x^2} + E_{\Delta x}(x) +$$ + +where $\Delta x$ is a small step size and $E_{\Delta x}(x)$ being the error term. + +Looking away from the error terms gives an approximation to the second derivative: + +!bt +\begin{equation} \label{approx} +g''(x) \approx \frac{g(x + \Delta x) - 2g(x) + g(x-\Delta x)}{\Delta x^2} +\end{equation} +!et + +If $x_i = i \Delta x = x_{i-1} + \Delta x$ and $g_i = g(x_i)$ for $i = 1,\dots N_x - 2$ with $N_x$ being the number of values for $x$, (ref{approx}) becomes + +!bt +\begin{aligned} +g''(x_i) &\approx \frac{g(x_i + \Delta x) - 2g(x_i) + g(x_i -\Delta x)}{\Delta x^2} \\ +&= \frac{g_{i+1} - 2g_i + g_{i-1}}{\Delta x^2} +\end{aligned} +!et + +Since we know from our problem that + +!bt +\begin{aligned} +-g''(x) &= f(x) \\ +&= (3x + x^2)\exp(x) +\end{aligned} +!et + +along with the conditions $g(0) = g(1) = 0$, +the following scheme can be used to find an approximate solution for $g(x)$ numerically: + +!bt +\begin{equation} + \begin{aligned} + -\Big( \frac{g_{i+1} - 2g_i + g_{i-1}}{\Delta x^2} \Big) &= f(x_i) \\ + -g_{i+1} + 2g_i - g_{i-1} &= \Delta x^2 f(x_i) + \end{aligned} +\end{equation} \label{odesys} +!et + +for $i = 1, \dots, N_x - 2$ where $g_0 = g_{N_x - 1} = 0$ and $f(x_i) = (3x_i + x_i^2)\exp(x_i)$, which is given for our specific problem. + +The equation can be rewritten into a matrix equation: + +!bt +\begin{aligned} +\begin{pmatrix} +2 & -1 & 0 & \dots & 0 \\ +-1 & 2 & -1 & \dots & 0 \\ +\vdots & & \ddots & & \vdots \\ +0 & \dots & -1 & 2 & -1 \\ +0 & \dots & 0 & -1 & 2\\ +\end{pmatrix} +\begin{pmatrix} +g_1 \\ +g_2 \\ +\vdots \\ +g_{N_x - 3} \\ +g_{N_x - 2} +\end{pmatrix} +&= +\Delta x^2 +\begin{pmatrix} +f(x_1) \\ +f(x_2) \\ +\vdots \\ +f(x_{N_x - 3}) \\ +f(x_{N_x - 2}) +\end{pmatrix} \\ +\bm{A}\bm{g} &= \bm{f}, +\end{aligned} +!et + +which makes it possible to solve for the vector $\bm{g}$. + +!split +===== Setting up the code ===== + +We can then compare the result from this numerical scheme with the output from our network using Autograd: + +!bc pycod +import autograd.numpy as np +from autograd import grad, elementwise_grad +import autograd.numpy.random as npr +from matplotlib import pyplot as plt + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +def deep_neural_network(deep_params, x): + # N_hidden is the number of hidden layers + # deep_params is a list, len() should be used + N_hidden = len(deep_params) - 1 # -1 since params consists of + # parameters to all the hidden + # layers AND the output layer. + + # Assumes input x being an one-dimensional array + num_values = np.size(x) + x = x.reshape(-1, num_values) + + # Assume that the input layer does nothing to the input x + x_input = x + + # Due to multiple hidden layers, define a variable referencing to the + # output of the previous layer: + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output + + +def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb): + # num_hidden_neurons is now a list of number of neurons within each hidden layer + + # Find the number of hidden layers: + N_hidden = np.size(num_neurons) + + ## Set up initial weigths and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 ) + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: %g'%cost_function_deep(P, x)) + + ## Start finding the optimal weigths using gradient descent + + # Find the Python function that represents the gradient of the cost function + # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer + cost_function_deep_grad = grad(cost_function_deep,0) + + # Let the update be done num_iter times + for i in range(num_iter): + # Evaluate the gradient at the current weights and biases in P. + # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases + # in the hidden layers and output layers evaluated at x. + cost_deep_grad = cost_function_deep_grad(P, x) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_deep_grad[l] + + print('Final cost: %g'%cost_function_deep(P, x)) + + return P + +## Set up the cost function specified for this Poisson equation: + +# The right side of the ODE +def f(x): + return (3*x + x**2)*np.exp(x) + +def cost_function_deep(P, x): + + # Evaluate the trial function with the current parameters P + g_t = g_trial_deep(x,P) + + # Find the derivative w.r.t x of the trial function + d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P) + + right_side = f(x) + + err_sqr = (-d2_g_t - right_side)**2 + cost_sum = np.sum(err_sqr) + + return cost_sum/np.size(err_sqr) + +# The trial solution: +def g_trial_deep(x,P): + return x*(1-x)*deep_neural_network(P,x) + +# The analytic solution; +def g_analytic(x): + return x*(1-x)*np.exp(x) + +if __name__ == '__main__': + npr.seed(4155) + + ## Decide the vales of arguments to the function to solve + Nx = 10 + x = np.linspace(0,1, Nx) + + ## Set up the initial parameters + num_hidden_neurons = [200,100] + num_iter = 1000 + lmb = 1e-3 + + P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb) + + g_dnn_ag = g_trial_deep(x,P) + g_analytical = g_analytic(x) + + # Find the maximum absolute difference between the solutons: + + plt.figure(figsize=(10,10)) + + plt.title('Performance of neural network solving an ODE compared to the analytical solution') + plt.plot(x, g_analytical) + plt.plot(x, g_dnn_ag[0,:]) + plt.legend(['analytical','nn']) + plt.xlabel('x') + plt.ylabel('g(x)') + + ## Perform the computation using the numerical scheme + + dx = 1/(Nx - 1) + + # Set up the matrix A + A = np.zeros((Nx-2,Nx-2)) + + A[0,0] = 2 + A[0,1] = -1 + + for i in range(1,Nx-3): + A[i,i-1] = -1 + A[i,i] = 2 + A[i,i+1] = -1 + + A[Nx - 3, Nx - 4] = -1 + A[Nx - 3, Nx - 3] = 2 + + # Set up the vector f + f_vec = dx**2 * f(x[1:-1]) + + # Solve the equation + g_res = np.linalg.solve(A,f_vec) + + g_vec = np.zeros(Nx) + g_vec[1:-1] = g_res + + # Print the differences between each method + max_diff1 = np.max(np.abs(g_dnn_ag - g_analytical)) + max_diff2 = np.max(np.abs(g_vec - g_analytical)) + print("The max absolute difference between the analytical solution and DNN Autograd: %g"%max_diff1) + print("The max absolute difference between the analytical solution and numerical scheme: %g"%max_diff2) + + # Plot the results + plt.figure(figsize=(10,10)) + + plt.plot(x,g_vec) + plt.plot(x,g_analytical) + plt.plot(x,g_dnn_ag[0,:]) + + plt.legend(['numerical scheme','analytical','dnn']) + plt.show() + +!ec + + + +!split +===== Partial Differential Equations ===== + +A partial differential equation (PDE) has a solution here the function +is defined by multiple variables. The equation may involve all kinds +of combinations of which variables the function is differentiated with +respect to. + +In general, a partial differential equation for a function $g(x_1,\dots,x_N)$ with $N$ variables may be expressed as + +!bt +\begin{equation} \label{PDE} + f\left(x_1, \, \dots \, , x_N, \frac{\partial g(x_1,\dots,x_N) }{\partial x_1}, \dots , \frac{\partial g(x_1,\dots,x_N) }{\partial x_N}, \frac{\partial g(x_1,\dots,x_N) }{\partial x_1\partial x_2}, \, \dots \, , \frac{\partial^n g(x_1,\dots,x_N) }{\partial x_N^n} \right) = 0 +\end{equation} +!et + +where $f$ is an expression involving all kinds of possible mixed derivatives of $g(x_1,\dots,x_N)$ up to an order $n$. In order for the solution to be unique, some additional conditions must also be given. + +!split +===== Type of problem ===== + +The problem our network must solve for, is similar to the ODE case. +We must have a trial solution $g_t$ at hand. + +For instance, the trial solution could be expressed as +!bt +\begin{align*} + g_t(x_1,\dots,x_N) = h_1(x_1,\dots,x_N) + h_2(x_1,\dots,x_N,N(x_1,\dots,x_N,P)) +\end{align*} +!et +where $h_1(x_1,\dots,x_N)$ is a function that ensures $g_t(x_1,\dots,x_N)$ satisfies some given conditions. +The neural network $N(x_1,\dots,x_N,P)$ has weights and biases described by $P$ and $h_2(x_1,\dots,x_N,N(x_1,\dots,x_N,P))$ is an expression using the output from the neural network in some way. + +The role of the function $h_2(x_1,\dots,x_N,N(x_1,\dots,x_N,P))$, is to ensure that the output of $N(x_1,\dots,x_N,P)$ is zero when $g_t(x_1,\dots,x_N)$ is evaluated at the values of $x_1,\dots,x_N$ where the given conditions must be satisfied. The function $h_1(x_1,\dots,x_N)$ should alone make $g_t(x_1,\dots,x_N)$ satisfy the conditions. + + +!split +===== Network requirements ===== + +The network tries then the minimize the cost function following the +same ideas as described for the ODE case, but now with more than one +variables to consider. The concept still remains the same; find a set +of parameters $P$ such that the expression $f$ in (ref{PDE}) is as +close to zero as possible. + +As for the ODE case, the cost function is the mean squared error that +the network must try to minimize. The cost function for the network to +minimize is + +!bt +\begin{equation*} +C\left(x_1, \dots, x_N, P\right) = \left( f\left(x_1, \, \dots \, , x_N, \frac{\partial g(x_1,\dots,x_N) }{\partial x_1}, \dots , \frac{\partial g(x_1,\dots,x_N) }{\partial x_N}, \frac{\partial g(x_1,\dots,x_N) }{\partial x_1\partial x_2}, \, \dots \, , \frac{\partial^n g(x_1,\dots,x_N) }{\partial x_N^n} \right) \right)^2 +\end{equation*} +!et + +!split +===== More details ===== + +If we let $\bm{x} = \big( x_1, \dots, x_N \big)$ be an array containing the values for $x_1, \dots, x_N$ respectively, the cost function can be reformulated into the following: +!bt +\[ + C\left(\bm{x}, P\right) = f\left( \left( \bm{x}, \frac{\partial g(\bm{x}) }{\partial x_1}, \dots , \frac{\partial g(\bm{x}) }{\partial x_N}, \frac{\partial g(\bm{x}) }{\partial x_1\partial x_2}, \, \dots \, , \frac{\partial^n g(\bm{x}) }{\partial x_N^n} \right) \right)^2 +\] +!et + +If we also have $M$ different sets of values for $x_1, \dots, x_N$, that is $\bm{x}_i = \big(x_1^{(i)}, \dots, x_N^{(i)}\big)$ for $i = 1,\dots,M$ being the rows in matrix $X$, the cost function can be generalized into +!bt +\begin{equation*} +C\left(X, P \right) = \sum_{i=1}^M f\left( \left( \bm{x}_i, \frac{\partial g(\bm{x}_i) }{\partial x_1}, \dots , \frac{\partial g(\bm{x}_i) }{\partial x_N}, \frac{\partial g(\bm{x}_i) }{\partial x_1\partial x_2}, \, \dots \, , \frac{\partial^n g(\bm{x}_i) }{\partial x_N^n} \right) \right)^2. +\end{equation*} +!et + +!split +===== Example: The diffusion equation ===== + +In one spatial dimension, the equation reads +!bt +\begin{equation*} + \frac{\partial g(x,t)}{\partial t} = \frac{\partial^2 g(x,t)}{\partial x^2} +\end{equation*} +!et + +where a possible choice of conditions are +!bt +\begin{align*} +g(0,t) &= 0 ,\qquad t \geq 0 \\ +g(1,t) &= 0, \qquad t \geq 0 \\ +g(x,0) &= u(x),\qquad x\in [0,1] +\end{align*} +!et +with $u(x)$ being some given function. + +!split +===== Defining the problem ===== + +For this case, we want to find $g(x,t)$ such that + +!bt +\begin{equation} + \frac{\partial g(x,t)}{\partial t} = \frac{\partial^2 g(x,t)}{\partial x^2} +\end{equation} \label{diffonedim} +!et + +and + +!bt +\begin{align*} +g(0,t) &= 0 ,\qquad t \geq 0 \\ +g(1,t) &= 0, \qquad t \geq 0 \\ +g(x,0) &= u(x),\qquad x\in [0,1] +\end{align*} +!et +with $u(x) = \sin(\pi x)$. + +First, let us set up the deep neural network. +The deep neural network will follow the same structure as discussed in the examples solving the ODEs. +First, we will look into how Autograd could be used in a network tailored to solve for bivariate functions. + + + +!split +===== Setting up the network using Autograd ===== + +The only change to do here, is to extend our network such that +functions of multiple parameters are correctly handled. In this case +we have two variables in our function to solve for, that is time $t$ +and position $x$. The variables will be represented by a +one-dimensional array in the program. The program will evaluate the +network at each possible pair $(x,t)$, given an array for the desired +$x$-values and $t$-values to approximate the solution at. + +!bc pycod +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +def deep_neural_network(deep_params, x): + # x is now a point and a 1D numpy array; make it a column vector + num_coordinates = np.size(x,0) + x = x.reshape(num_coordinates,-1) + + num_points = np.size(x,1) + + # N_hidden is the number of hidden layers + N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer + + # Assume that the input layer does nothing to the input x + x_input = x + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output[0][0] +!ec + +!split +===== Setting up the network using Autograd; The trial solution ===== + +The cost function must then iterate through the given arrays +containing values for $x$ and $t$, defines a point $(x,t)$ the deep +neural network and the trial solution is evaluated at, and then finds +the Jacobian of the trial solution. + +A possible trial solution for this PDE is + +$$ +g_t(x,t) = h_1(x,t) + x(1-x)tN(x,t,P) +$$ + +with $A(x,t)$ being a function ensuring that $g_t(x,t)$ satisfies our given conditions, and $N(x,t,P)$ being the output from the deep neural network using weights and biases for each layer from $P$. + +To fulfill the conditions, $A(x,t)$ could be: + +$$ +h_1(x,t) = (1-t)\Big(u(x) - \big((1-x)u(0) + x u(1)\big)\Big) = (1-t)u(x) = (1-t)\sin(\pi x) +$$ +since $(0) = u(1) = 0$ and $u(x) = \sin(\pi x)$. + +!split +===== Why the jacobian? ===== + +The Jacobian is used because the program must find the derivative of +the trial solution with respect to $x$ and $t$. + +This gives the necessity of computing the Jacobian matrix, as we want +to evaluate the gradient with respect to $x$ and $t$ (note that the +Jacobian of a scalar-valued multivariate function is simply its +gradient). + +In Autograd, the differentiation is by default done with respect to +the first input argument of your Python function. Since the points is +an array representing $x$ and $t$, the Jacobian is calculated using +the values of $x$ and $t$. + +To find the second derivative with respect to $x$ and $t$, the +Jacobian can be found for the second time. The result is a Hessian +matrix, which is the matrix containing all the possible second order +mixed derivatives of $g(x,t)$. + +!bc pycod +# Set up the trial function: +def u(x): + return np.sin(np.pi*x) + +def g_trial(point,P): + x,t = point + return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point) + +# The right side of the ODE: +def f(point): + return 0. + +# The cost function: +def cost_function(P, x, t): + cost_sum = 0 + + g_t_jacobian_func = jacobian(g_trial) + g_t_hessian_func = hessian(g_trial) + + for x_ in x: + for t_ in t: + point = np.array([x_,t_]) + + g_t = g_trial(point,P) + g_t_jacobian = g_t_jacobian_func(point,P) + g_t_hessian = g_t_hessian_func(point,P) + + g_t_dt = g_t_jacobian[1] + g_t_d2x = g_t_hessian[0][0] + + func = f(point) + + err_sqr = ( (g_t_dt - g_t_d2x) - func)**2 + cost_sum += err_sqr + + return cost_sum +!ec + +!split +===== Setting up the network using Autograd; The full program ===== + +Having set up the network, along with the trial solution and cost function, we can now see how the deep neural network performs by comparing the results to the analytical solution. + +The analytical solution of our problem is + +$$ +g(x,t) = \exp(-\pi^2 t)\sin(\pi x) +$$ + +A possible way to implement a neural network solving the PDE, is given below. +Be aware, though, that it is fairly slow for the parameters used. +A better result is possible, but requires more iterations, and thus longer time to complete. + + +Indeed, the program below is not optimal in its implementation, but rather serves as an example on how to implement and use a neural network to solve a PDE. +Using TensorFlow results in a much better execution time. Try it! + +!bc pycod +import autograd.numpy as np +from autograd import jacobian,hessian,grad +import autograd.numpy.random as npr +from matplotlib import cm +from matplotlib import pyplot as plt +from mpl_toolkits.mplot3d import axes3d + +## Set up the network + +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +def deep_neural_network(deep_params, x): + # x is now a point and a 1D numpy array; make it a column vector + num_coordinates = np.size(x,0) + x = x.reshape(num_coordinates,-1) + + num_points = np.size(x,1) + + # N_hidden is the number of hidden layers + N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer + + # Assume that the input layer does nothing to the input x + x_input = x + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output[0][0] + +## Define the trial solution and cost function +def u(x): + return np.sin(np.pi*x) + +def g_trial(point,P): + x,t = point + return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point) + +# The right side of the ODE: +def f(point): + return 0. + +# The cost function: +def cost_function(P, x, t): + cost_sum = 0 + + g_t_jacobian_func = jacobian(g_trial) + g_t_hessian_func = hessian(g_trial) + + for x_ in x: + for t_ in t: + point = np.array([x_,t_]) + + g_t = g_trial(point,P) + g_t_jacobian = g_t_jacobian_func(point,P) + g_t_hessian = g_t_hessian_func(point,P) + + g_t_dt = g_t_jacobian[1] + g_t_d2x = g_t_hessian[0][0] + + func = f(point) + + err_sqr = ( (g_t_dt - g_t_d2x) - func)**2 + cost_sum += err_sqr + + return cost_sum /( np.size(x)*np.size(t) ) + +## For comparison, define the analytical solution +def g_analytic(point): + x,t = point + return np.exp(-np.pi**2*t)*np.sin(np.pi*x) + +## Set up a function for training the network to solve for the equation +def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb): + ## Set up initial weigths and biases + N_hidden = np.size(num_neurons) + + ## Set up initial weigths and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: ',cost_function(P, x, t)) + + cost_function_grad = grad(cost_function,0) + + # Let the update be done num_iter times + for i in range(num_iter): + cost_grad = cost_function_grad(P, x , t) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_grad[l] + + print('Final cost: ',cost_function(P, x, t)) + + return P + +if __name__ == '__main__': + ### Use the neural network: + npr.seed(15) + + ## Decide the vales of arguments to the function to solve + Nx = 10; Nt = 10 + x = np.linspace(0, 1, Nx) + t = np.linspace(0,1,Nt) + + ## Set up the parameters for the network + num_hidden_neurons = [100, 25] + num_iter = 250 + lmb = 0.01 + + P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb) + + ## Store the results + g_dnn_ag = np.zeros((Nx, Nt)) + G_analytical = np.zeros((Nx, Nt)) + for i,x_ in enumerate(x): + for j, t_ in enumerate(t): + point = np.array([x_, t_]) + g_dnn_ag[i,j] = g_trial(point,P) + + G_analytical[i,j] = g_analytic(point) + + # Find the map difference between the analytical and the computed solution + diff_ag = np.abs(g_dnn_ag - G_analytical) + print('Max absolute difference between the analytical solution and the network: %g'%np.max(diff_ag)) + + ## Plot the solutions in two dimensions, that being in position and time + + T,X = np.meshgrid(t,x) + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons)) + s = ax.plot_surface(T,X,g_dnn_ag,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Analytical solution') + s = ax.plot_surface(T,X,G_analytical,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Difference') + s = ax.plot_surface(T,X,diff_ag,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + ## Take some slices of the 3D plots just to see the solutions at particular times + indx1 = 0 + indx2 = int(Nt/2) + indx3 = Nt-1 + + t1 = t[indx1] + t2 = t[indx2] + t3 = t[indx3] + + # Slice the results from the DNN + res1 = g_dnn_ag[:,indx1] + res2 = g_dnn_ag[:,indx2] + res3 = g_dnn_ag[:,indx3] + + # Slice the analytical results + res_analytical1 = G_analytical[:,indx1] + res_analytical2 = G_analytical[:,indx2] + res_analytical3 = G_analytical[:,indx3] + + # Plot the slices + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t1) + plt.plot(x, res1) + plt.plot(x,res_analytical1) + plt.legend(['dnn','analytical']) + + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t2) + plt.plot(x, res2) + plt.plot(x,res_analytical2) + plt.legend(['dnn','analytical']) + + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t3) + plt.plot(x, res3) + plt.plot(x,res_analytical3) + plt.legend(['dnn','analytical']) + + plt.show() +!ec + +!split +===== Example: Solving the wave equation with Neural Networks ===== + +The wave equation is +!bt +\begin{equation*} + \frac{\partial^2 g(x,t)}{\partial t^2} = c^2\frac{\partial^2 g(x,t)}{\partial x^2} +\end{equation*} +!et + +with $c$ being the specified wave speed. + +Here, the chosen conditions are +!bt +\begin{align*} + g(0,t) &= 0 \\ + g(1,t) &= 0 \\ + g(x,0) &= u(x) \\ + \frac{\partial g(x,t)}{\partial t} \Big |_{t = 0} &= v(x) +\end{align*} +!et +where $\frac{\partial g(x,t)}{\partial t} \Big |_{t = 0}$ means the derivative of $g(x,t)$ with respect to $t$ is evaluated at $t = 0$, and $u(x)$ and $v(x)$ being given functions. + +!split +===== The problem to solve for ===== + +The wave equation to solve for, is + +!bt +\begin{equation} \label{wave} +\frac{\partial^2 g(x,t)}{\partial t^2} = c^2 \frac{\partial^2 g(x,t)}{\partial x^2} +\end{equation} +!et + +where $c$ is the given wave speed. +The chosen conditions for this equation are + +!bt +\begin{aligned} +g(0,t) &= 0, &t \geq 0 \\ +g(1,t) &= 0, &t \geq 0 \\ +g(x,0) &= u(x), &x\in[0,1] \\ +\frac{\partial g(x,t)}{\partial t}\Big |_{t = 0} &= v(x), &x \in [0,1] +\end{aligned} \label{condwave} +!et + +In this example, let $c = 1$ and $u(x) = \sin(\pi x)$ and $v(x) = -\pi\sin(\pi x)$. + + +!split +===== The trial solution ===== +Setting up the network is done in similar matter as for the example of solving the diffusion equation. +The only things we have to change, is the trial solution such that it satisfies the conditions from (ref{condwave}) and the cost function. + +The trial solution becomes slightly different since we have other conditions than in the example of solving the diffusion equation. Here, a possible trial solution $g_t(x,t)$ is + +$$ +g_t(x,t) = h_1(x,t) + x(1-x)t^2N(x,t,P) +$$ + +where + +$$ +h_1(x,t) = (1-t^2)u(x) + tv(x) +$$ + +Note that this trial solution satisfies the conditions only if $u(0) = v(0) = u(1) = v(1) = 0$, which is the case in this example. + +!split +===== The analytical solution ===== + +The analytical solution for our specific problem, is + +$$ +g(x,t) = \sin(\pi x)\cos(\pi t) - \sin(\pi x)\sin(\pi t) +$$ + +!split +===== Solving the wave equation - the full program using Autograd ===== + +!bc pycod +import autograd.numpy as np +from autograd import hessian,grad +import autograd.numpy.random as npr +from matplotlib import cm +from matplotlib import pyplot as plt +from mpl_toolkits.mplot3d import axes3d + +## Set up the trial function: +def u(x): + return np.sin(np.pi*x) + +def v(x): + return -np.pi*np.sin(np.pi*x) + +def h1(point): + x,t = point + return (1 - t**2)*u(x) + t*v(x) + +def g_trial(point,P): + x,t = point + return h1(point) + x*(1-x)*t**2*deep_neural_network(P,point) + +## Define the cost function +def cost_function(P, x, t): + cost_sum = 0 + + g_t_hessian_func = hessian(g_trial) + + for x_ in x: + for t_ in t: + point = np.array([x_,t_]) + + g_t_hessian = g_t_hessian_func(point,P) + + g_t_d2x = g_t_hessian[0][0] + g_t_d2t = g_t_hessian[1][1] + + err_sqr = ( (g_t_d2t - g_t_d2x) )**2 + cost_sum += err_sqr + + return cost_sum / (np.size(t) * np.size(x)) + +## The neural network +def sigmoid(z): + return 1/(1 + np.exp(-z)) + +def deep_neural_network(deep_params, x): + # x is now a point and a 1D numpy array; make it a column vector + num_coordinates = np.size(x,0) + x = x.reshape(num_coordinates,-1) + + num_points = np.size(x,1) + + # N_hidden is the number of hidden layers + N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer + + # Assume that the input layer does nothing to the input x + x_input = x + x_prev = x_input + + ## Hidden layers: + + for l in range(N_hidden): + # From the list of parameters P; find the correct weigths and bias for this layer + w_hidden = deep_params[l] + + # Add a row of ones to include bias + x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0) + + z_hidden = np.matmul(w_hidden, x_prev) + x_hidden = sigmoid(z_hidden) + + # Update x_prev such that next layer can use the output from this layer + x_prev = x_hidden + + ## Output layer: + + # Get the weights and bias for this layer + w_output = deep_params[-1] + + # Include bias: + x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0) + + z_output = np.matmul(w_output, x_prev) + x_output = z_output + + return x_output[0][0] + +## The analytical solution +def g_analytic(point): + x,t = point + return np.sin(np.pi*x)*np.cos(np.pi*t) - np.sin(np.pi*x)*np.sin(np.pi*t) + +def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb): + ## Set up initial weigths and biases + N_hidden = np.size(num_neurons) + + ## Set up initial weigths and biases + + # Initialize the list of parameters: + P = [None]*(N_hidden + 1) # + 1 to include the output layer + + P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias + for l in range(1,N_hidden): + P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias + + # For the output layer + P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included + + print('Initial cost: ',cost_function(P, x, t)) + + cost_function_grad = grad(cost_function,0) + + # Let the update be done num_iter times + for i in range(num_iter): + cost_grad = cost_function_grad(P, x , t) + + for l in range(N_hidden+1): + P[l] = P[l] - lmb * cost_grad[l] + + + print('Final cost: ',cost_function(P, x, t)) + + return P + +if __name__ == '__main__': + ### Use the neural network: + npr.seed(15) + + ## Decide the vales of arguments to the function to solve + Nx = 10; Nt = 10 + x = np.linspace(0, 1, Nx) + t = np.linspace(0,1,Nt) + + ## Set up the parameters for the network + num_hidden_neurons = [50,20] + num_iter = 1000 + lmb = 0.01 + + P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb) + + ## Store the results + res = np.zeros((Nx, Nt)) + res_analytical = np.zeros((Nx, Nt)) + for i,x_ in enumerate(x): + for j, t_ in enumerate(t): + point = np.array([x_, t_]) + res[i,j] = g_trial(point,P) + + res_analytical[i,j] = g_analytic(point) + + diff = np.abs(res - res_analytical) + print("Max difference between analytical and solution from nn: %g"%np.max(diff)) + + ## Plot the solutions in two dimensions, that being in position and time + + T,X = np.meshgrid(t,x) + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons)) + s = ax.plot_surface(T,X,res,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Analytical solution') + s = ax.plot_surface(T,X,res_analytical,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + + fig = plt.figure(figsize=(10,10)) + ax = fig.add_suplot(projection='3d') + ax.set_title('Difference') + s = ax.plot_surface(T,X,diff,linewidth=0,antialiased=False,cmap=cm.viridis) + ax.set_xlabel('Time $t$') + ax.set_ylabel('Position $x$'); + + ## Take some slices of the 3D plots just to see the solutions at particular times + indx1 = 0 + indx2 = int(Nt/2) + indx3 = Nt-1 + + t1 = t[indx1] + t2 = t[indx2] + t3 = t[indx3] + + # Slice the results from the DNN + res1 = res[:,indx1] + res2 = res[:,indx2] + res3 = res[:,indx3] + + # Slice the analytical results + res_analytical1 = res_analytical[:,indx1] + res_analytical2 = res_analytical[:,indx2] + res_analytical3 = res_analytical[:,indx3] + + # Plot the slices + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t1) + plt.plot(x, res1) + plt.plot(x,res_analytical1) + plt.legend(['dnn','analytical']) + + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t2) + plt.plot(x, res2) + plt.plot(x,res_analytical2) + plt.legend(['dnn','analytical']) + + plt.figure(figsize=(10,10)) + plt.title("Computed solutions at time = %g"%t3) + plt.plot(x, res3) + plt.plot(x,res_analytical3) + plt.legend(['dnn','analytical']) + + plt.show() +!ec + +!split +===== Resources on differential equations and deep learning ===== + +o "Artificial neural networks for solving ordinary and partial differential equations by I.E. Lagaris et al":"https://pdfs.semanticscholar.org/d061/df393e0e8fbfd0ea24976458b7d42419040d.pdf" +o "Neural networks for solving differential equations by A. Honchar":"https://becominghuman.ai/neural-networks-for-solving-differential-equations-fa230ac5e04c" +o "Solving differential equations using neural networks by M.M Chiaramonte and M. Kiener":"http://cs229.stanford.edu/proj2013/ChiaramonteKiener-SolvingDifferentialEquationsUsingNeuralNetworks.pdf" +o "Introduction to Partial Differential Equations by A. Tveito, R. Winther":"https://www.springer.com/us/book/9783540225515" + + + + + + From d488bb07cffe52bc696cc163c0ec2e5a0b7d36f6 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 07:32:29 +0200 Subject: [PATCH 02/14] update week 43 --- doc/pub/week43/html/week43-bs.html | 1707 ++---------- doc/pub/week43/html/week43-reveal.html | 1710 ++---------- doc/pub/week43/html/week43-solarized.html | 1674 ++---------- doc/pub/week43/html/week43.html | 1674 ++---------- doc/pub/week43/ipynb/ipynb-week43-src.tar.gz | Bin 192 -> 191 bytes doc/pub/week43/ipynb/week43.ipynb | 2415 +++-------------- .../Previousversions/exercisesweek43.do.txt | 1284 +++++++++ doc/src/week43/week43.do.txt | 1297 +-------- 8 files changed, 2491 insertions(+), 9270 deletions(-) create mode 100644 doc/src/week43/Previousversions/exercisesweek43.do.txt diff --git a/doc/pub/week43/html/week43-bs.html b/doc/pub/week43/html/week43-bs.html index 778488ec5..a991e9bc4 100644 --- a/doc/pub/week43/html/week43-bs.html +++ b/doc/pub/week43/html/week43-bs.html @@ -41,15 +41,6 @@ doconce format html week43.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'exercises-and-lab-session-week-43'), - ('Mathematics of deep learning', - 2, - None, - 'mathematics-of-deep-learning'), - ('Reminder on books with hands-on material and codes', - 2, - None, - 'reminder-on-books-with-hands-on-material-and-codes'), - ('Reading recommendations', 2, None, 'reading-recommendations'), ('Using Automatic differentiation', 2, None, @@ -58,10 +49,10 @@ doconce format html week43.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'back-propagation-and-automatic-differentiation'), - ('Lecture Monday October 21', + ('Lecture Monday October 20', 2, None, - 'lecture-monday-october-21'), + 'lecture-monday-october-20'), ('Setting up the back propagation algorithm and algorithm for a ' 'feed forward NN, initalizations', 2, @@ -95,63 +86,6 @@ doconce format html week43.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'more-on-activation-functions-output-layers'), - ('Setting up a Multi-layer perceptron model for classification', - 2, - None, - 'setting-up-a-multi-layer-perceptron-model-for-classification'), - ('Defining the cost function', - 2, - None, - 'defining-the-cost-function'), - ('Example: binary classification problem', - 2, - None, - 'example-binary-classification-problem'), - ('The Softmax function', 2, None, 'the-softmax-function'), - ('Developing a code for doing neural networks with back ' - 'propagation', - 2, - None, - 'developing-a-code-for-doing-neural-networks-with-back-propagation'), - ('Collect and pre-process data', - 2, - None, - 'collect-and-pre-process-data'), - ('Train and test datasets', 2, None, 'train-and-test-datasets'), - ('Define model and architecture', - 2, - None, - 'define-model-and-architecture'), - ('Layers', 2, None, 'layers'), - ('Weights and biases', 2, None, 'weights-and-biases'), - ('Feed-forward pass', 2, None, 'feed-forward-pass'), - ('Matrix multiplications', 2, None, 'matrix-multiplications'), - ('Choose cost function and optimizer', - 2, - None, - 'choose-cost-function-and-optimizer'), - ('Optimizing the cost function', - 2, - None, - 'optimizing-the-cost-function'), - ('Regularization', 2, None, 'regularization'), - ('Matrix multiplication', 2, None, 'matrix-multiplication'), - ('Improving performance', 2, None, 'improving-performance'), - ('Full object-oriented implementation', - 2, - None, - 'full-object-oriented-implementation'), - ('Evaluate model performance on test data', - 2, - None, - 'evaluate-model-performance-on-test-data'), - ('Adjust hyperparameters', 2, None, 'adjust-hyperparameters'), - ('Visualization', 2, None, 'visualization'), - ('scikit-learn implementation', - 2, - None, - 'scikit-learn-implementation'), - ('Visualization', 2, None, 'visualization'), ('Building neural networks in Tensorflow and Keras', 2, None, @@ -162,14 +96,18 @@ doconce format html week43.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'collect-and-pre-process-data'), - ('The Breast Cancer Data, now with Keras', + ('Using Pytorch with the full MNIST data set', 2, None, - 'the-breast-cancer-data-now-with-keras'), - ('Building a neural network code', + 'using-pytorch-with-the-full-mnist-data-set'), + ('And a similar example using Tensorflow with Keras', 2, None, - 'building-a-neural-network-code'), + 'and-a-similar-example-using-tensorflow-with-keras'), + ('Building our own neural network code', + 2, + None, + 'building-our-own-neural-network-code'), ('Learning rate methods', 3, None, 'learning-rate-methods'), ('Usage of the above learning rate schedulers', 3, @@ -344,12 +282,9 @@ MathJax.Hub.Config({ - -

Setting up a Multi-layer perceptron model for classification

- -

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

- -

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

- -

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

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

and

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

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

- - - -

Defining the cost function

- -

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

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

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

- -

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

- -

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

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

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

- -

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

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

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

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

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

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

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

- -

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

- - -

Example: binary classification problem

- -

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

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

where we had defined the logistic (sigmoid) function

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

and

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

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

- -

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

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

with

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

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

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

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

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

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

- - -

The Softmax function

-

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

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

For the Softmax function we have

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

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

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

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

- - -

Developing a code for doing neural networks with back propagation

- -

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

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

Collect and pre-process data

- -

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

- -

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

- -

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

- -

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

- -

and the targets would be:

- -

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

- -

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

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

Train and test datasets

- -

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

- -

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

- -

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

- - - -
-
-
-
-
-
from sklearn.model_selection import train_test_split
-
-# one-liner from scikit-learn library
-train_size = 0.8
-test_size = 1 - train_size
-X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
-                                                    test_size=test_size)
-
-# equivalently in numpy
-def train_test_split_numpy(inputs, labels, train_size, test_size):
-    n_inputs = len(inputs)
-    inputs_shuffled = inputs.copy()
-    labels_shuffled = labels.copy()
-    
-    np.random.shuffle(inputs_shuffled)
-    np.random.shuffle(labels_shuffled)
-    
-    train_end = int(n_inputs*train_size)
-    X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]
-    Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]
-    
-    return X_train, X_test, Y_train, Y_test
-
-#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)
-
-print("Number of training images: " + str(len(X_train)))
-print("Number of test images: " + str(len(X_test)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -

Define model and architecture

- -

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

- -

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

- -

$$ y = f(z) ,$$

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- - -

Layers

- - -

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

- - -

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

- - -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- - -

Weights and biases

- -

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

- -

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

- -

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

- -

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

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

Feed-forward pass

- -

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

- -

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

- -

this is then passed through our activation function

- -

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

- -

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

- -

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

- -

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

- -

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

- - -

Matrix multiplications

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

This is fed to the output layer:

- -

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

- -

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

- -

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

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

Choose cost function and optimizer

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- - - -

Optimizing the cost function

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

This has two important benefits:

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

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

- - -

Regularization

- -

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

- -

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

- -

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

- -

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

- -

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

- - -

Matrix multiplication

- -

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

- -

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

- -

The gradient for the output weights is calculated as

- -

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

- -

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

- -

The gradient with respect to the output bias is then

- -

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

- -

The error in the hidden layer is

- -

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

- -

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

- -

This again gives us the gradients in the hidden layer:

- -

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

- -

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

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

Improving performance

- -

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

- -

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

- -

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

- -

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

- - -

Full object-oriented implementation

- -

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

- - - -
-
-
-
-
-
class NeuralNetwork:
-    def __init__(
-            self,
-            X_data,
-            Y_data,
-            n_hidden_neurons=50,
-            n_categories=10,
-            epochs=10,
-            batch_size=100,
-            eta=0.1,
-            lmbd=0.0):
-
-        self.X_data_full = X_data
-        self.Y_data_full = Y_data
-
-        self.n_inputs = X_data.shape[0]
-        self.n_features = X_data.shape[1]
-        self.n_hidden_neurons = n_hidden_neurons
-        self.n_categories = n_categories
-
-        self.epochs = epochs
-        self.batch_size = batch_size
-        self.iterations = self.n_inputs // self.batch_size
-        self.eta = eta
-        self.lmbd = lmbd
-
-        self.create_biases_and_weights()
-
-    def create_biases_and_weights(self):
-        self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)
-        self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01
-
-        self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)
-        self.output_bias = np.zeros(self.n_categories) + 0.01
-
-    def feed_forward(self):
-        # feed-forward for training
-        self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias
-        self.a_h = sigmoid(self.z_h)
-
-        self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias
-
-        exp_term = np.exp(self.z_o)
-        self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
-
-    def feed_forward_out(self, X):
-        # feed-forward for output
-        z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias
-        a_h = sigmoid(z_h)
-
-        z_o = np.matmul(a_h, self.output_weights) + self.output_bias
-        
-        exp_term = np.exp(z_o)
-        probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
-        return probabilities
-
-    def backpropagation(self):
-        error_output = self.probabilities - self.Y_data
-        error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)
-
-        self.output_weights_gradient = np.matmul(self.a_h.T, error_output)
-        self.output_bias_gradient = np.sum(error_output, axis=0)
-
-        self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)
-        self.hidden_bias_gradient = np.sum(error_hidden, axis=0)
-
-        if self.lmbd > 0.0:
-            self.output_weights_gradient += self.lmbd * self.output_weights
-            self.hidden_weights_gradient += self.lmbd * self.hidden_weights
-
-        self.output_weights -= self.eta * self.output_weights_gradient
-        self.output_bias -= self.eta * self.output_bias_gradient
-        self.hidden_weights -= self.eta * self.hidden_weights_gradient
-        self.hidden_bias -= self.eta * self.hidden_bias_gradient
-
-    def predict(self, X):
-        probabilities = self.feed_forward_out(X)
-        return np.argmax(probabilities, axis=1)
-
-    def predict_probabilities(self, X):
-        probabilities = self.feed_forward_out(X)
-        return probabilities
-
-    def train(self):
-        data_indices = np.arange(self.n_inputs)
-
-        for i in range(self.epochs):
-            for j in range(self.iterations):
-                # pick datapoints with replacement
-                chosen_datapoints = np.random.choice(
-                    data_indices, size=self.batch_size, replace=False
-                )
-
-                # minibatch training data
-                self.X_data = self.X_data_full[chosen_datapoints]
-                self.Y_data = self.Y_data_full[chosen_datapoints]
-
-                self.feed_forward()
-                self.backpropagation()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -

Evaluate model performance on test data

- -

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

- -

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

- -

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

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

Adjust hyperparameters

- -

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

- - - -
-
-
-
-
-
eta_vals = np.logspace(-5, 1, 7)
-lmbd_vals = np.logspace(-5, 1, 7)
-# store the models for later use
-DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
-
-# grid search
-for i, eta in enumerate(eta_vals):
-    for j, lmbd in enumerate(lmbd_vals):
-        dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,
-                            n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)
-        dnn.train()
-        
-        DNN_numpy[i][j] = dnn
-        
-        test_predict = dnn.predict(X_test)
-        
-        print("Learning rate  = ", eta)
-        print("Lambda = ", lmbd)
-        print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))
-        print()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -

Visualization

- - - -
-
-
-
-
-
# visual representation of grid search
-# uses seaborn heatmap, you can also do this with matplotlib imshow
-import seaborn as sns
-
-sns.set()
-
-train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-
-for i in range(len(eta_vals)):
-    for j in range(len(lmbd_vals)):
-        dnn = DNN_numpy[i][j]
-        
-        train_pred = dnn.predict(X_train) 
-        test_pred = dnn.predict(X_test)
-
-        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
-        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
-
-        
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Training Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Test Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -

scikit-learn implementation

- -

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

- -

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

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

Visualization

- - -
-
-
-
-
-
# optional
-# visual representation of grid search
-# uses seaborn heatmap, could probably do this in matplotlib
-import seaborn as sns
-
-sns.set()
-
-train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-
-for i in range(len(eta_vals)):
-    for j in range(len(lmbd_vals)):
-        dnn = DNN_scikit[i][j]
-        
-        train_pred = dnn.predict(X_train) 
-        test_pred = dnn.predict(X_test)
-
-        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
-        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
-
-        
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Training Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Test Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -

Building neural networks in Tensorflow and Keras

@@ -2360,7 +1004,7 @@ plt.show() -

The Breast Cancer Data, now with Keras

+

Using Pytorch with the full MNIST data set

@@ -2369,171 +1013,82 @@ plt.show()
-
import tensorflow as tf
-from tensorflow.keras.layers import Input
-from tensorflow.keras.models import Sequential      #This allows appending layers to existing models
-from tensorflow.keras.layers import Dense           #This allows defining the characteristics of a particular layer
-from tensorflow.keras import optimizers             #This allows using whichever optimiser we want (sgd,adam,RMSprop)
-from tensorflow.keras import regularizers           #This allows using whichever regularizer we want (l1,l2,l1_l2)
-from tensorflow.keras.utils import to_categorical   #This allows using categorical cross entropy as the cost function
-import numpy as np
-import matplotlib.pyplot as plt
-import seaborn as sns
-from sklearn.model_selection import train_test_split as splitter
-from sklearn.datasets import load_breast_cancer
-import pickle
-import os 
+  
import torch
+import torch.nn as nn
+import torch.optim as optim
+import torchvision
+import torchvision.transforms as transforms
+
+# Device configuration: use GPU if available
+device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
+
+# MNIST dataset (downloads if not already present)
+transform = transforms.Compose([
+    transforms.ToTensor(),
+    transforms.Normalize((0.5,), (0.5,))  # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)
+])
+train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)
+test_dataset  = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)
+
+train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)
+test_loader  = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)
 
 
-"""Load breast cancer dataset"""
+class NeuralNet(nn.Module):
+    def __init__(self):
+        super(NeuralNet, self).__init__()
+        self.fc1 = nn.Linear(28*28, 100)   # first hidden layer (784 -> 100)
+        self.fc2 = nn.Linear(100, 100)    # second hidden layer (100 -> 100)
+        self.fc3 = nn.Linear(100, 10)     # output layer (100 -> 10 classes)
+    def forward(self, x):
+        x = x.view(x.size(0), -1)         # flatten images into vectors of size 784
+        x = torch.relu(self.fc1(x))       # hidden layer 1 + ReLU activation
+        x = torch.relu(self.fc2(x))       # hidden layer 2 + ReLU activation
+        x = self.fc3(x)                   # output layer (logits for 10 classes)
+        return x
 
-np.random.seed(0)        #create same seed for random number every time
-
-cancer=load_breast_cancer()      #Download breast cancer dataset
-
-inputs=cancer.data                     #Feature matrix of 569 rows (samples) and 30 columns (parameters)
-outputs=cancer.target                  #Label array of 569 rows (0 for benign and 1 for malignant)
-labels=cancer.feature_names[0:30]
-
-print('The content of the breast cancer dataset is:')      #Print information about the datasets
-print(labels)
-print('-------------------------')
-print("inputs =  " + str(inputs.shape))
-print("outputs =  " + str(outputs.shape))
-print("labels =  "+ str(labels.shape))
-
-x=inputs      #Reassign the Feature and Label matrices to other variables
-y=outputs
-
-#%% 
-
-# Visualisation of dataset (for correlation analysis)
-
-plt.figure()
-plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean radius',fontweight='bold')
-plt.ylabel('Mean perimeter',fontweight='bold')
-plt.show()
-
-plt.figure()
-plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral)
-plt.xlabel('Mean compactness',fontweight='bold')
-plt.ylabel('Mean concavity',fontweight='bold')
-plt.show()
+model = NeuralNet().to(device)
 
 
-plt.figure()
-plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean radius',fontweight='bold')
-plt.ylabel('Mean texture',fontweight='bold')
-plt.show()
+criterion = nn.CrossEntropyLoss()
+optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)
 
-plt.figure()
-plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean perimeter',fontweight='bold')
-plt.ylabel('Mean compactness',fontweight='bold')
-plt.show()
+num_epochs = 10
+for epoch in range(num_epochs):
+    model.train()  # set model to training mode
+    running_loss = 0.0
+    for images, labels in train_loader:
+        # Move data to device (GPU if available, else CPU)
+        images, labels = images.to(device), labels.to(device)
+
+        optimizer.zero_grad()            # reset gradients to zero
+        outputs = model(images)          # forward pass: compute predictions
+        loss = criterion(outputs, labels)  # compute cross-entropy loss
+        loss.backward()                 # backpropagate to compute gradients
+        optimizer.step()                # update weights using SGD step 
+
+        running_loss += loss.item()
+    # Compute average loss over all batches in this epoch
+    avg_loss = running_loss / len(train_loader)
+    print(f"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}")
+
+#Evaluation on the Test Set
 
 
-# Generate training and testing datasets
 
-#Select features relevant to classification (texture,perimeter,compactness and symmetery) 
-#and add to input matrix
+model.eval()  # set model to evaluation mode 
+correct = 0
+total = 0
+with torch.no_grad():  # disable gradient calculation for evaluation 
+    for images, labels in test_loader:
+        images, labels = images.to(device), labels.to(device)
+        outputs = model(images)
+        _, predicted = torch.max(outputs, dim=1)  # class with highest score
+        total += labels.size(0)
+        correct += (predicted == labels).sum().item()
 
-temp1=np.reshape(x[:,1],(len(x[:,1]),1))
-temp2=np.reshape(x[:,2],(len(x[:,2]),1))
-X=np.hstack((temp1,temp2))      
-temp=np.reshape(x[:,5],(len(x[:,5]),1))
-X=np.hstack((X,temp))       
-temp=np.reshape(x[:,8],(len(x[:,8]),1))
-X=np.hstack((X,temp))       
-
-X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1)   #Split datasets into training and testing
-
-y_train=to_categorical(y_train)     #Convert labels to categorical when using categorical cross entropy
-y_test=to_categorical(y_test)
-
-del temp1,temp2,temp
-
-# %%
-
-# Define tunable parameters"
-
-eta=np.logspace(-3,-1,3)                    #Define vector of learning rates (parameter to SGD optimiser)
-lamda=0.01                                  #Define hyperparameter
-n_layers=2                                  #Define number of hidden layers in the model
-n_neuron=np.logspace(0,3,4,dtype=int)       #Define number of neurons per layer
-epochs=100                                   #Number of reiterations over the input data
-batch_size=100                              #Number of samples per gradient update
-
-# %%
-
-"""Define function to return Deep Neural Network model"""
-
-def NN_model(inputsize,n_layers,n_neuron,eta,lamda):
-    model=Sequential()      
-    for i in range(n_layers):       #Run loop to add hidden layers to the model
-        if (i==0):                  #First layer requires input dimensions
-            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize))
-        else:                       #Subsequent layers are capable of automatic shape inferencing
-            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda)))
-    model.add(Dense(2,activation='softmax'))  #2 outputs - ordered and disordered (softmax for prob)
-    sgd=optimizers.SGD(learning_rate=eta)
-    model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy'])
-    return model
-
-    
-Train_accuracy=np.zeros((len(n_neuron),len(eta)))      #Define matrices to store accuracy scores as a function
-Test_accuracy=np.zeros((len(n_neuron),len(eta)))       #of learning rate and number of hidden neurons for 
-
-for i in range(len(n_neuron)):     #run loops over hidden neurons and learning rates to calculate 
-    for j in range(len(eta)):      #accuracy scores 
-        DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda)
-        DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1)
-        Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1]
-        Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1]
-               
-
-def plot_data(x,y,data,title=None):
-
-    # plot results
-    fontsize=16
-
-
-    fig = plt.figure()
-    ax = fig.add_subplot(111)
-    cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1)
-    
-    cbar=fig.colorbar(cax)
-    cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize)
-    cbar.set_ticks([0,.2,.4,0.6,0.8,1.0])
-    cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%'])
-
-    # put text on matrix elements
-    for i, x_val in enumerate(np.arange(len(x))):
-        for j, y_val in enumerate(np.arange(len(y))):
-            c = "${0:.1f}\\%$".format( 100*data[j,i])  
-            ax.text(x_val, y_val, c, va='center', ha='center')
-
-    # convert axis vaues to to string labels
-    x=[str(i) for i in x]
-    y=[str(i) for i in y]
-
-
-    ax.set_xticklabels(['']+x)
-    ax.set_yticklabels(['']+y)
-
-    ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize)
-    ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize)
-    if title is not None:
-        ax.set_title(title)
-
-    plt.tight_layout()
-
-    plt.show()
-    
-plot_data(eta,n_neuron,Train_accuracy, 'training')
-plot_data(eta,n_neuron,Test_accuracy, 'testing')
+accuracy = 100 * correct / total
+print(f"Test Accuracy: {accuracy:.2f}%")
 
@@ -2551,7 +1106,81 @@ plot_data(eta,n_neuron,Test_accuracy, 'testing& -

Building a neural network code

+

And a similar example using Tensorflow with Keras

+ + + +
+
+
+
+
+
import tensorflow as tf
+from tensorflow import keras
+from tensorflow.keras import layers, regularizers
+
+# Check for GPU (TensorFlow will use it automatically if available)
+gpus = tf.config.list_physical_devices('GPU')
+print(f"GPUs available: {gpus}")
+
+# 1) Load and preprocess MNIST
+(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
+# Normalize to [0, 1]
+x_train = (x_train.astype("float32") / 255.0)
+x_test  = (x_test.astype("float32") / 255.0)
+
+# 2) Build the model: 784 -> 100 -> 100 -> 10
+l2_reg = 1e-4  # L2 regularization strength
+
+model = keras.Sequential([
+    layers.Input(shape=(28, 28)),
+    layers.Flatten(),
+    layers.Dense(100, activation="relu",
+                 kernel_regularizer=regularizers.l2(l2_reg)),
+    layers.Dense(100, activation="relu",
+                 kernel_regularizer=regularizers.l2(l2_reg)),
+    layers.Dense(10, activation="softmax")  # output probabilities for 10 classes
+])
+
+# 3) Compile with SGD + weight decay via L2 regularizers
+model.compile(
+    optimizer=keras.optimizers.SGD(learning_rate=0.01),
+    loss="sparse_categorical_crossentropy",
+    metrics=["accuracy"],
+)
+
+model.summary()
+
+# 4) Train
+history = model.fit(
+    x_train, y_train,
+    epochs=10,
+    batch_size=64,
+    validation_split=0.1,  # optional: monitor validation during training
+    verbose=1
+)
+
+# 5) Evaluate on test set
+test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
+print(f"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +

Building our own neural network code

Here we present a flexible object oriented codebase for a feed forward neural network, along with a demonstration of how @@ -6584,7 +5213,7 @@ $$ -->

- © 1999-2024, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2025, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
diff --git a/doc/pub/week43/html/week43-reveal.html b/doc/pub/week43/html/week43-reveal.html index 30320d347..6d8a445b5 100644 --- a/doc/pub/week43/html/week43-reveal.html +++ b/doc/pub/week43/html/week43-reveal.html @@ -173,24 +173,21 @@ MathJax.Hub.Config({
-Morten Hjorth-Jensen [1, 2] +Morten Hjorth-Jensen
- +
-[1] Department of Physics, University of Oslo -
-
-[2] Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University +Department of Physics, University of Oslo, Norway

-

October 21, 2024

+

October 20, 2025


- © 1999-2024, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2025, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
@@ -198,19 +195,16 @@ MathJax.Hub.Config({

Plans for week 43

-Material for the lecture on Monday October 21, 2024 +Material for the lecture on Monday October 20, 2025

@@ -231,44 +225,11 @@ MathJax.Hub.Config({
-
-

Mathematics of deep learning

- -
-Two recent books online -

-

    -

  1. The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at https://arxiv.org/abs/2105.04026, published as Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022
  2. -

  3. Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at https://doi.org/10.48550/arXiv.2310.20360
  4. -
-
-
- -
-

Reminder on books with hands-on material and codes

-
- -

-

-
-
- -
-

Reading recommendations

- -
    -

  1. Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at https://github.com/rasbt/machine-learning-book. See also chapters 12 and 13 on using Pytorch to make a Neural network code.
  2. -

  3. Goodfellow et al, chapter 6 and 7 contain most of the neural network background.
  4. -
-
-

Using Automatic differentiation

In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from week 39 and the Autograd documentation at https://github.com/HIPS/autograd. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.

@@ -284,12 +245,12 @@ we will also study the usage of Autograd, see for example Lecture Monday October 21 +

Lecture Monday October 20

Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations

-

This is a reminder from where we ended last week.

+

This is a reminder from last week.

The architecture (our model) @@ -499,1352 +460,6 @@ gradient descent optimization does in general not get stuck.
-
-

Setting up a Multi-layer perceptron model for classification

- -

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

- -

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

- -

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

-

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

 
- -

and

-

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

 
- -

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

-
- -
-

Defining the cost function

- -

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

-

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

 
- -

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

- -

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

- -

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

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

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

- -

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

- -

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

 
- -

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

- -

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

 
- -

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

- -

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

 
- -

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

- -

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

-
- -
-

Example: binary classification problem

- -

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

-

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

 
- -

where we had defined the logistic (sigmoid) function

-

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

 
- -

and

-

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

 
- -

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

- -

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

-

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

 
- -

with

-

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

 
- -

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

-

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

 
- -

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

-

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

 
- -

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

-
- -
-

The Softmax function

-

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

-

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

 
- -

For the Softmax function we have

-

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

 
- -

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

-

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

 
- -

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

-
- -
-

Developing a code for doing neural networks with back propagation

- -

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

- -
    -

  1. Collect and pre-process data
  2. - -

  3. Define model and architecture
  4. - -

  5. Choose cost function and optimizer
  6. - -

  7. Train the model
  8. - -

  9. Evaluate model performance on test data
  10. - -

  11. Adjust hyperparameters (if necessary, network architecture)
  12. -
-
- -
-

Collect and pre-process data

- -

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

- -

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

- -

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

- -

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

 
-

- -

and the targets would be:

- -

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

 

- -

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

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

Train and test datasets

- -

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

- -

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

- -

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

- - - -
-
-
-
-
-
from sklearn.model_selection import train_test_split
-
-# one-liner from scikit-learn library
-train_size = 0.8
-test_size = 1 - train_size
-X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
-                                                    test_size=test_size)
-
-# equivalently in numpy
-def train_test_split_numpy(inputs, labels, train_size, test_size):
-    n_inputs = len(inputs)
-    inputs_shuffled = inputs.copy()
-    labels_shuffled = labels.copy()
-    
-    np.random.shuffle(inputs_shuffled)
-    np.random.shuffle(labels_shuffled)
-    
-    train_end = int(n_inputs*train_size)
-    X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]
-    Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]
-    
-    return X_train, X_test, Y_train, Y_test
-
-#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)
-
-print("Number of training images: " + str(len(X_train)))
-print("Number of test images: " + str(len(X_test)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

Define model and architecture

- -

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

- -

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

 

- -

 
-$$ y = f(z) ,$$ -

 

- -

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

- -

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

- -

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

 
-

- -

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

- -

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

- -

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

- -

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

 

- -

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

-
- -
-

Layers

- -
    -

  • Input
  • -
-

-

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

- -
    -

  • Hidden layer
  • -
-

-

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

- -
    -

  • Output
  • -
-

-

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

- -

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

- -

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

- -

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

 
-

- -

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

- -

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

 

- -

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

-
- -
-

Weights and biases

- -

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

- -

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

- -

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

 

- -

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

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

Feed-forward pass

- -

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

- -

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

 

- -

this is then passed through our activation function

- -

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

 

- -

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

- -

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

 

- -

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

- -

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

 
-

-
- -
-

Matrix multiplications

- -

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

- -

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

 

- -

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

- -

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

 

- -

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

- -

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

 

- -

This is fed to the output layer:

- -

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

 

- -

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

- -

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

 

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

Choose cost function and optimizer

- -

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

- -

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

- -

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

 

- -

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

 

- -

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

- -

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

- -

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

-
- -
-

Optimizing the cost function

- -

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

- -

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

 

- -

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

- -

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

- -

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

 
-

- -

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

- -

This has two important benefits:

-
    -

  1. Introducing stochasticity decreases the chance that the algorithm becomes stuck in a local minima.
  2. - -

  3. It significantly speeds up the calculation, since we do not have to use the entire dataset to calculate the gradient.
  4. -
-

-

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

-
- -
-

Regularization

- -

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

- -

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

- -

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

 
-

- -

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

- -

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

-
- -
-

Matrix multiplication

- -

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

- -

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

 

- -

The gradient for the output weights is calculated as

- -

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

 

- -

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

- -

The gradient with respect to the output bias is then

- -

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

 

- -

The error in the hidden layer is

- -

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

 

- -

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

- -

This again gives us the gradients in the hidden layer:

- -

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

 

- -

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

 

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

Improving performance

- -

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

- -

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

- -

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

- -

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

-
- -
-

Full object-oriented implementation

- -

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

- - - -
-
-
-
-
-
class NeuralNetwork:
-    def __init__(
-            self,
-            X_data,
-            Y_data,
-            n_hidden_neurons=50,
-            n_categories=10,
-            epochs=10,
-            batch_size=100,
-            eta=0.1,
-            lmbd=0.0):
-
-        self.X_data_full = X_data
-        self.Y_data_full = Y_data
-
-        self.n_inputs = X_data.shape[0]
-        self.n_features = X_data.shape[1]
-        self.n_hidden_neurons = n_hidden_neurons
-        self.n_categories = n_categories
-
-        self.epochs = epochs
-        self.batch_size = batch_size
-        self.iterations = self.n_inputs // self.batch_size
-        self.eta = eta
-        self.lmbd = lmbd
-
-        self.create_biases_and_weights()
-
-    def create_biases_and_weights(self):
-        self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)
-        self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01
-
-        self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)
-        self.output_bias = np.zeros(self.n_categories) + 0.01
-
-    def feed_forward(self):
-        # feed-forward for training
-        self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias
-        self.a_h = sigmoid(self.z_h)
-
-        self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias
-
-        exp_term = np.exp(self.z_o)
-        self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
-
-    def feed_forward_out(self, X):
-        # feed-forward for output
-        z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias
-        a_h = sigmoid(z_h)
-
-        z_o = np.matmul(a_h, self.output_weights) + self.output_bias
-        
-        exp_term = np.exp(z_o)
-        probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
-        return probabilities
-
-    def backpropagation(self):
-        error_output = self.probabilities - self.Y_data
-        error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)
-
-        self.output_weights_gradient = np.matmul(self.a_h.T, error_output)
-        self.output_bias_gradient = np.sum(error_output, axis=0)
-
-        self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)
-        self.hidden_bias_gradient = np.sum(error_hidden, axis=0)
-
-        if self.lmbd > 0.0:
-            self.output_weights_gradient += self.lmbd * self.output_weights
-            self.hidden_weights_gradient += self.lmbd * self.hidden_weights
-
-        self.output_weights -= self.eta * self.output_weights_gradient
-        self.output_bias -= self.eta * self.output_bias_gradient
-        self.hidden_weights -= self.eta * self.hidden_weights_gradient
-        self.hidden_bias -= self.eta * self.hidden_bias_gradient
-
-    def predict(self, X):
-        probabilities = self.feed_forward_out(X)
-        return np.argmax(probabilities, axis=1)
-
-    def predict_probabilities(self, X):
-        probabilities = self.feed_forward_out(X)
-        return probabilities
-
-    def train(self):
-        data_indices = np.arange(self.n_inputs)
-
-        for i in range(self.epochs):
-            for j in range(self.iterations):
-                # pick datapoints with replacement
-                chosen_datapoints = np.random.choice(
-                    data_indices, size=self.batch_size, replace=False
-                )
-
-                # minibatch training data
-                self.X_data = self.X_data_full[chosen_datapoints]
-                self.Y_data = self.Y_data_full[chosen_datapoints]
-
-                self.feed_forward()
-                self.backpropagation()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

Evaluate model performance on test data

- -

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

- -

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

 

- -

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

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

Adjust hyperparameters

- -

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

- - - -
-
-
-
-
-
eta_vals = np.logspace(-5, 1, 7)
-lmbd_vals = np.logspace(-5, 1, 7)
-# store the models for later use
-DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
-
-# grid search
-for i, eta in enumerate(eta_vals):
-    for j, lmbd in enumerate(lmbd_vals):
-        dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,
-                            n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)
-        dnn.train()
-        
-        DNN_numpy[i][j] = dnn
-        
-        test_predict = dnn.predict(X_test)
-        
-        print("Learning rate  = ", eta)
-        print("Lambda = ", lmbd)
-        print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))
-        print()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

Visualization

- - - -
-
-
-
-
-
# visual representation of grid search
-# uses seaborn heatmap, you can also do this with matplotlib imshow
-import seaborn as sns
-
-sns.set()
-
-train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-
-for i in range(len(eta_vals)):
-    for j in range(len(lmbd_vals)):
-        dnn = DNN_numpy[i][j]
-        
-        train_pred = dnn.predict(X_train) 
-        test_pred = dnn.predict(X_test)
-
-        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
-        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
-
-        
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Training Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Test Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

scikit-learn implementation

- -

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

- -

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

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

Visualization

- - -
-
-
-
-
-
# optional
-# visual representation of grid search
-# uses seaborn heatmap, could probably do this in matplotlib
-import seaborn as sns
-
-sns.set()
-
-train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
-
-for i in range(len(eta_vals)):
-    for j in range(len(lmbd_vals)):
-        dnn = DNN_scikit[i][j]
-        
-        train_pred = dnn.predict(X_train) 
-        test_pred = dnn.predict(X_test)
-
-        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
-        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
-
-        
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Training Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-fig, ax = plt.subplots(figsize = (10, 10))
-sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
-ax.set_title("Test Accuracy")
-ax.set_ylabel("$\eta$")
-ax.set_xlabel("$\lambda$")
-plt.show()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Building neural networks in Tensorflow and Keras

@@ -2228,7 +843,7 @@ plt.show()
-

The Breast Cancer Data, now with Keras

+

Using Pytorch with the full MNIST data set

@@ -2237,171 +852,82 @@ plt.show()
-
import tensorflow as tf
-from tensorflow.keras.layers import Input
-from tensorflow.keras.models import Sequential      #This allows appending layers to existing models
-from tensorflow.keras.layers import Dense           #This allows defining the characteristics of a particular layer
-from tensorflow.keras import optimizers             #This allows using whichever optimiser we want (sgd,adam,RMSprop)
-from tensorflow.keras import regularizers           #This allows using whichever regularizer we want (l1,l2,l1_l2)
-from tensorflow.keras.utils import to_categorical   #This allows using categorical cross entropy as the cost function
-import numpy as np
-import matplotlib.pyplot as plt
-import seaborn as sns
-from sklearn.model_selection import train_test_split as splitter
-from sklearn.datasets import load_breast_cancer
-import pickle
-import os 
+  
import torch
+import torch.nn as nn
+import torch.optim as optim
+import torchvision
+import torchvision.transforms as transforms
+
+# Device configuration: use GPU if available
+device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
+
+# MNIST dataset (downloads if not already present)
+transform = transforms.Compose([
+    transforms.ToTensor(),
+    transforms.Normalize((0.5,), (0.5,))  # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)
+])
+train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)
+test_dataset  = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)
+
+train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)
+test_loader  = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)
 
 
-"""Load breast cancer dataset"""
+class NeuralNet(nn.Module):
+    def __init__(self):
+        super(NeuralNet, self).__init__()
+        self.fc1 = nn.Linear(28*28, 100)   # first hidden layer (784 -> 100)
+        self.fc2 = nn.Linear(100, 100)    # second hidden layer (100 -> 100)
+        self.fc3 = nn.Linear(100, 10)     # output layer (100 -> 10 classes)
+    def forward(self, x):
+        x = x.view(x.size(0), -1)         # flatten images into vectors of size 784
+        x = torch.relu(self.fc1(x))       # hidden layer 1 + ReLU activation
+        x = torch.relu(self.fc2(x))       # hidden layer 2 + ReLU activation
+        x = self.fc3(x)                   # output layer (logits for 10 classes)
+        return x
 
-np.random.seed(0)        #create same seed for random number every time
-
-cancer=load_breast_cancer()      #Download breast cancer dataset
-
-inputs=cancer.data                     #Feature matrix of 569 rows (samples) and 30 columns (parameters)
-outputs=cancer.target                  #Label array of 569 rows (0 for benign and 1 for malignant)
-labels=cancer.feature_names[0:30]
-
-print('The content of the breast cancer dataset is:')      #Print information about the datasets
-print(labels)
-print('-------------------------')
-print("inputs =  " + str(inputs.shape))
-print("outputs =  " + str(outputs.shape))
-print("labels =  "+ str(labels.shape))
-
-x=inputs      #Reassign the Feature and Label matrices to other variables
-y=outputs
-
-#%% 
-
-# Visualisation of dataset (for correlation analysis)
-
-plt.figure()
-plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean radius',fontweight='bold')
-plt.ylabel('Mean perimeter',fontweight='bold')
-plt.show()
-
-plt.figure()
-plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral)
-plt.xlabel('Mean compactness',fontweight='bold')
-plt.ylabel('Mean concavity',fontweight='bold')
-plt.show()
+model = NeuralNet().to(device)
 
 
-plt.figure()
-plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean radius',fontweight='bold')
-plt.ylabel('Mean texture',fontweight='bold')
-plt.show()
+criterion = nn.CrossEntropyLoss()
+optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)
 
-plt.figure()
-plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
-plt.xlabel('Mean perimeter',fontweight='bold')
-plt.ylabel('Mean compactness',fontweight='bold')
-plt.show()
+num_epochs = 10
+for epoch in range(num_epochs):
+    model.train()  # set model to training mode
+    running_loss = 0.0
+    for images, labels in train_loader:
+        # Move data to device (GPU if available, else CPU)
+        images, labels = images.to(device), labels.to(device)
+
+        optimizer.zero_grad()            # reset gradients to zero
+        outputs = model(images)          # forward pass: compute predictions
+        loss = criterion(outputs, labels)  # compute cross-entropy loss
+        loss.backward()                 # backpropagate to compute gradients
+        optimizer.step()                # update weights using SGD step 
+
+        running_loss += loss.item()
+    # Compute average loss over all batches in this epoch
+    avg_loss = running_loss / len(train_loader)
+    print(f"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}")
+
+#Evaluation on the Test Set
 
 
-# Generate training and testing datasets
 
-#Select features relevant to classification (texture,perimeter,compactness and symmetery) 
-#and add to input matrix
+model.eval()  # set model to evaluation mode 
+correct = 0
+total = 0
+with torch.no_grad():  # disable gradient calculation for evaluation 
+    for images, labels in test_loader:
+        images, labels = images.to(device), labels.to(device)
+        outputs = model(images)
+        _, predicted = torch.max(outputs, dim=1)  # class with highest score
+        total += labels.size(0)
+        correct += (predicted == labels).sum().item()
 
-temp1=np.reshape(x[:,1],(len(x[:,1]),1))
-temp2=np.reshape(x[:,2],(len(x[:,2]),1))
-X=np.hstack((temp1,temp2))      
-temp=np.reshape(x[:,5],(len(x[:,5]),1))
-X=np.hstack((X,temp))       
-temp=np.reshape(x[:,8],(len(x[:,8]),1))
-X=np.hstack((X,temp))       
-
-X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1)   #Split datasets into training and testing
-
-y_train=to_categorical(y_train)     #Convert labels to categorical when using categorical cross entropy
-y_test=to_categorical(y_test)
-
-del temp1,temp2,temp
-
-# %%
-
-# Define tunable parameters"
-
-eta=np.logspace(-3,-1,3)                    #Define vector of learning rates (parameter to SGD optimiser)
-lamda=0.01                                  #Define hyperparameter
-n_layers=2                                  #Define number of hidden layers in the model
-n_neuron=np.logspace(0,3,4,dtype=int)       #Define number of neurons per layer
-epochs=100                                   #Number of reiterations over the input data
-batch_size=100                              #Number of samples per gradient update
-
-# %%
-
-"""Define function to return Deep Neural Network model"""
-
-def NN_model(inputsize,n_layers,n_neuron,eta,lamda):
-    model=Sequential()      
-    for i in range(n_layers):       #Run loop to add hidden layers to the model
-        if (i==0):                  #First layer requires input dimensions
-            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize))
-        else:                       #Subsequent layers are capable of automatic shape inferencing
-            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda)))
-    model.add(Dense(2,activation='softmax'))  #2 outputs - ordered and disordered (softmax for prob)
-    sgd=optimizers.SGD(learning_rate=eta)
-    model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy'])
-    return model
-
-    
-Train_accuracy=np.zeros((len(n_neuron),len(eta)))      #Define matrices to store accuracy scores as a function
-Test_accuracy=np.zeros((len(n_neuron),len(eta)))       #of learning rate and number of hidden neurons for 
-
-for i in range(len(n_neuron)):     #run loops over hidden neurons and learning rates to calculate 
-    for j in range(len(eta)):      #accuracy scores 
-        DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda)
-        DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1)
-        Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1]
-        Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1]
-               
-
-def plot_data(x,y,data,title=None):
-
-    # plot results
-    fontsize=16
-
-
-    fig = plt.figure()
-    ax = fig.add_subplot(111)
-    cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1)
-    
-    cbar=fig.colorbar(cax)
-    cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize)
-    cbar.set_ticks([0,.2,.4,0.6,0.8,1.0])
-    cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%'])
-
-    # put text on matrix elements
-    for i, x_val in enumerate(np.arange(len(x))):
-        for j, y_val in enumerate(np.arange(len(y))):
-            c = "${0:.1f}\\%$".format( 100*data[j,i])  
-            ax.text(x_val, y_val, c, va='center', ha='center')
-
-    # convert axis vaues to to string labels
-    x=[str(i) for i in x]
-    y=[str(i) for i in y]
-
-
-    ax.set_xticklabels(['']+x)
-    ax.set_yticklabels(['']+y)
-
-    ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize)
-    ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize)
-    if title is not None:
-        ax.set_title(title)
-
-    plt.tight_layout()
-
-    plt.show()
-    
-plot_data(eta,n_neuron,Train_accuracy, 'training')
-plot_data(eta,n_neuron,Test_accuracy, 'testing')
+accuracy = 100 * correct / total
+print(f"Test Accuracy: {accuracy:.2f}%")
 
@@ -2419,7 +945,81 @@ plot_data(eta,n_neuron,Test_accuracy, 'testing&
-

Building a neural network code

+

And a similar example using Tensorflow with Keras

+ + + +
+
+
+
+
+
import tensorflow as tf
+from tensorflow import keras
+from tensorflow.keras import layers, regularizers
+
+# Check for GPU (TensorFlow will use it automatically if available)
+gpus = tf.config.list_physical_devices('GPU')
+print(f"GPUs available: {gpus}")
+
+# 1) Load and preprocess MNIST
+(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
+# Normalize to [0, 1]
+x_train = (x_train.astype("float32") / 255.0)
+x_test  = (x_test.astype("float32") / 255.0)
+
+# 2) Build the model: 784 -> 100 -> 100 -> 10
+l2_reg = 1e-4  # L2 regularization strength
+
+model = keras.Sequential([
+    layers.Input(shape=(28, 28)),
+    layers.Flatten(),
+    layers.Dense(100, activation="relu",
+                 kernel_regularizer=regularizers.l2(l2_reg)),
+    layers.Dense(100, activation="relu",
+                 kernel_regularizer=regularizers.l2(l2_reg)),
+    layers.Dense(10, activation="softmax")  # output probabilities for 10 classes
+])
+
+# 3) Compile with SGD + weight decay via L2 regularizers
+model.compile(
+    optimizer=keras.optimizers.SGD(learning_rate=0.01),
+    loss="sparse_categorical_crossentropy",
+    metrics=["accuracy"],
+)
+
+model.summary()
+
+# 4) Train
+history = model.fit(
+    x_train, y_train,
+    epochs=10,
+    batch_size=64,
+    validation_split=0.1,  # optional: monitor validation during training
+    verbose=1
+)
+
+# 5) Evaluate on test set
+test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
+print(f"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

Building our own neural network code

Here we present a flexible object oriented codebase for a feed forward neural network, along with a demonstration of how diff --git a/doc/pub/week43/html/week43-solarized.html b/doc/pub/week43/html/week43-solarized.html index 2650fd3cb..aad94e9d9 100644 --- a/doc/pub/week43/html/week43-solarized.html +++ b/doc/pub/week43/html/week43-solarized.html @@ -68,15 +68,6 @@ div.toc p,a { 2, None, 'exercises-and-lab-session-week-43'), - ('Mathematics of deep learning', - 2, - None, - 'mathematics-of-deep-learning'), - ('Reminder on books with hands-on material and codes', - 2, - None, - 'reminder-on-books-with-hands-on-material-and-codes'), - ('Reading recommendations', 2, None, 'reading-recommendations'), ('Using Automatic differentiation', 2, None, @@ -85,10 +76,10 @@ div.toc p,a { 2, None, 'back-propagation-and-automatic-differentiation'), - ('Lecture Monday October 21', + ('Lecture Monday October 20', 2, None, - 'lecture-monday-october-21'), + 'lecture-monday-october-20'), ('Setting up the back propagation algorithm and algorithm for a ' 'feed forward NN, initalizations', 2, @@ -122,63 +113,6 @@ div.toc p,a { 2, None, 'more-on-activation-functions-output-layers'), - ('Setting up a Multi-layer perceptron model for classification', - 2, - None, - 'setting-up-a-multi-layer-perceptron-model-for-classification'), - ('Defining the cost function', - 2, - None, - 'defining-the-cost-function'), - ('Example: binary classification problem', - 2, - None, - 'example-binary-classification-problem'), - ('The Softmax function', 2, None, 'the-softmax-function'), - ('Developing a code for doing neural networks with back ' - 'propagation', - 2, - None, - 'developing-a-code-for-doing-neural-networks-with-back-propagation'), - ('Collect and pre-process data', - 2, - None, - 'collect-and-pre-process-data'), - ('Train and test datasets', 2, None, 'train-and-test-datasets'), - ('Define model and architecture', - 2, - None, - 'define-model-and-architecture'), - ('Layers', 2, None, 'layers'), - ('Weights and biases', 2, None, 'weights-and-biases'), - ('Feed-forward pass', 2, None, 'feed-forward-pass'), - ('Matrix multiplications', 2, None, 'matrix-multiplications'), - ('Choose cost function and optimizer', - 2, - None, - 'choose-cost-function-and-optimizer'), - ('Optimizing the cost function', - 2, - None, - 'optimizing-the-cost-function'), - ('Regularization', 2, None, 'regularization'), - ('Matrix multiplication', 2, None, 'matrix-multiplication'), - ('Improving performance', 2, None, 'improving-performance'), - ('Full object-oriented implementation', - 2, - None, - 'full-object-oriented-implementation'), - ('Evaluate model performance on test data', - 2, - None, - 'evaluate-model-performance-on-test-data'), - ('Adjust hyperparameters', 2, None, 'adjust-hyperparameters'), - ('Visualization', 2, None, 'visualization'), - ('scikit-learn implementation', - 2, - None, - 'scikit-learn-implementation'), - ('Visualization', 2, None, 'visualization'), ('Building neural networks in Tensorflow and Keras', 2, None, @@ -189,14 +123,18 @@ div.toc p,a { 2, None, 'collect-and-pre-process-data'), - ('The Breast Cancer Data, now with Keras', + ('Using Pytorch with the full MNIST data set', 2, None, - 'the-breast-cancer-data-now-with-keras'), - ('Building a neural network code', + 'using-pytorch-with-the-full-mnist-data-set'), + ('And a similar example using Tensorflow with Keras', 2, None, - 'building-a-neural-network-code'), + 'and-a-similar-example-using-tensorflow-with-keras'), + ('Building our own neural network code', + 2, + None, + 'building-our-own-neural-network-code'), ('Learning rate methods', 3, None, 'learning-rate-methods'), ('Usage of the above learning rate schedulers', 3, @@ -361,18 +299,15 @@ MathJax.Hub.Config({

-Morten Hjorth-Jensen [1, 2] +Morten Hjorth-Jensen
- +
-[1] Department of Physics, University of Oslo -
-
-[2] Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University +Department of Physics, University of Oslo, Norway

-

October 21, 2024

+

October 20, 2025


@@ -380,14 +315,14 @@ MathJax.Hub.Config({

Plans for week 43

-Material for the lecture on Monday October 21, 2024 +Material for the lecture on Monday October 20, 2025

@@ -405,42 +340,11 @@ MathJax.Hub.Config({ -









-

Mathematics of deep learning

- -
-Two recent books online -

-

    -
  1. The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at https://arxiv.org/abs/2105.04026, published as Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022
  2. -
  3. Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at https://doi.org/10.48550/arXiv.2310.20360
  4. -
-
- - -









-

Reminder on books with hands-on material and codes

-
- -

-

-
- - -









-

Reading recommendations

- -
    -
  1. Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at https://github.com/rasbt/machine-learning-book. See also chapters 12 and 13 on using Pytorch to make a Neural network code.
  2. -
  3. Goodfellow et al, chapter 6 and 7 contain most of the neural network background.
  4. -










Using Automatic differentiation

In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from week 39 and the Autograd documentation at https://github.com/HIPS/autograd. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.











@@ -453,11 +357,11 @@ we will also study the usage of Autograd, see for example http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture4.pdf









-

Lecture Monday October 21

+

Lecture Monday October 20











Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations

-

This is a reminder from where we ended last week.

+

This is a reminder from last week.

The architecture (our model) @@ -637,1239 +541,6 @@ gradient descent optimization does in general not get stuck.
  • For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).
  • For regression tasks, you can simply use no activation function at all.
  • - -

    Setting up a Multi-layer perceptron model for classification

    - -

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

    - -

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

    - -

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

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

    and

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

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

    - - -









    -

    Defining the cost function

    - -

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

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

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

    - -

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

    - -

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

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

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

    - -

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

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

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

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

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

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

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

    - -

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

    - -









    -

    Example: binary classification problem

    - -

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

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

    where we had defined the logistic (sigmoid) function

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

    and

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

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

    - -

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

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

    with

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

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

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

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

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

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

    - -









    -

    The Softmax function

    -

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

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

    For the Softmax function we have

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

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

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

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

    - - -

    Developing a code for doing neural networks with back propagation

    - -

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

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









    -

    Collect and pre-process data

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    and the targets would be:

    - -

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

    - -

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

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









    -

    Train and test datasets

    - -

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

    - -

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

    - -

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

    - - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -
    -# one-liner from scikit-learn library
    -train_size = 0.8
    -test_size = 1 - train_size
    -X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
    -                                                    test_size=test_size)
    -
    -# equivalently in numpy
    -def train_test_split_numpy(inputs, labels, train_size, test_size):
    -    n_inputs = len(inputs)
    -    inputs_shuffled = inputs.copy()
    -    labels_shuffled = labels.copy()
    -    
    -    np.random.shuffle(inputs_shuffled)
    -    np.random.shuffle(labels_shuffled)
    -    
    -    train_end = int(n_inputs*train_size)
    -    X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]
    -    Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]
    -    
    -    return X_train, X_test, Y_train, Y_test
    -
    -#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)
    -
    -print("Number of training images: " + str(len(X_train)))
    -print("Number of test images: " + str(len(X_test)))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Define model and architecture

    - -

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

    - -

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

    - -

    $$ y = f(z) ,$$

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Layers

    - -
      -
    • Input
    • -
    -

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

    - -
      -
    • Hidden layer
    • -
    -

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

    - -
      -
    • Output
    • -
    -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Weights and biases

    - -

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

    - -

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

    - -

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

    - -

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

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









    -

    Feed-forward pass

    - -

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

    - -

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

    - -

    this is then passed through our activation function

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Matrix multiplications

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    This is fed to the output layer:

    - -

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

    - -

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

    - -

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

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









    -

    Choose cost function and optimizer

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -









    -

    Optimizing the cost function

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    This has two important benefits:

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

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

    - - -

    Regularization

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -









    -

    Matrix multiplication

    - -

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

    - -

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

    - -

    The gradient for the output weights is calculated as

    - -

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

    - -

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

    - -

    The gradient with respect to the output bias is then

    - -

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

    - -

    The error in the hidden layer is

    - -

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

    - -

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

    - -

    This again gives us the gradients in the hidden layer:

    - -

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

    - -

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

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









    -

    Improving performance

    - -

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

    - -

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

    - -

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

    - -

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

    - -









    -

    Full object-oriented implementation

    - -

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

    - - - -
    -
    -
    -
    -
    -
    class NeuralNetwork:
    -    def __init__(
    -            self,
    -            X_data,
    -            Y_data,
    -            n_hidden_neurons=50,
    -            n_categories=10,
    -            epochs=10,
    -            batch_size=100,
    -            eta=0.1,
    -            lmbd=0.0):
    -
    -        self.X_data_full = X_data
    -        self.Y_data_full = Y_data
    -
    -        self.n_inputs = X_data.shape[0]
    -        self.n_features = X_data.shape[1]
    -        self.n_hidden_neurons = n_hidden_neurons
    -        self.n_categories = n_categories
    -
    -        self.epochs = epochs
    -        self.batch_size = batch_size
    -        self.iterations = self.n_inputs // self.batch_size
    -        self.eta = eta
    -        self.lmbd = lmbd
    -
    -        self.create_biases_and_weights()
    -
    -    def create_biases_and_weights(self):
    -        self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)
    -        self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01
    -
    -        self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)
    -        self.output_bias = np.zeros(self.n_categories) + 0.01
    -
    -    def feed_forward(self):
    -        # feed-forward for training
    -        self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias
    -        self.a_h = sigmoid(self.z_h)
    -
    -        self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias
    -
    -        exp_term = np.exp(self.z_o)
    -        self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    -
    -    def feed_forward_out(self, X):
    -        # feed-forward for output
    -        z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias
    -        a_h = sigmoid(z_h)
    -
    -        z_o = np.matmul(a_h, self.output_weights) + self.output_bias
    -        
    -        exp_term = np.exp(z_o)
    -        probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    -        return probabilities
    -
    -    def backpropagation(self):
    -        error_output = self.probabilities - self.Y_data
    -        error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)
    -
    -        self.output_weights_gradient = np.matmul(self.a_h.T, error_output)
    -        self.output_bias_gradient = np.sum(error_output, axis=0)
    -
    -        self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)
    -        self.hidden_bias_gradient = np.sum(error_hidden, axis=0)
    -
    -        if self.lmbd > 0.0:
    -            self.output_weights_gradient += self.lmbd * self.output_weights
    -            self.hidden_weights_gradient += self.lmbd * self.hidden_weights
    -
    -        self.output_weights -= self.eta * self.output_weights_gradient
    -        self.output_bias -= self.eta * self.output_bias_gradient
    -        self.hidden_weights -= self.eta * self.hidden_weights_gradient
    -        self.hidden_bias -= self.eta * self.hidden_bias_gradient
    -
    -    def predict(self, X):
    -        probabilities = self.feed_forward_out(X)
    -        return np.argmax(probabilities, axis=1)
    -
    -    def predict_probabilities(self, X):
    -        probabilities = self.feed_forward_out(X)
    -        return probabilities
    -
    -    def train(self):
    -        data_indices = np.arange(self.n_inputs)
    -
    -        for i in range(self.epochs):
    -            for j in range(self.iterations):
    -                # pick datapoints with replacement
    -                chosen_datapoints = np.random.choice(
    -                    data_indices, size=self.batch_size, replace=False
    -                )
    -
    -                # minibatch training data
    -                self.X_data = self.X_data_full[chosen_datapoints]
    -                self.Y_data = self.Y_data_full[chosen_datapoints]
    -
    -                self.feed_forward()
    -                self.backpropagation()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Evaluate model performance on test data

    - -

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

    - -

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

    - -

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

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









    -

    Adjust hyperparameters

    - -

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

    - - - -
    -
    -
    -
    -
    -
    eta_vals = np.logspace(-5, 1, 7)
    -lmbd_vals = np.logspace(-5, 1, 7)
    -# store the models for later use
    -DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
    -
    -# grid search
    -for i, eta in enumerate(eta_vals):
    -    for j, lmbd in enumerate(lmbd_vals):
    -        dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,
    -                            n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)
    -        dnn.train()
    -        
    -        DNN_numpy[i][j] = dnn
    -        
    -        test_predict = dnn.predict(X_test)
    -        
    -        print("Learning rate  = ", eta)
    -        print("Lambda = ", lmbd)
    -        print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))
    -        print()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Visualization

    - - - -
    -
    -
    -
    -
    -
    # visual representation of grid search
    -# uses seaborn heatmap, you can also do this with matplotlib imshow
    -import seaborn as sns
    -
    -sns.set()
    -
    -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -
    -for i in range(len(eta_vals)):
    -    for j in range(len(lmbd_vals)):
    -        dnn = DNN_numpy[i][j]
    -        
    -        train_pred = dnn.predict(X_train) 
    -        test_pred = dnn.predict(X_test)
    -
    -        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
    -        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
    -
    -        
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Training Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Test Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    scikit-learn implementation

    - -

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

    - -

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

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









    -

    Visualization

    - - -
    -
    -
    -
    -
    -
    # optional
    -# visual representation of grid search
    -# uses seaborn heatmap, could probably do this in matplotlib
    -import seaborn as sns
    -
    -sns.set()
    -
    -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -
    -for i in range(len(eta_vals)):
    -    for j in range(len(lmbd_vals)):
    -        dnn = DNN_scikit[i][j]
    -        
    -        train_pred = dnn.predict(X_train) 
    -        test_pred = dnn.predict(X_test)
    -
    -        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
    -        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
    -
    -        
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Training Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Test Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -









    Building neural networks in Tensorflow and Keras

    @@ -2251,7 +922,7 @@ plt.show()









    -

    The Breast Cancer Data, now with Keras

    +

    Using Pytorch with the full MNIST data set

    @@ -2260,171 +931,82 @@ plt.show()
    -
    import tensorflow as tf
    -from tensorflow.keras.layers import Input
    -from tensorflow.keras.models import Sequential      #This allows appending layers to existing models
    -from tensorflow.keras.layers import Dense           #This allows defining the characteristics of a particular layer
    -from tensorflow.keras import optimizers             #This allows using whichever optimiser we want (sgd,adam,RMSprop)
    -from tensorflow.keras import regularizers           #This allows using whichever regularizer we want (l1,l2,l1_l2)
    -from tensorflow.keras.utils import to_categorical   #This allows using categorical cross entropy as the cost function
    -import numpy as np
    -import matplotlib.pyplot as plt
    -import seaborn as sns
    -from sklearn.model_selection import train_test_split as splitter
    -from sklearn.datasets import load_breast_cancer
    -import pickle
    -import os 
    +  
    import torch
    +import torch.nn as nn
    +import torch.optim as optim
    +import torchvision
    +import torchvision.transforms as transforms
    +
    +# Device configuration: use GPU if available
    +device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    +
    +# MNIST dataset (downloads if not already present)
    +transform = transforms.Compose([
    +    transforms.ToTensor(),
    +    transforms.Normalize((0.5,), (0.5,))  # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)
    +])
    +train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)
    +test_dataset  = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)
    +
    +train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)
    +test_loader  = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)
     
     
    -"""Load breast cancer dataset"""
    +class NeuralNet(nn.Module):
    +    def __init__(self):
    +        super(NeuralNet, self).__init__()
    +        self.fc1 = nn.Linear(28*28, 100)   # first hidden layer (784 -> 100)
    +        self.fc2 = nn.Linear(100, 100)    # second hidden layer (100 -> 100)
    +        self.fc3 = nn.Linear(100, 10)     # output layer (100 -> 10 classes)
    +    def forward(self, x):
    +        x = x.view(x.size(0), -1)         # flatten images into vectors of size 784
    +        x = torch.relu(self.fc1(x))       # hidden layer 1 + ReLU activation
    +        x = torch.relu(self.fc2(x))       # hidden layer 2 + ReLU activation
    +        x = self.fc3(x)                   # output layer (logits for 10 classes)
    +        return x
     
    -np.random.seed(0)        #create same seed for random number every time
    -
    -cancer=load_breast_cancer()      #Download breast cancer dataset
    -
    -inputs=cancer.data                     #Feature matrix of 569 rows (samples) and 30 columns (parameters)
    -outputs=cancer.target                  #Label array of 569 rows (0 for benign and 1 for malignant)
    -labels=cancer.feature_names[0:30]
    -
    -print('The content of the breast cancer dataset is:')      #Print information about the datasets
    -print(labels)
    -print('-------------------------')
    -print("inputs =  " + str(inputs.shape))
    -print("outputs =  " + str(outputs.shape))
    -print("labels =  "+ str(labels.shape))
    -
    -x=inputs      #Reassign the Feature and Label matrices to other variables
    -y=outputs
    -
    -#%% 
    -
    -# Visualisation of dataset (for correlation analysis)
    -
    -plt.figure()
    -plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean radius',fontweight='bold')
    -plt.ylabel('Mean perimeter',fontweight='bold')
    -plt.show()
    -
    -plt.figure()
    -plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral)
    -plt.xlabel('Mean compactness',fontweight='bold')
    -plt.ylabel('Mean concavity',fontweight='bold')
    -plt.show()
    +model = NeuralNet().to(device)
     
     
    -plt.figure()
    -plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean radius',fontweight='bold')
    -plt.ylabel('Mean texture',fontweight='bold')
    -plt.show()
    +criterion = nn.CrossEntropyLoss()
    +optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)
     
    -plt.figure()
    -plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean perimeter',fontweight='bold')
    -plt.ylabel('Mean compactness',fontweight='bold')
    -plt.show()
    +num_epochs = 10
    +for epoch in range(num_epochs):
    +    model.train()  # set model to training mode
    +    running_loss = 0.0
    +    for images, labels in train_loader:
    +        # Move data to device (GPU if available, else CPU)
    +        images, labels = images.to(device), labels.to(device)
    +
    +        optimizer.zero_grad()            # reset gradients to zero
    +        outputs = model(images)          # forward pass: compute predictions
    +        loss = criterion(outputs, labels)  # compute cross-entropy loss
    +        loss.backward()                 # backpropagate to compute gradients
    +        optimizer.step()                # update weights using SGD step 
    +
    +        running_loss += loss.item()
    +    # Compute average loss over all batches in this epoch
    +    avg_loss = running_loss / len(train_loader)
    +    print(f"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}")
    +
    +#Evaluation on the Test Set
     
     
    -# Generate training and testing datasets
     
    -#Select features relevant to classification (texture,perimeter,compactness and symmetery) 
    -#and add to input matrix
    +model.eval()  # set model to evaluation mode 
    +correct = 0
    +total = 0
    +with torch.no_grad():  # disable gradient calculation for evaluation 
    +    for images, labels in test_loader:
    +        images, labels = images.to(device), labels.to(device)
    +        outputs = model(images)
    +        _, predicted = torch.max(outputs, dim=1)  # class with highest score
    +        total += labels.size(0)
    +        correct += (predicted == labels).sum().item()
     
    -temp1=np.reshape(x[:,1],(len(x[:,1]),1))
    -temp2=np.reshape(x[:,2],(len(x[:,2]),1))
    -X=np.hstack((temp1,temp2))      
    -temp=np.reshape(x[:,5],(len(x[:,5]),1))
    -X=np.hstack((X,temp))       
    -temp=np.reshape(x[:,8],(len(x[:,8]),1))
    -X=np.hstack((X,temp))       
    -
    -X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1)   #Split datasets into training and testing
    -
    -y_train=to_categorical(y_train)     #Convert labels to categorical when using categorical cross entropy
    -y_test=to_categorical(y_test)
    -
    -del temp1,temp2,temp
    -
    -# %%
    -
    -# Define tunable parameters"
    -
    -eta=np.logspace(-3,-1,3)                    #Define vector of learning rates (parameter to SGD optimiser)
    -lamda=0.01                                  #Define hyperparameter
    -n_layers=2                                  #Define number of hidden layers in the model
    -n_neuron=np.logspace(0,3,4,dtype=int)       #Define number of neurons per layer
    -epochs=100                                   #Number of reiterations over the input data
    -batch_size=100                              #Number of samples per gradient update
    -
    -# %%
    -
    -"""Define function to return Deep Neural Network model"""
    -
    -def NN_model(inputsize,n_layers,n_neuron,eta,lamda):
    -    model=Sequential()      
    -    for i in range(n_layers):       #Run loop to add hidden layers to the model
    -        if (i==0):                  #First layer requires input dimensions
    -            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize))
    -        else:                       #Subsequent layers are capable of automatic shape inferencing
    -            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda)))
    -    model.add(Dense(2,activation='softmax'))  #2 outputs - ordered and disordered (softmax for prob)
    -    sgd=optimizers.SGD(learning_rate=eta)
    -    model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy'])
    -    return model
    -
    -    
    -Train_accuracy=np.zeros((len(n_neuron),len(eta)))      #Define matrices to store accuracy scores as a function
    -Test_accuracy=np.zeros((len(n_neuron),len(eta)))       #of learning rate and number of hidden neurons for 
    -
    -for i in range(len(n_neuron)):     #run loops over hidden neurons and learning rates to calculate 
    -    for j in range(len(eta)):      #accuracy scores 
    -        DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda)
    -        DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1)
    -        Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1]
    -        Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1]
    -               
    -
    -def plot_data(x,y,data,title=None):
    -
    -    # plot results
    -    fontsize=16
    -
    -
    -    fig = plt.figure()
    -    ax = fig.add_subplot(111)
    -    cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1)
    -    
    -    cbar=fig.colorbar(cax)
    -    cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize)
    -    cbar.set_ticks([0,.2,.4,0.6,0.8,1.0])
    -    cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%'])
    -
    -    # put text on matrix elements
    -    for i, x_val in enumerate(np.arange(len(x))):
    -        for j, y_val in enumerate(np.arange(len(y))):
    -            c = "${0:.1f}\\%$".format( 100*data[j,i])  
    -            ax.text(x_val, y_val, c, va='center', ha='center')
    -
    -    # convert axis vaues to to string labels
    -    x=[str(i) for i in x]
    -    y=[str(i) for i in y]
    -
    -
    -    ax.set_xticklabels(['']+x)
    -    ax.set_yticklabels(['']+y)
    -
    -    ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize)
    -    ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize)
    -    if title is not None:
    -        ax.set_title(title)
    -
    -    plt.tight_layout()
    -
    -    plt.show()
    -    
    -plot_data(eta,n_neuron,Train_accuracy, 'training')
    -plot_data(eta,n_neuron,Test_accuracy, 'testing')
    +accuracy = 100 * correct / total
    +print(f"Test Accuracy: {accuracy:.2f}%")
     
    @@ -2442,7 +1024,81 @@ plot_data(eta,n_neuron,Test_accuracy, 'testing&









    -

    Building a neural network code

    +

    And a similar example using Tensorflow with Keras

    + + + +
    +
    +
    +
    +
    +
    import tensorflow as tf
    +from tensorflow import keras
    +from tensorflow.keras import layers, regularizers
    +
    +# Check for GPU (TensorFlow will use it automatically if available)
    +gpus = tf.config.list_physical_devices('GPU')
    +print(f"GPUs available: {gpus}")
    +
    +# 1) Load and preprocess MNIST
    +(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
    +# Normalize to [0, 1]
    +x_train = (x_train.astype("float32") / 255.0)
    +x_test  = (x_test.astype("float32") / 255.0)
    +
    +# 2) Build the model: 784 -> 100 -> 100 -> 10
    +l2_reg = 1e-4  # L2 regularization strength
    +
    +model = keras.Sequential([
    +    layers.Input(shape=(28, 28)),
    +    layers.Flatten(),
    +    layers.Dense(100, activation="relu",
    +                 kernel_regularizer=regularizers.l2(l2_reg)),
    +    layers.Dense(100, activation="relu",
    +                 kernel_regularizer=regularizers.l2(l2_reg)),
    +    layers.Dense(10, activation="softmax")  # output probabilities for 10 classes
    +])
    +
    +# 3) Compile with SGD + weight decay via L2 regularizers
    +model.compile(
    +    optimizer=keras.optimizers.SGD(learning_rate=0.01),
    +    loss="sparse_categorical_crossentropy",
    +    metrics=["accuracy"],
    +)
    +
    +model.summary()
    +
    +# 4) Train
    +history = model.fit(
    +    x_train, y_train,
    +    epochs=10,
    +    batch_size=64,
    +    validation_split=0.1,  # optional: monitor validation during training
    +    verbose=1
    +)
    +
    +# 5) Evaluate on test set
    +test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
    +print(f"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}")
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +









    +

    Building our own neural network code

    Here we present a flexible object oriented codebase for a feed forward neural network, along with a demonstration of how @@ -6462,7 +5118,7 @@ $$

    - © 1999-2024, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2025, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/week43/html/week43.html b/doc/pub/week43/html/week43.html index 9210219f9..a5349e8d7 100644 --- a/doc/pub/week43/html/week43.html +++ b/doc/pub/week43/html/week43.html @@ -145,15 +145,6 @@ div.toc p,a { 2, None, 'exercises-and-lab-session-week-43'), - ('Mathematics of deep learning', - 2, - None, - 'mathematics-of-deep-learning'), - ('Reminder on books with hands-on material and codes', - 2, - None, - 'reminder-on-books-with-hands-on-material-and-codes'), - ('Reading recommendations', 2, None, 'reading-recommendations'), ('Using Automatic differentiation', 2, None, @@ -162,10 +153,10 @@ div.toc p,a { 2, None, 'back-propagation-and-automatic-differentiation'), - ('Lecture Monday October 21', + ('Lecture Monday October 20', 2, None, - 'lecture-monday-october-21'), + 'lecture-monday-october-20'), ('Setting up the back propagation algorithm and algorithm for a ' 'feed forward NN, initalizations', 2, @@ -199,63 +190,6 @@ div.toc p,a { 2, None, 'more-on-activation-functions-output-layers'), - ('Setting up a Multi-layer perceptron model for classification', - 2, - None, - 'setting-up-a-multi-layer-perceptron-model-for-classification'), - ('Defining the cost function', - 2, - None, - 'defining-the-cost-function'), - ('Example: binary classification problem', - 2, - None, - 'example-binary-classification-problem'), - ('The Softmax function', 2, None, 'the-softmax-function'), - ('Developing a code for doing neural networks with back ' - 'propagation', - 2, - None, - 'developing-a-code-for-doing-neural-networks-with-back-propagation'), - ('Collect and pre-process data', - 2, - None, - 'collect-and-pre-process-data'), - ('Train and test datasets', 2, None, 'train-and-test-datasets'), - ('Define model and architecture', - 2, - None, - 'define-model-and-architecture'), - ('Layers', 2, None, 'layers'), - ('Weights and biases', 2, None, 'weights-and-biases'), - ('Feed-forward pass', 2, None, 'feed-forward-pass'), - ('Matrix multiplications', 2, None, 'matrix-multiplications'), - ('Choose cost function and optimizer', - 2, - None, - 'choose-cost-function-and-optimizer'), - ('Optimizing the cost function', - 2, - None, - 'optimizing-the-cost-function'), - ('Regularization', 2, None, 'regularization'), - ('Matrix multiplication', 2, None, 'matrix-multiplication'), - ('Improving performance', 2, None, 'improving-performance'), - ('Full object-oriented implementation', - 2, - None, - 'full-object-oriented-implementation'), - ('Evaluate model performance on test data', - 2, - None, - 'evaluate-model-performance-on-test-data'), - ('Adjust hyperparameters', 2, None, 'adjust-hyperparameters'), - ('Visualization', 2, None, 'visualization'), - ('scikit-learn implementation', - 2, - None, - 'scikit-learn-implementation'), - ('Visualization', 2, None, 'visualization'), ('Building neural networks in Tensorflow and Keras', 2, None, @@ -266,14 +200,18 @@ div.toc p,a { 2, None, 'collect-and-pre-process-data'), - ('The Breast Cancer Data, now with Keras', + ('Using Pytorch with the full MNIST data set', 2, None, - 'the-breast-cancer-data-now-with-keras'), - ('Building a neural network code', + 'using-pytorch-with-the-full-mnist-data-set'), + ('And a similar example using Tensorflow with Keras', 2, None, - 'building-a-neural-network-code'), + 'and-a-similar-example-using-tensorflow-with-keras'), + ('Building our own neural network code', + 2, + None, + 'building-our-own-neural-network-code'), ('Learning rate methods', 3, None, 'learning-rate-methods'), ('Usage of the above learning rate schedulers', 3, @@ -438,18 +376,15 @@ MathJax.Hub.Config({
    -Morten Hjorth-Jensen [1, 2] +Morten Hjorth-Jensen
    - +
    -[1] Department of Physics, University of Oslo -
    -
    -[2] Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University +Department of Physics, University of Oslo, Norway

    -

    October 21, 2024

    +

    October 20, 2025


    @@ -457,14 +392,14 @@ MathJax.Hub.Config({

    Plans for week 43

    -Material for the lecture on Monday October 21, 2024 +Material for the lecture on Monday October 20, 2025

    @@ -482,42 +417,11 @@ MathJax.Hub.Config({
    -









    -

    Mathematics of deep learning

    - -
    -Two recent books online -

    -

      -
    1. The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at https://arxiv.org/abs/2105.04026, published as Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022
    2. -
    3. Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at https://doi.org/10.48550/arXiv.2310.20360
    4. -
    -
    - - -









    -

    Reminder on books with hands-on material and codes

    -
    - -

    -

    -
    - - -









    -

    Reading recommendations

    - -
      -
    1. Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at https://github.com/rasbt/machine-learning-book. See also chapters 12 and 13 on using Pytorch to make a Neural network code.
    2. -
    3. Goodfellow et al, chapter 6 and 7 contain most of the neural network background.
    4. -










    Using Automatic differentiation

    In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from week 39 and the Autograd documentation at https://github.com/HIPS/autograd. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.











    @@ -530,11 +434,11 @@ we will also study the usage of Autograd, see for example http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture4.pdf









    -

    Lecture Monday October 21

    +

    Lecture Monday October 20











    Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations

    -

    This is a reminder from where we ended last week.

    +

    This is a reminder from last week.

    The architecture (our model) @@ -714,1239 +618,6 @@ gradient descent optimization does in general not get stuck.
  • For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).
  • For regression tasks, you can simply use no activation function at all.
  • - -

    Setting up a Multi-layer perceptron model for classification

    - -

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

    - -

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

    - -

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

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

    and

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

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

    - - -









    -

    Defining the cost function

    - -

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

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

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

    - -

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

    - -

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

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

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

    - -

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

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

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

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

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

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

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

    - -

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

    - -









    -

    Example: binary classification problem

    - -

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

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

    where we had defined the logistic (sigmoid) function

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

    and

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

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

    - -

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

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

    with

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

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

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

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

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

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

    - -









    -

    The Softmax function

    -

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

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

    For the Softmax function we have

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

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

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

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

    - - -

    Developing a code for doing neural networks with back propagation

    - -

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

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









    -

    Collect and pre-process data

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    and the targets would be:

    - -

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

    - -

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

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









    -

    Train and test datasets

    - -

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

    - -

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

    - -

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

    - - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -
    -# one-liner from scikit-learn library
    -train_size = 0.8
    -test_size = 1 - train_size
    -X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,
    -                                                    test_size=test_size)
    -
    -# equivalently in numpy
    -def train_test_split_numpy(inputs, labels, train_size, test_size):
    -    n_inputs = len(inputs)
    -    inputs_shuffled = inputs.copy()
    -    labels_shuffled = labels.copy()
    -    
    -    np.random.shuffle(inputs_shuffled)
    -    np.random.shuffle(labels_shuffled)
    -    
    -    train_end = int(n_inputs*train_size)
    -    X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]
    -    Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]
    -    
    -    return X_train, X_test, Y_train, Y_test
    -
    -#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)
    -
    -print("Number of training images: " + str(len(X_train)))
    -print("Number of test images: " + str(len(X_test)))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Define model and architecture

    - -

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

    - -

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

    - -

    $$ y = f(z) ,$$

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Layers

    - -
      -
    • Input
    • -
    -

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

    - -
      -
    • Hidden layer
    • -
    -

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

    - -
      -
    • Output
    • -
    -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Weights and biases

    - -

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

    - -

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

    - -

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

    - -

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

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









    -

    Feed-forward pass

    - -

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

    - -

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

    - -

    this is then passed through our activation function

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -

    Matrix multiplications

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    This is fed to the output layer:

    - -

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

    - -

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

    - -

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

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









    -

    Choose cost function and optimizer

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - - -









    -

    Optimizing the cost function

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -

    This has two important benefits:

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

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

    - - -

    Regularization

    - -

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

    - -

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

    - -

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

    - -

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

    - -

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

    - -









    -

    Matrix multiplication

    - -

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

    - -

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

    - -

    The gradient for the output weights is calculated as

    - -

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

    - -

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

    - -

    The gradient with respect to the output bias is then

    - -

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

    - -

    The error in the hidden layer is

    - -

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

    - -

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

    - -

    This again gives us the gradients in the hidden layer:

    - -

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

    - -

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

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









    -

    Improving performance

    - -

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

    - -

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

    - -

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

    - -

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

    - -









    -

    Full object-oriented implementation

    - -

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

    - - - -
    -
    -
    -
    -
    -
    class NeuralNetwork:
    -    def __init__(
    -            self,
    -            X_data,
    -            Y_data,
    -            n_hidden_neurons=50,
    -            n_categories=10,
    -            epochs=10,
    -            batch_size=100,
    -            eta=0.1,
    -            lmbd=0.0):
    -
    -        self.X_data_full = X_data
    -        self.Y_data_full = Y_data
    -
    -        self.n_inputs = X_data.shape[0]
    -        self.n_features = X_data.shape[1]
    -        self.n_hidden_neurons = n_hidden_neurons
    -        self.n_categories = n_categories
    -
    -        self.epochs = epochs
    -        self.batch_size = batch_size
    -        self.iterations = self.n_inputs // self.batch_size
    -        self.eta = eta
    -        self.lmbd = lmbd
    -
    -        self.create_biases_and_weights()
    -
    -    def create_biases_and_weights(self):
    -        self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)
    -        self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01
    -
    -        self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)
    -        self.output_bias = np.zeros(self.n_categories) + 0.01
    -
    -    def feed_forward(self):
    -        # feed-forward for training
    -        self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias
    -        self.a_h = sigmoid(self.z_h)
    -
    -        self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias
    -
    -        exp_term = np.exp(self.z_o)
    -        self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    -
    -    def feed_forward_out(self, X):
    -        # feed-forward for output
    -        z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias
    -        a_h = sigmoid(z_h)
    -
    -        z_o = np.matmul(a_h, self.output_weights) + self.output_bias
    -        
    -        exp_term = np.exp(z_o)
    -        probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
    -        return probabilities
    -
    -    def backpropagation(self):
    -        error_output = self.probabilities - self.Y_data
    -        error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)
    -
    -        self.output_weights_gradient = np.matmul(self.a_h.T, error_output)
    -        self.output_bias_gradient = np.sum(error_output, axis=0)
    -
    -        self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)
    -        self.hidden_bias_gradient = np.sum(error_hidden, axis=0)
    -
    -        if self.lmbd > 0.0:
    -            self.output_weights_gradient += self.lmbd * self.output_weights
    -            self.hidden_weights_gradient += self.lmbd * self.hidden_weights
    -
    -        self.output_weights -= self.eta * self.output_weights_gradient
    -        self.output_bias -= self.eta * self.output_bias_gradient
    -        self.hidden_weights -= self.eta * self.hidden_weights_gradient
    -        self.hidden_bias -= self.eta * self.hidden_bias_gradient
    -
    -    def predict(self, X):
    -        probabilities = self.feed_forward_out(X)
    -        return np.argmax(probabilities, axis=1)
    -
    -    def predict_probabilities(self, X):
    -        probabilities = self.feed_forward_out(X)
    -        return probabilities
    -
    -    def train(self):
    -        data_indices = np.arange(self.n_inputs)
    -
    -        for i in range(self.epochs):
    -            for j in range(self.iterations):
    -                # pick datapoints with replacement
    -                chosen_datapoints = np.random.choice(
    -                    data_indices, size=self.batch_size, replace=False
    -                )
    -
    -                # minibatch training data
    -                self.X_data = self.X_data_full[chosen_datapoints]
    -                self.Y_data = self.Y_data_full[chosen_datapoints]
    -
    -                self.feed_forward()
    -                self.backpropagation()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Evaluate model performance on test data

    - -

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

    - -

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

    - -

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

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









    -

    Adjust hyperparameters

    - -

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

    - - - -
    -
    -
    -
    -
    -
    eta_vals = np.logspace(-5, 1, 7)
    -lmbd_vals = np.logspace(-5, 1, 7)
    -# store the models for later use
    -DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
    -
    -# grid search
    -for i, eta in enumerate(eta_vals):
    -    for j, lmbd in enumerate(lmbd_vals):
    -        dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,
    -                            n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)
    -        dnn.train()
    -        
    -        DNN_numpy[i][j] = dnn
    -        
    -        test_predict = dnn.predict(X_test)
    -        
    -        print("Learning rate  = ", eta)
    -        print("Lambda = ", lmbd)
    -        print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))
    -        print()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Visualization

    - - - -
    -
    -
    -
    -
    -
    # visual representation of grid search
    -# uses seaborn heatmap, you can also do this with matplotlib imshow
    -import seaborn as sns
    -
    -sns.set()
    -
    -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -
    -for i in range(len(eta_vals)):
    -    for j in range(len(lmbd_vals)):
    -        dnn = DNN_numpy[i][j]
    -        
    -        train_pred = dnn.predict(X_train) 
    -        test_pred = dnn.predict(X_test)
    -
    -        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
    -        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
    -
    -        
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Training Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Test Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    scikit-learn implementation

    - -

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

    - -

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

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









    -

    Visualization

    - - -
    -
    -
    -
    -
    -
    # optional
    -# visual representation of grid search
    -# uses seaborn heatmap, could probably do this in matplotlib
    -import seaborn as sns
    -
    -sns.set()
    -
    -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
    -
    -for i in range(len(eta_vals)):
    -    for j in range(len(lmbd_vals)):
    -        dnn = DNN_scikit[i][j]
    -        
    -        train_pred = dnn.predict(X_train) 
    -        test_pred = dnn.predict(X_test)
    -
    -        train_accuracy[i][j] = accuracy_score(Y_train, train_pred)
    -        test_accuracy[i][j] = accuracy_score(Y_test, test_pred)
    -
    -        
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Training Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -fig, ax = plt.subplots(figsize = (10, 10))
    -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis")
    -ax.set_title("Test Accuracy")
    -ax.set_ylabel("$\eta$")
    -ax.set_xlabel("$\lambda$")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -









    Building neural networks in Tensorflow and Keras

    @@ -2328,7 +999,7 @@ plt.show()









    -

    The Breast Cancer Data, now with Keras

    +

    Using Pytorch with the full MNIST data set

    @@ -2337,171 +1008,82 @@ plt.show()
    -
    import tensorflow as tf
    -from tensorflow.keras.layers import Input
    -from tensorflow.keras.models import Sequential      #This allows appending layers to existing models
    -from tensorflow.keras.layers import Dense           #This allows defining the characteristics of a particular layer
    -from tensorflow.keras import optimizers             #This allows using whichever optimiser we want (sgd,adam,RMSprop)
    -from tensorflow.keras import regularizers           #This allows using whichever regularizer we want (l1,l2,l1_l2)
    -from tensorflow.keras.utils import to_categorical   #This allows using categorical cross entropy as the cost function
    -import numpy as np
    -import matplotlib.pyplot as plt
    -import seaborn as sns
    -from sklearn.model_selection import train_test_split as splitter
    -from sklearn.datasets import load_breast_cancer
    -import pickle
    -import os 
    +  
    import torch
    +import torch.nn as nn
    +import torch.optim as optim
    +import torchvision
    +import torchvision.transforms as transforms
    +
    +# Device configuration: use GPU if available
    +device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    +
    +# MNIST dataset (downloads if not already present)
    +transform = transforms.Compose([
    +    transforms.ToTensor(),
    +    transforms.Normalize((0.5,), (0.5,))  # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)
    +])
    +train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)
    +test_dataset  = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)
    +
    +train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)
    +test_loader  = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)
     
     
    -"""Load breast cancer dataset"""
    +class NeuralNet(nn.Module):
    +    def __init__(self):
    +        super(NeuralNet, self).__init__()
    +        self.fc1 = nn.Linear(28*28, 100)   # first hidden layer (784 -> 100)
    +        self.fc2 = nn.Linear(100, 100)    # second hidden layer (100 -> 100)
    +        self.fc3 = nn.Linear(100, 10)     # output layer (100 -> 10 classes)
    +    def forward(self, x):
    +        x = x.view(x.size(0), -1)         # flatten images into vectors of size 784
    +        x = torch.relu(self.fc1(x))       # hidden layer 1 + ReLU activation
    +        x = torch.relu(self.fc2(x))       # hidden layer 2 + ReLU activation
    +        x = self.fc3(x)                   # output layer (logits for 10 classes)
    +        return x
     
    -np.random.seed(0)        #create same seed for random number every time
    -
    -cancer=load_breast_cancer()      #Download breast cancer dataset
    -
    -inputs=cancer.data                     #Feature matrix of 569 rows (samples) and 30 columns (parameters)
    -outputs=cancer.target                  #Label array of 569 rows (0 for benign and 1 for malignant)
    -labels=cancer.feature_names[0:30]
    -
    -print('The content of the breast cancer dataset is:')      #Print information about the datasets
    -print(labels)
    -print('-------------------------')
    -print("inputs =  " + str(inputs.shape))
    -print("outputs =  " + str(outputs.shape))
    -print("labels =  "+ str(labels.shape))
    -
    -x=inputs      #Reassign the Feature and Label matrices to other variables
    -y=outputs
    -
    -#%% 
    -
    -# Visualisation of dataset (for correlation analysis)
    -
    -plt.figure()
    -plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean radius',fontweight='bold')
    -plt.ylabel('Mean perimeter',fontweight='bold')
    -plt.show()
    -
    -plt.figure()
    -plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral)
    -plt.xlabel('Mean compactness',fontweight='bold')
    -plt.ylabel('Mean concavity',fontweight='bold')
    -plt.show()
    +model = NeuralNet().to(device)
     
     
    -plt.figure()
    -plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean radius',fontweight='bold')
    -plt.ylabel('Mean texture',fontweight='bold')
    -plt.show()
    +criterion = nn.CrossEntropyLoss()
    +optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)
     
    -plt.figure()
    -plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)
    -plt.xlabel('Mean perimeter',fontweight='bold')
    -plt.ylabel('Mean compactness',fontweight='bold')
    -plt.show()
    +num_epochs = 10
    +for epoch in range(num_epochs):
    +    model.train()  # set model to training mode
    +    running_loss = 0.0
    +    for images, labels in train_loader:
    +        # Move data to device (GPU if available, else CPU)
    +        images, labels = images.to(device), labels.to(device)
    +
    +        optimizer.zero_grad()            # reset gradients to zero
    +        outputs = model(images)          # forward pass: compute predictions
    +        loss = criterion(outputs, labels)  # compute cross-entropy loss
    +        loss.backward()                 # backpropagate to compute gradients
    +        optimizer.step()                # update weights using SGD step 
    +
    +        running_loss += loss.item()
    +    # Compute average loss over all batches in this epoch
    +    avg_loss = running_loss / len(train_loader)
    +    print(f"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}")
    +
    +#Evaluation on the Test Set
     
     
    -# Generate training and testing datasets
     
    -#Select features relevant to classification (texture,perimeter,compactness and symmetery) 
    -#and add to input matrix
    +model.eval()  # set model to evaluation mode 
    +correct = 0
    +total = 0
    +with torch.no_grad():  # disable gradient calculation for evaluation 
    +    for images, labels in test_loader:
    +        images, labels = images.to(device), labels.to(device)
    +        outputs = model(images)
    +        _, predicted = torch.max(outputs, dim=1)  # class with highest score
    +        total += labels.size(0)
    +        correct += (predicted == labels).sum().item()
     
    -temp1=np.reshape(x[:,1],(len(x[:,1]),1))
    -temp2=np.reshape(x[:,2],(len(x[:,2]),1))
    -X=np.hstack((temp1,temp2))      
    -temp=np.reshape(x[:,5],(len(x[:,5]),1))
    -X=np.hstack((X,temp))       
    -temp=np.reshape(x[:,8],(len(x[:,8]),1))
    -X=np.hstack((X,temp))       
    -
    -X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1)   #Split datasets into training and testing
    -
    -y_train=to_categorical(y_train)     #Convert labels to categorical when using categorical cross entropy
    -y_test=to_categorical(y_test)
    -
    -del temp1,temp2,temp
    -
    -# %%
    -
    -# Define tunable parameters"
    -
    -eta=np.logspace(-3,-1,3)                    #Define vector of learning rates (parameter to SGD optimiser)
    -lamda=0.01                                  #Define hyperparameter
    -n_layers=2                                  #Define number of hidden layers in the model
    -n_neuron=np.logspace(0,3,4,dtype=int)       #Define number of neurons per layer
    -epochs=100                                   #Number of reiterations over the input data
    -batch_size=100                              #Number of samples per gradient update
    -
    -# %%
    -
    -"""Define function to return Deep Neural Network model"""
    -
    -def NN_model(inputsize,n_layers,n_neuron,eta,lamda):
    -    model=Sequential()      
    -    for i in range(n_layers):       #Run loop to add hidden layers to the model
    -        if (i==0):                  #First layer requires input dimensions
    -            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize))
    -        else:                       #Subsequent layers are capable of automatic shape inferencing
    -            model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda)))
    -    model.add(Dense(2,activation='softmax'))  #2 outputs - ordered and disordered (softmax for prob)
    -    sgd=optimizers.SGD(learning_rate=eta)
    -    model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy'])
    -    return model
    -
    -    
    -Train_accuracy=np.zeros((len(n_neuron),len(eta)))      #Define matrices to store accuracy scores as a function
    -Test_accuracy=np.zeros((len(n_neuron),len(eta)))       #of learning rate and number of hidden neurons for 
    -
    -for i in range(len(n_neuron)):     #run loops over hidden neurons and learning rates to calculate 
    -    for j in range(len(eta)):      #accuracy scores 
    -        DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda)
    -        DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1)
    -        Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1]
    -        Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1]
    -               
    -
    -def plot_data(x,y,data,title=None):
    -
    -    # plot results
    -    fontsize=16
    -
    -
    -    fig = plt.figure()
    -    ax = fig.add_subplot(111)
    -    cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1)
    -    
    -    cbar=fig.colorbar(cax)
    -    cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize)
    -    cbar.set_ticks([0,.2,.4,0.6,0.8,1.0])
    -    cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%'])
    -
    -    # put text on matrix elements
    -    for i, x_val in enumerate(np.arange(len(x))):
    -        for j, y_val in enumerate(np.arange(len(y))):
    -            c = "${0:.1f}\\%$".format( 100*data[j,i])  
    -            ax.text(x_val, y_val, c, va='center', ha='center')
    -
    -    # convert axis vaues to to string labels
    -    x=[str(i) for i in x]
    -    y=[str(i) for i in y]
    -
    -
    -    ax.set_xticklabels(['']+x)
    -    ax.set_yticklabels(['']+y)
    -
    -    ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize)
    -    ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize)
    -    if title is not None:
    -        ax.set_title(title)
    -
    -    plt.tight_layout()
    -
    -    plt.show()
    -    
    -plot_data(eta,n_neuron,Train_accuracy, 'training')
    -plot_data(eta,n_neuron,Test_accuracy, 'testing')
    +accuracy = 100 * correct / total
    +print(f"Test Accuracy: {accuracy:.2f}%")
     
    @@ -2519,7 +1101,81 @@ plot_data(eta,n_neuron,Test_accuracy, 'testing&









    -

    Building a neural network code

    +

    And a similar example using Tensorflow with Keras

    + + + +
    +
    +
    +
    +
    +
    import tensorflow as tf
    +from tensorflow import keras
    +from tensorflow.keras import layers, regularizers
    +
    +# Check for GPU (TensorFlow will use it automatically if available)
    +gpus = tf.config.list_physical_devices('GPU')
    +print(f"GPUs available: {gpus}")
    +
    +# 1) Load and preprocess MNIST
    +(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
    +# Normalize to [0, 1]
    +x_train = (x_train.astype("float32") / 255.0)
    +x_test  = (x_test.astype("float32") / 255.0)
    +
    +# 2) Build the model: 784 -> 100 -> 100 -> 10
    +l2_reg = 1e-4  # L2 regularization strength
    +
    +model = keras.Sequential([
    +    layers.Input(shape=(28, 28)),
    +    layers.Flatten(),
    +    layers.Dense(100, activation="relu",
    +                 kernel_regularizer=regularizers.l2(l2_reg)),
    +    layers.Dense(100, activation="relu",
    +                 kernel_regularizer=regularizers.l2(l2_reg)),
    +    layers.Dense(10, activation="softmax")  # output probabilities for 10 classes
    +])
    +
    +# 3) Compile with SGD + weight decay via L2 regularizers
    +model.compile(
    +    optimizer=keras.optimizers.SGD(learning_rate=0.01),
    +    loss="sparse_categorical_crossentropy",
    +    metrics=["accuracy"],
    +)
    +
    +model.summary()
    +
    +# 4) Train
    +history = model.fit(
    +    x_train, y_train,
    +    epochs=10,
    +    batch_size=64,
    +    validation_split=0.1,  # optional: monitor validation during training
    +    verbose=1
    +)
    +
    +# 5) Evaluate on test set
    +test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
    +print(f"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}")
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +









    +

    Building our own neural network code

    Here we present a flexible object oriented codebase for a feed forward neural network, along with a demonstration of how @@ -6539,7 +5195,7 @@ $$

    - © 1999-2024, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2025, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz b/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz index 27f05a66279fd7c06d284fa65fb22f776eb76209..686438690424bb06d48ac0af9e4470ee1f5a06c8 100644 GIT binary patch literal 191 zcmV;w06_mAiwFQ*$@ORe1MSaC3c@fD2H>uHia9|^P13FfyKo_hc!88oZLCddlA^u6 zeSoeMH${YeF#LoJ!^|ODZ+2Pa?k-piAtYf8#!M4FC0WhyNgQ*CIY~KXY$zZx<&+0N zmRsqivrd>{m8LqQvZ&tm4Q*xlVa|LCJo8T+D`{c7?_H%8DD5!Ux`rEK&1fXsUgc0| twBr{Tymrzc2-Slq3hAU);u5w-pNwd16#n`c&+|O*YY$@IoWcMI003IdRp9^t literal 192 zcmV;x06+g9iwFR$co$~?1MSbv3c@f92k@Qu6nTQtx^_DY?%+WX@dY}TxjNU*wnO*! z?gR9sco`z}cli?%LUPE~n_U*Uy9*XW2uT=&G1G)kNmg?`p_Bt_Wl|}V#ZWt@e4}0cU;F*8oSV;@peeWu*Kxv1$)-~J^YZgbc?Ntti uMmx5^;I)$mL8u-?QAj7X5|^+w`ea07qwv?yc%J8ZUwZ(h+L-462mk<|b5~yg diff --git a/doc/pub/week43/ipynb/week43.ipynb b/doc/pub/week43/ipynb/week43.ipynb index 0635c602d..bcf841703 100644 --- a/doc/pub/week43/ipynb/week43.ipynb +++ b/doc/pub/week43/ipynb/week43.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "6107bf3a", + "id": "b4262ce2", "metadata": { "editable": true }, @@ -14,42 +14,39 @@ }, { "cell_type": "markdown", - "id": "fdc249e0", + "id": "9203032a", "metadata": { "editable": true }, "source": [ "# Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations\n", - "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University\n", + "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo, Norway\n", "\n", - "Date: **October 21, 2024**" + "Date: **October 20, 2025**" ] }, { "cell_type": "markdown", - "id": "92454b8c", + "id": "56b9fe61", "metadata": { "editable": true }, "source": [ "## Plans for week 43\n", "\n", - "**Material for the lecture on Monday October 21, 2024.**\n", + "**Material for the lecture on Monday October 20, 2025.**\n", "\n", " * Building our own Feed-forward Neural Network with intro to Tensorflow\n", "\n", " * Solving differential equations with Neural Networks\n", - "\n", - " * Video of lecture at \n", - "\n", - " * Video os second part, solving differential equations with neural networks at \n", - "\n", - " * Whiteboard notes on solving differential equations at " + "\n", + "\n", + "" ] }, { "cell_type": "markdown", - "id": "7ad9295b", + "id": "0b8b78a7", "metadata": { "editable": true }, @@ -66,48 +63,7 @@ }, { "cell_type": "markdown", - "id": "cbe78b79", - "metadata": { - "editable": true - }, - "source": [ - "## Mathematics of deep learning\n", - "\n", - "**Two recent books online.**\n", - "\n", - "1. The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at , published as [Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022](https://doi.org/10.1017/9781009025096.002)\n", - "\n", - "2. Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at " - ] - }, - { - "cell_type": "markdown", - "id": "52f3d73d", - "metadata": { - "editable": true - }, - "source": [ - "## Reminder on books with hands-on material and codes\n", - "* Sebastian Rashcka et al, Machine learning with Scikit-Learn and PyTorch at " - ] - }, - { - "cell_type": "markdown", - "id": "afcf91a9", - "metadata": { - "editable": true - }, - "source": [ - "## Reading recommendations\n", - "\n", - "1. Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at . See also chapters 12 and 13 on using Pytorch to make a Neural network code. \n", - "\n", - "2. Goodfellow et al, chapter 6 and 7 contain most of the neural network background." - ] - }, - { - "cell_type": "markdown", - "id": "73c52766", + "id": "211ed9dd", "metadata": { "editable": true }, @@ -115,12 +71,12 @@ "## Using Automatic differentiation\n", "\n", "In our discussions of ordinary differential equations and neural network codes\n", - "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from [week 39](https://compphysics.github.io/MachineLearning/doc/pub/week39/html/week39.html) and the Autograd documentation at ." + "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at and the lecture slides from week 40, see ." ] }, { "cell_type": "markdown", - "id": "0c8d3f87", + "id": "22d4d145", "metadata": { "editable": true }, @@ -137,23 +93,23 @@ }, { "cell_type": "markdown", - "id": "e37a061f", + "id": "96f43859", "metadata": { "editable": true }, "source": [ - "## Lecture Monday October 21" + "## Lecture Monday October 20" ] }, { "cell_type": "markdown", - "id": "c9dcc967", + "id": "a38b1a5e", "metadata": { "editable": true }, "source": [ "## Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations\n", - "This is a reminder from where we ended last week.\n", + "This is a reminder from last week.\n", "\n", "**The architecture (our model).**\n", "\n", @@ -174,7 +130,7 @@ }, { "cell_type": "markdown", - "id": "5ff0f230", + "id": "8e9e7f7a", "metadata": { "editable": true }, @@ -197,7 +153,7 @@ }, { "cell_type": "markdown", - "id": "9bfa26c0", + "id": "64ec6fe3", "metadata": { "editable": true }, @@ -209,7 +165,7 @@ }, { "cell_type": "markdown", - "id": "eb6f6d75", + "id": "ce7deff8", "metadata": { "editable": true }, @@ -221,7 +177,7 @@ }, { "cell_type": "markdown", - "id": "8474f6a3", + "id": "0794bf9c", "metadata": { "editable": true }, @@ -231,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "0edb9d87", + "id": "966295a4", "metadata": { "editable": true }, @@ -243,7 +199,7 @@ }, { "cell_type": "markdown", - "id": "5e0a7cea", + "id": "1a24ff59", "metadata": { "editable": true }, @@ -257,7 +213,7 @@ }, { "cell_type": "markdown", - "id": "790a822d", + "id": "0e7ea1ba", "metadata": { "editable": true }, @@ -269,7 +225,7 @@ }, { "cell_type": "markdown", - "id": "adec1944", + "id": "bdefff6b", "metadata": { "editable": true }, @@ -281,7 +237,7 @@ }, { "cell_type": "markdown", - "id": "556caafc", + "id": "de1257ed", "metadata": { "editable": true }, @@ -291,7 +247,7 @@ }, { "cell_type": "markdown", - "id": "17f55244", + "id": "3c04f532", "metadata": { "editable": true }, @@ -303,7 +259,7 @@ }, { "cell_type": "markdown", - "id": "d2cb9b96", + "id": "59d21e46", "metadata": { "editable": true }, @@ -315,7 +271,7 @@ }, { "cell_type": "markdown", - "id": "ededcd6c", + "id": "22face27", "metadata": { "editable": true }, @@ -325,7 +281,7 @@ }, { "cell_type": "markdown", - "id": "837b7226", + "id": "1e72f57e", "metadata": { "editable": true }, @@ -337,7 +293,7 @@ }, { "cell_type": "markdown", - "id": "be1f3b39", + "id": "a9ebc5c4", "metadata": { "editable": true }, @@ -349,7 +305,7 @@ }, { "cell_type": "markdown", - "id": "a320c88d", + "id": "2ab07a4a", "metadata": { "editable": true }, @@ -372,7 +328,7 @@ }, { "cell_type": "markdown", - "id": "d832d09f", + "id": "15174e2a", "metadata": { "editable": true }, @@ -384,7 +340,7 @@ }, { "cell_type": "markdown", - "id": "588ddc37", + "id": "3e037a7e", "metadata": { "editable": true }, @@ -396,7 +352,7 @@ }, { "cell_type": "markdown", - "id": "ff490c14", + "id": "854aa7cd", "metadata": { "editable": true }, @@ -406,7 +362,7 @@ }, { "cell_type": "markdown", - "id": "33129f1d", + "id": "3b300627", "metadata": { "editable": true }, @@ -418,7 +374,7 @@ }, { "cell_type": "markdown", - "id": "2cd95b52", + "id": "60c47f86", "metadata": { "editable": true }, @@ -439,7 +395,7 @@ }, { "cell_type": "markdown", - "id": "36bff826", + "id": "de3db402", "metadata": { "editable": true }, @@ -453,7 +409,7 @@ }, { "cell_type": "markdown", - "id": "9ef16459", + "id": "c9b3f789", "metadata": { "editable": true }, @@ -465,7 +421,7 @@ }, { "cell_type": "markdown", - "id": "4cc08f94", + "id": "9e6ba2c1", "metadata": { "editable": true }, @@ -487,7 +443,7 @@ }, { "cell_type": "markdown", - "id": "ea028825", + "id": "a0ca6ce2", "metadata": { "editable": true }, @@ -509,1499 +465,7 @@ }, { "cell_type": "markdown", - "id": "921a49ef", - "metadata": { - "editable": true - }, - "source": [ - "## Setting up a Multi-layer perceptron model for classification\n", - "\n", - "We are now gong to develop an example based on the MNIST data\n", - "base. This is a classification problem and we need to use our\n", - "cross-entropy function we discussed in connection with logistic\n", - "regression. The cross-entropy defines our cost function for the\n", - "classificaton problems with neural networks.\n", - "\n", - "In binary classification with two classes $(0, 1)$ we define the\n", - "logistic/sigmoid function as the probability that a particular input\n", - "is in class $0$ or $1$. This is possible because the logistic\n", - "function takes any input from the real numbers and inputs a number\n", - "between 0 and 1, and can therefore be interpreted as a probability. It\n", - "also has other nice properties, such as a derivative that is simple to\n", - "calculate.\n", - "\n", - "For an input $\\boldsymbol{a}$ from the hidden layer, the probability that the input $\\boldsymbol{x}$\n", - "is in class 0 or 1 is just. We let $\\theta$ represent the unknown weights and biases to be adjusted by our equations). The variable $x$\n", - "represents our activation values $z$. We have" - ] - }, - { - "cell_type": "markdown", - "id": "9a029a10", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "P(y = 0 \\mid \\boldsymbol{x}, \\boldsymbol{\\theta}) = \\frac{1}{1 + \\exp{(- \\boldsymbol{x}})} ,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "40d7c3b7", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "cf8c63fe", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "P(y = 1 \\mid \\boldsymbol{x}, \\boldsymbol{\\theta}) = 1 - P(y = 0 \\mid \\boldsymbol{x}, \\boldsymbol{\\theta}) ,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "1b6c3403", - "metadata": { - "editable": true - }, - "source": [ - "where $y \\in \\{0, 1\\}$ and $\\boldsymbol{\\theta}$ represents the weights and biases\n", - "of our network." - ] - }, - { - "cell_type": "markdown", - "id": "8143e962", - "metadata": { - "editable": true - }, - "source": [ - "## Defining the cost function\n", - "\n", - "Our cost function is given as (see the Logistic regression lectures)" - ] - }, - { - "cell_type": "markdown", - "id": "6619f034", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\mathcal{C}(\\boldsymbol{\\theta}) = - \\ln P(\\mathcal{D} \\mid \\boldsymbol{\\theta}) = - \\sum_{i=1}^n\n", - "y_i \\ln[P(y_i = 0)] + (1 - y_i) \\ln [1 - P(y_i = 0)] = \\sum_{i=1}^n \\mathcal{L}_i(\\boldsymbol{\\theta}) .\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "6b4e1124", - "metadata": { - "editable": true - }, - "source": [ - "This last equality means that we can interpret our *cost* function as a sum over the *loss* function\n", - "for each point in the dataset $\\mathcal{L}_i(\\boldsymbol{\\theta})$. \n", - "The negative sign is just so that we can think about our algorithm as minimizing a positive number, rather\n", - "than maximizing a negative number. \n", - "\n", - "In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: \n", - "\n", - "$y = 5 \\quad \\rightarrow \\quad \\boldsymbol{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$ and\n", - "\n", - "$y = 1 \\quad \\rightarrow \\quad \\boldsymbol{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$ \n", - "\n", - "i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset (numbers from $0$ to $9$).. \n", - "\n", - "If $\\boldsymbol{x}_i$ is the $i$-th input (image), $y_{ic}$ refers to the $c$-th component of the $i$-th\n", - "output vector $\\boldsymbol{y}_i$. \n", - "The probability of $\\boldsymbol{x}_i$ being in class $c$ will be given by the softmax function:" - ] - }, - { - "cell_type": "markdown", - "id": "f0373257", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "P(y_{ic} = 1 \\mid \\boldsymbol{x}_i, \\boldsymbol{\\theta}) = \\frac{\\exp{((\\boldsymbol{a}_i^{hidden})^T \\boldsymbol{w}_c)}}\n", - "{\\sum_{c'=0}^{C-1} \\exp{((\\boldsymbol{a}_i^{hidden})^T \\boldsymbol{w}_{c'})}} ,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "f958a039", - "metadata": { - "editable": true - }, - "source": [ - "which reduces to the logistic function in the binary case. \n", - "The likelihood of this $C$-class classifier\n", - "is now given as:" - ] - }, - { - "cell_type": "markdown", - "id": "e67e2ba4", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "P(\\mathcal{D} \\mid \\boldsymbol{\\theta}) = \\prod_{i=1}^n \\prod_{c=0}^{C-1} [P(y_{ic} = 1)]^{y_{ic}} .\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "de66b0e1", - "metadata": { - "editable": true - }, - "source": [ - "Again we take the negative log-likelihood to define our cost function:" - ] - }, - { - "cell_type": "markdown", - "id": "8f041533", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\mathcal{C}(\\boldsymbol{\\theta}) = - \\log{P(\\mathcal{D} \\mid \\boldsymbol{\\theta})}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "8840e115", - "metadata": { - "editable": true - }, - "source": [ - "See the logistic regression lectures for a full definition of the cost function.\n", - "\n", - "The back propagation equations need now only a small change, namely the definition of a new cost function. We are thus ready to use the same equations as before!" - ] - }, - { - "cell_type": "markdown", - "id": "f21c7506", - "metadata": { - "editable": true - }, - "source": [ - "## Example: binary classification problem\n", - "\n", - "As an example of the above, relevant for project 2 as well, let us consider a binary class. As discussed in our logistic regression lectures, we defined a cost function in terms of the parameters $\\beta$ as" - ] - }, - { - "cell_type": "markdown", - "id": "72c3c921", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\mathcal{C}(\\boldsymbol{\\beta}) = - \\sum_{i=1}^n \\left(y_i\\log{p(y_i \\vert x_i,\\boldsymbol{\\beta})}+(1-y_i)\\log{1-p(y_i \\vert x_i,\\boldsymbol{\\beta})}\\right),\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "e37b9409", - "metadata": { - "editable": true - }, - "source": [ - "where we had defined the logistic (sigmoid) function" - ] - }, - { - "cell_type": "markdown", - "id": "0f635478", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "p(y_i =1\\vert x_i,\\boldsymbol{\\beta})=\\frac{\\exp{(\\beta_0+\\beta_1 x_i)}}{1+\\exp{(\\beta_0+\\beta_1 x_i)}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "96e12d56", - "metadata": { - "editable": true - }, - "source": [ - "and" - ] - }, - { - "cell_type": "markdown", - "id": "25625fe3", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "p(y_i =0\\vert x_i,\\boldsymbol{\\beta})=1-p(y_i =1\\vert x_i,\\boldsymbol{\\beta}).\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "cd61de5c", - "metadata": { - "editable": true - }, - "source": [ - "The parameters $\\boldsymbol{\\beta}$ were defined using a minimization method like gradient descent or Newton-Raphson's method. \n", - "\n", - "Now we replace $x_i$ with the activation $z_i^l$ for a given layer $l$ and the outputs as $y_i=a_i^l=f(z_i^l)$, with $z_i^l$ now being a function of the weights $w_{ij}^l$ and biases $b_i^l$. \n", - "We have then" - ] - }, - { - "cell_type": "markdown", - "id": "9bb7f55b", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "a_i^l = y_i = \\frac{\\exp{(z_i^l)}}{1+\\exp{(z_i^l)}},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "6e427758", - "metadata": { - "editable": true - }, - "source": [ - "with" - ] - }, - { - "cell_type": "markdown", - "id": "e28000bc", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "z_i^l = \\sum_{j}w_{ij}^l a_j^{l-1}+b_i^l,\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "1986d31a", - "metadata": { - "editable": true - }, - "source": [ - "where the superscript $l-1$ indicates that these are the outputs from layer $l-1$.\n", - "Our cost function at the final layer $l=L$ is now" - ] - }, - { - "cell_type": "markdown", - "id": "c1797668", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\mathcal{C}(\\boldsymbol{W}) = - \\sum_{i=1}^n \\left(t_i\\log{a_i^L}+(1-t_i)\\log{(1-a_i^L)}\\right),\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "07583c6a", - "metadata": { - "editable": true - }, - "source": [ - "where we have defined the targets $t_i$. The derivatives of the cost function with respect to the output $a_i^L$ are then easily calculated and we get" - ] - }, - { - "cell_type": "markdown", - "id": "978e292d", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial \\mathcal{C}(\\boldsymbol{W})}{\\partial a_i^L} = \\frac{a_i^L-t_i}{a_i^L(1-a_i^L)}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "d6385ead", - "metadata": { - "editable": true - }, - "source": [ - "In case we use another activation function than the logistic one, we need to evaluate other derivatives." - ] - }, - { - "cell_type": "markdown", - "id": "8335897f", - "metadata": { - "editable": true - }, - "source": [ - "## The Softmax function\n", - "In case we employ the more general case given by the Softmax equation, we need to evaluate the derivative of the activation function with respect to the activation $z_i^l$, that is we need" - ] - }, - { - "cell_type": "markdown", - "id": "50f96054", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f(z_i^l)}{\\partial w_{jk}^l} =\n", - "\\frac{\\partial f(z_i^l)}{\\partial z_j^l} \\frac{\\partial z_j^l}{\\partial w_{jk}^l}= \\frac{\\partial f(z_i^l)}{\\partial z_j^l}a_k^{l-1}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "db6ebd31", - "metadata": { - "editable": true - }, - "source": [ - "For the Softmax function we have" - ] - }, - { - "cell_type": "markdown", - "id": "e5c3f583", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "f(z_i^l) = \\frac{\\exp{(z_i^l)}}{\\sum_{m=1}^K\\exp{(z_m^l)}}.\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "7988ff75", - "metadata": { - "editable": true - }, - "source": [ - "Its derivative with respect to $z_j^l$ gives" - ] - }, - { - "cell_type": "markdown", - "id": "d3073ab9", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\frac{\\partial f(z_i^l)}{\\partial z_j^l}= f(z_i^l)\\left(\\delta_{ij}-f(z_j^l)\\right),\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "a4be6483", - "metadata": { - "editable": true - }, - "source": [ - "which in case of the simply binary model reduces to having $i=j$." - ] - }, - { - "cell_type": "markdown", - "id": "cbbc9199", - "metadata": { - "editable": true - }, - "source": [ - "## Developing a code for doing neural networks with back propagation\n", - "\n", - "One can identify a set of key steps when using neural networks to solve supervised learning problems: \n", - "\n", - "1. Collect and pre-process data \n", - "\n", - "2. Define model and architecture \n", - "\n", - "3. Choose cost function and optimizer \n", - "\n", - "4. Train the model \n", - "\n", - "5. Evaluate model performance on test data \n", - "\n", - "6. Adjust hyperparameters (if necessary, network architecture)" - ] - }, - { - "cell_type": "markdown", - "id": "67083baf", - "metadata": { - "editable": true - }, - "source": [ - "## Collect and pre-process data\n", - "\n", - "Here we will be using the MNIST dataset, which is readily available through the **scikit-learn**\n", - "package. You may also find it for example [here](http://yann.lecun.com/exdb/mnist/). \n", - "The *MNIST* (Modified National Institute of Standards and Technology) database is a large database\n", - "of handwritten digits that is commonly used for training various image processing systems. \n", - "The MNIST dataset consists of 70 000 images of size $28\\times 28$ pixels, each labeled from 0 to 9. \n", - "The scikit-learn dataset we will use consists of a selection of 1797 images of size $8\\times 8$ collected and processed from this database. \n", - "\n", - "To feed data into a feed-forward neural network we need to represent\n", - "the inputs as a design/feature matrix $X = (n_{inputs}, n_{features})$. Each\n", - "row represents an *input*, in this case a handwritten digit, and\n", - "each column represents a *feature*, in this case a pixel. The\n", - "correct answers, also known as *labels* or *targets* are\n", - "represented as a 1D array of integers \n", - "$Y = (n_{inputs}) = (5, 3, 1, 8,...)$.\n", - "\n", - "As an example, say we want to build a neural network using supervised learning to predict Body-Mass Index (BMI) from\n", - "measurements of height (in m) \n", - "and weight (in kg). If we have measurements of 5 people the design/feature matrix could be for example: \n", - "\n", - "$$ X = \\begin{bmatrix}\n", - "1.85 & 81\\\\\n", - "1.71 & 65\\\\\n", - "1.95 & 103\\\\\n", - "1.55 & 42\\\\\n", - "1.63 & 56\n", - "\\end{bmatrix} ,$$ \n", - "\n", - "and the targets would be: \n", - "\n", - "$$ Y = (23.7, 22.2, 27.1, 17.5, 21.1) $$ \n", - "\n", - "Since each input image is a 2D matrix, we need to flatten the image\n", - "(i.e. \"unravel\" the 2D matrix into a 1D array) to turn the data into a\n", - "design/feature matrix. This means we lose all spatial information in the\n", - "image, such as locality and translational invariance. More complicated\n", - "architectures such as Convolutional Neural Networks can take advantage\n", - "of such information, and are most commonly applied when analyzing\n", - "images." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "ce086d04", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "%matplotlib inline\n", - "\n", - "# import necessary packages\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "from sklearn import datasets\n", - "\n", - "\n", - "# ensure the same random numbers appear every time\n", - "np.random.seed(0)\n", - "\n", - "# display images in notebook\n", - "%matplotlib inline\n", - "plt.rcParams['figure.figsize'] = (12,12)\n", - "\n", - "\n", - "# download MNIST dataset\n", - "digits = datasets.load_digits()\n", - "\n", - "# define inputs and labels\n", - "inputs = digits.images\n", - "labels = digits.target\n", - "\n", - "print(\"inputs = (n_inputs, pixel_width, pixel_height) = \" + str(inputs.shape))\n", - "print(\"labels = (n_inputs) = \" + str(labels.shape))\n", - "\n", - "\n", - "# flatten the image\n", - "# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64\n", - "n_inputs = len(inputs)\n", - "inputs = inputs.reshape(n_inputs, -1)\n", - "print(\"X = (n_inputs, n_features) = \" + str(inputs.shape))\n", - "\n", - "\n", - "# choose some random images to display\n", - "indices = np.arange(n_inputs)\n", - "random_indices = np.random.choice(indices, size=5)\n", - "\n", - "for i, image in enumerate(digits.images[random_indices]):\n", - " plt.subplot(1, 5, i+1)\n", - " plt.axis('off')\n", - " plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n", - " plt.title(\"Label: %d\" % digits.target[random_indices[i]])\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "id": "54bfb494", - "metadata": { - "editable": true - }, - "source": [ - "## Train and test datasets\n", - "\n", - "Performing analysis before partitioning the dataset is a major error, that can lead to incorrect conclusions. \n", - "\n", - "We will reserve $80 \\%$ of our dataset for training and $20 \\%$ for testing. \n", - "\n", - "It is important that the train and test datasets are drawn randomly from our dataset, to ensure\n", - "no bias in the sampling. \n", - "Say you are taking measurements of weather data to predict the weather in the coming 5 days.\n", - "You don't want to train your model on measurements taken from the hours 00.00 to 12.00, and then test it on data\n", - "collected from 12.00 to 24.00." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "63b09387", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.model_selection import train_test_split\n", - "\n", - "# one-liner from scikit-learn library\n", - "train_size = 0.8\n", - "test_size = 1 - train_size\n", - "X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,\n", - " test_size=test_size)\n", - "\n", - "# equivalently in numpy\n", - "def train_test_split_numpy(inputs, labels, train_size, test_size):\n", - " n_inputs = len(inputs)\n", - " inputs_shuffled = inputs.copy()\n", - " labels_shuffled = labels.copy()\n", - " \n", - " np.random.shuffle(inputs_shuffled)\n", - " np.random.shuffle(labels_shuffled)\n", - " \n", - " train_end = int(n_inputs*train_size)\n", - " X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:]\n", - " Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:]\n", - " \n", - " return X_train, X_test, Y_train, Y_test\n", - "\n", - "#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size)\n", - "\n", - "print(\"Number of training images: \" + str(len(X_train)))\n", - "print(\"Number of test images: \" + str(len(X_test)))" - ] - }, - { - "cell_type": "markdown", - "id": "8af9f143", - "metadata": { - "editable": true - }, - "source": [ - "## Define model and architecture\n", - "\n", - "Our simple feed-forward neural network will consist of an *input* layer, a single *hidden* layer and an *output* layer. The activation $y$ of each neuron is a weighted sum of inputs, passed through an activation function. In case of the simple perceptron model we have \n", - "\n", - "$$ z = \\sum_{i=1}^n w_i a_i ,$$\n", - "\n", - "$$ y = f(z) ,$$\n", - "\n", - "where $f$ is the activation function, $a_i$ represents input from neuron $i$ in the preceding layer\n", - "and $w_i$ is the weight to input $i$. \n", - "The activation of the neurons in the input layer is just the features (e.g. a pixel value). \n", - "\n", - "The simplest activation function for a neuron is the *Heaviside* function:\n", - "\n", - "$$ f(z) = \n", - "\\begin{cases}\n", - "1, & z > 0\\\\\n", - "0, & \\text{otherwise}\n", - "\\end{cases}\n", - "$$\n", - "\n", - "A feed-forward neural network with this activation is known as a *perceptron*. \n", - "For a binary classifier (i.e. two classes, 0 or 1, dog or not-dog) we can also use this in our output layer. \n", - "This activation can be generalized to $k$ classes (using e.g. the *one-against-all* strategy), \n", - "and we call these architectures *multiclass perceptrons*. \n", - "\n", - "However, it is now common to use the terms Single Layer Perceptron (SLP) (1 hidden layer) and \n", - "Multilayer Perceptron (MLP) (2 or more hidden layers) to refer to feed-forward neural networks with any activation function. \n", - "\n", - "Typical choices for activation functions include the sigmoid function, hyperbolic tangent, and Rectified Linear Unit (ReLU). \n", - "We will be using the sigmoid function $\\sigma(x)$: \n", - "\n", - "$$ f(x) = \\sigma(x) = \\frac{1}{1 + e^{-x}} ,$$\n", - "\n", - "which is inspired by probability theory (see logistic regression) and was most commonly used until about 2011. See the discussion below concerning other activation functions." - ] - }, - { - "cell_type": "markdown", - "id": "0878e62d", - "metadata": { - "editable": true - }, - "source": [ - "## Layers\n", - "\n", - "* Input \n", - "\n", - "Since each input image has 8x8 = 64 pixels or features, we have an input layer of 64 neurons. \n", - "\n", - "* Hidden layer\n", - "\n", - "We will use 50 neurons in the hidden layer receiving input from the neurons in the input layer. \n", - "Since each neuron in the hidden layer is connected to the 64 inputs we have 64x50 = 3200 weights to the hidden layer. \n", - "\n", - "* Output\n", - "\n", - "If we were building a binary classifier, it would be sufficient with a single neuron in the output layer,\n", - "which could output 0 or 1 according to the Heaviside function. This would be an example of a *hard* classifier, meaning it outputs the class of the input directly. However, if we are dealing with noisy data it is often beneficial to use a *soft* classifier, which outputs the probability of being in class 0 or 1. \n", - "\n", - "For a soft binary classifier, we could use a single neuron and interpret the output as either being the probability of being in class 0 or the probability of being in class 1. Alternatively we could use 2 neurons, and interpret each neuron as the probability of being in each class. \n", - "\n", - "Since we are doing multiclass classification, with 10 categories, it is natural to use 10 neurons in the output layer. We number the neurons $j = 0,1,...,9$. The activation of each output neuron $j$ will be according to the *softmax* function: \n", - "\n", - "$$ P(\\text{class $j$} \\mid \\text{input $\\boldsymbol{a}$}) = \\frac{\\exp{(\\boldsymbol{a}^T \\boldsymbol{w}_j)}}\n", - "{\\sum_{c=0}^{9} \\exp{(\\boldsymbol{a}^T \\boldsymbol{w}_c)}} ,$$ \n", - "\n", - "i.e. each neuron $j$ outputs the probability of being in class $j$ given an input from the hidden layer $\\boldsymbol{a}$, with $\\boldsymbol{w}_j$ the weights of neuron $j$ to the inputs. \n", - "The denominator is a normalization factor to ensure the outputs (probabilities) sum up to 1. \n", - "The exponent is just the weighted sum of inputs as before: \n", - "\n", - "$$ z_j = \\sum_{i=1}^n w_ {ij} a_i+b_j.$$ \n", - "\n", - "Since each neuron in the output layer is connected to the 50 inputs from the hidden layer we have 50x10 = 500\n", - "weights to the output layer." - ] - }, - { - "cell_type": "markdown", - "id": "32e84e6b", - "metadata": { - "editable": true - }, - "source": [ - "## Weights and biases\n", - "\n", - "Typically weights are initialized with small values distributed around zero, drawn from a uniform\n", - "or normal distribution. Setting all weights to zero means all neurons give the same output, making the network useless. \n", - "\n", - "Adding a bias value to the weighted sum of inputs allows the neural network to represent a greater range\n", - "of values. Without it, any input with the value 0 will be mapped to zero (before being passed through the activation). The bias unit has an output of 1, and a weight to each neuron $j$, $b_j$: \n", - "\n", - "$$ z_j = \\sum_{i=1}^n w_ {ij} a_i + b_j.$$ \n", - "\n", - "The bias weights $\\boldsymbol{b}$ are often initialized to zero, but a small value like $0.01$ ensures all neurons have some output which can be backpropagated in the first training cycle." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "2f1c2946", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# building our neural network\n", - "\n", - "n_inputs, n_features = X_train.shape\n", - "n_hidden_neurons = 50\n", - "n_categories = 10\n", - "\n", - "# we make the weights normally distributed using numpy.random.randn\n", - "\n", - "# weights and bias in the hidden layer\n", - "hidden_weights = np.random.randn(n_features, n_hidden_neurons)\n", - "hidden_bias = np.zeros(n_hidden_neurons) + 0.01\n", - "\n", - "# weights and bias in the output layer\n", - "output_weights = np.random.randn(n_hidden_neurons, n_categories)\n", - "output_bias = np.zeros(n_categories) + 0.01" - ] - }, - { - "cell_type": "markdown", - "id": "8f3da5d5", - "metadata": { - "editable": true - }, - "source": [ - "## Feed-forward pass\n", - "\n", - "Denote $F$ the number of features, $H$ the number of hidden neurons and $C$ the number of categories. \n", - "For each input image we calculate a weighted sum of input features (pixel values) to each neuron $j$ in the hidden layer $l$: \n", - "\n", - "$$ z_{j}^{l} = \\sum_{i=1}^{F} w_{ij}^{l} x_i + b_{j}^{l},$$\n", - "\n", - "this is then passed through our activation function \n", - "\n", - "$$ a_{j}^{l} = f(z_{j}^{l}) .$$ \n", - "\n", - "We calculate a weighted sum of inputs (activations in the hidden layer) to each neuron $j$ in the output layer: \n", - "\n", - "$$ z_{j}^{L} = \\sum_{i=1}^{H} w_{ij}^{L} a_{i}^{l} + b_{j}^{L}.$$ \n", - "\n", - "Finally we calculate the output of neuron $j$ in the output layer using the softmax function: \n", - "\n", - "$$ a_{j}^{L} = \\frac{\\exp{(z_j^{L})}}\n", - "{\\sum_{c=0}^{C-1} \\exp{(z_c^{L})}} .$$" - ] - }, - { - "cell_type": "markdown", - "id": "bd250632", - "metadata": { - "editable": true - }, - "source": [ - "## Matrix multiplications\n", - "\n", - "Since our data has the dimensions $X = (n_{inputs}, n_{features})$ and our weights to the hidden\n", - "layer have the dimensions \n", - "$W_{hidden} = (n_{features}, n_{hidden})$,\n", - "we can easily feed the network all our training data in one go by taking the matrix product \n", - "\n", - "$$ X W^{h} = (n_{inputs}, n_{hidden}),$$ \n", - "\n", - "and obtain a matrix that holds the weighted sum of inputs to the hidden layer\n", - "for each input image and each hidden neuron. \n", - "We also add the bias to obtain a matrix of weighted sums to the hidden layer $Z^{h}$: \n", - "\n", - "$$ \\boldsymbol{z}^{l} = \\boldsymbol{X} \\boldsymbol{W}^{l} + \\boldsymbol{b}^{l} ,$$\n", - "\n", - "meaning the same bias (1D array with size equal number of hidden neurons) is added to each input image. \n", - "This is then passed through the activation: \n", - "\n", - "$$ \\boldsymbol{a}^{l} = f(\\boldsymbol{z}^l) .$$ \n", - "\n", - "This is fed to the output layer: \n", - "\n", - "$$ \\boldsymbol{z}^{L} = \\boldsymbol{a}^{L} \\boldsymbol{W}^{L} + \\boldsymbol{b}^{L} .$$\n", - "\n", - "Finally we receive our output values for each image and each category by passing it through the softmax function: \n", - "\n", - "$$ output = softmax (\\boldsymbol{z}^{L}) = (n_{inputs}, n_{categories}) .$$" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "9367a90d", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# setup the feed-forward pass, subscript h = hidden layer\n", - "\n", - "def sigmoid(x):\n", - " return 1/(1 + np.exp(-x))\n", - "\n", - "def feed_forward(X):\n", - " # weighted sum of inputs to the hidden layer\n", - " z_h = np.matmul(X, hidden_weights) + hidden_bias\n", - " # activation in the hidden layer\n", - " a_h = sigmoid(z_h)\n", - " \n", - " # weighted sum of inputs to the output layer\n", - " z_o = np.matmul(a_h, output_weights) + output_bias\n", - " # softmax output\n", - " # axis 0 holds each input and axis 1 the probabilities of each category\n", - " exp_term = np.exp(z_o)\n", - " probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)\n", - " \n", - " return probabilities\n", - "\n", - "probabilities = feed_forward(X_train)\n", - "print(\"probabilities = (n_inputs, n_categories) = \" + str(probabilities.shape))\n", - "print(\"probability that image 0 is in category 0,1,2,...,9 = \\n\" + str(probabilities[0]))\n", - "print(\"probabilities sum up to: \" + str(probabilities[0].sum()))\n", - "print()\n", - "\n", - "# we obtain a prediction by taking the class with the highest likelihood\n", - "def predict(X):\n", - " probabilities = feed_forward(X)\n", - " return np.argmax(probabilities, axis=1)\n", - "\n", - "predictions = predict(X_train)\n", - "print(\"predictions = (n_inputs) = \" + str(predictions.shape))\n", - "print(\"prediction for image 0: \" + str(predictions[0]))\n", - "print(\"correct label for image 0: \" + str(Y_train[0]))" - ] - }, - { - "cell_type": "markdown", - "id": "06333cb2", - "metadata": { - "editable": true - }, - "source": [ - "## Choose cost function and optimizer\n", - "\n", - "To measure how well our neural network is doing we need to introduce a cost function. \n", - "We will call the function that gives the error of a single sample output the *loss* function, and the function\n", - "that gives the total error of our network across all samples the *cost* function.\n", - "A typical choice for multiclass classification is the *cross-entropy* loss, also known as the negative log likelihood. \n", - "\n", - "In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: \n", - "\n", - "$$ y = 5 \\quad \\rightarrow \\quad \\boldsymbol{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$$ \n", - "\n", - "$$ y = 1 \\quad \\rightarrow \\quad \\boldsymbol{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$$ \n", - "\n", - "i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset. \n", - "\n", - "Let $y_{ic}$ denote the $c$-th component of the $i$-th one-hot vector. \n", - "We define the cost function $\\mathcal{C}$ as a sum over the cross-entropy loss for each point $\\boldsymbol{x}_i$ in the dataset.\n", - "\n", - "In the one-hot representation only one of the terms in the loss function is non-zero, namely the\n", - "probability of the correct category $c'$ \n", - "(i.e. the category $c'$ such that $y_{ic'} = 1$). This means that the cross entropy loss only punishes you for how wrong\n", - "you got the correct label. The probability of category $c$ is given by the softmax function. The vector $\\boldsymbol{\\theta}$ represents the parameters of our network, i.e. all the weights and biases." - ] - }, - { - "cell_type": "markdown", - "id": "c7de629a", - "metadata": { - "editable": true - }, - "source": [ - "## Optimizing the cost function\n", - "\n", - "The network is trained by finding the weights and biases that minimize the cost function. One of the most widely used classes of methods is *gradient descent* and its generalizations. The idea behind gradient descent\n", - "is simply to adjust the weights in the direction where the gradient of the cost function is large and negative. This ensures we flow toward a *local* minimum of the cost function. \n", - "Each parameter $\\theta$ is iteratively adjusted according to the rule \n", - "\n", - "$$ \\theta_{i+1} = \\theta_i - \\eta \\nabla \\mathcal{C}(\\theta_i) ,$$\n", - "\n", - "where $\\eta$ is known as the *learning rate*, which controls how big a step we take towards the minimum. \n", - "This update can be repeated for any number of iterations, or until we are satisfied with the result. \n", - "\n", - "A simple and effective improvement is a variant called *Batch Gradient Descent*. \n", - "Instead of calculating the gradient on the whole dataset, we calculate an approximation of the gradient\n", - "on a subset of the data called a *minibatch*. \n", - "If there are $N$ data points and we have a minibatch size of $M$, the total number of batches\n", - "is $N/M$. \n", - "We denote each minibatch $B_k$, with $k = 1, 2,...,N/M$. The gradient then becomes: \n", - "\n", - "$$ \\nabla \\mathcal{C}(\\theta) = \\frac{1}{N} \\sum_{i=1}^N \\nabla \\mathcal{L}_i(\\theta) \\quad \\rightarrow \\quad\n", - "\\frac{1}{M} \\sum_{i \\in B_k} \\nabla \\mathcal{L}_i(\\theta) ,$$\n", - "\n", - "i.e. instead of averaging the loss over the entire dataset, we average over a minibatch. \n", - "\n", - "This has two important benefits: \n", - "1. Introducing stochasticity decreases the chance that the algorithm becomes stuck in a local minima. \n", - "\n", - "2. It significantly speeds up the calculation, since we do not have to use the entire dataset to calculate the gradient. \n", - "\n", - "The various optmization methods, with codes and algorithms, are discussed in our lectures on [Gradient descent approaches](https://compphysics.github.io/MachineLearning/doc/pub/Splines/html/Splines-bs.html)." - ] - }, - { - "cell_type": "markdown", - "id": "467898fe", - "metadata": { - "editable": true - }, - "source": [ - "## Regularization\n", - "\n", - "It is common to add an extra term to the cost function, proportional\n", - "to the size of the weights. This is equivalent to constraining the\n", - "size of the weights, so that they do not grow out of control.\n", - "Constraining the size of the weights means that the weights cannot\n", - "grow arbitrarily large to fit the training data, and in this way\n", - "reduces *overfitting*.\n", - "\n", - "We will measure the size of the weights using the so called *L2-norm*, meaning our cost function becomes: \n", - "\n", - "$$ \\mathcal{C}(\\theta) = \\frac{1}{N} \\sum_{i=1}^N \\mathcal{L}_i(\\theta) \\quad \\rightarrow \\quad\n", - "\\frac{1}{N} \\sum_{i=1}^N \\mathcal{L}_i(\\theta) + \\lambda \\lvert \\lvert \\boldsymbol{w} \\rvert \\rvert_2^2 \n", - "= \\frac{1}{N} \\sum_{i=1}^N \\mathcal{L}(\\theta) + \\lambda \\sum_{ij} w_{ij}^2,$$ \n", - "\n", - "i.e. we sum up all the weights squared. The factor $\\lambda$ is known as a regularization parameter.\n", - "\n", - "In order to train the model, we need to calculate the derivative of\n", - "the cost function with respect to every bias and weight in the\n", - "network. In total our network has $(64 + 1)\\times 50=3250$ weights in\n", - "the hidden layer and $(50 + 1)\\times 10=510$ weights to the output\n", - "layer ($+1$ for the bias), and the gradient must be calculated for\n", - "every parameter. We use the *backpropagation* algorithm discussed\n", - "above. This is a clever use of the chain rule that allows us to\n", - "calculate the gradient efficently." - ] - }, - { - "cell_type": "markdown", - "id": "da72e113", - "metadata": { - "editable": true - }, - "source": [ - "## Matrix multiplication\n", - "\n", - "To more efficently train our network these equations are implemented using matrix operations. \n", - "The error in the output layer is calculated simply as, with $\\boldsymbol{t}$ being our targets, \n", - "\n", - "$$ \\delta_L = \\boldsymbol{t} - \\boldsymbol{y} = (n_{inputs}, n_{categories}) .$$ \n", - "\n", - "The gradient for the output weights is calculated as \n", - "\n", - "$$ \\nabla W_{L} = \\boldsymbol{a}^T \\delta_L = (n_{hidden}, n_{categories}) ,$$\n", - "\n", - "where $\\boldsymbol{a} = (n_{inputs}, n_{hidden})$. This simply means that we are summing up the gradients for each input. \n", - "Since we are going backwards we have to transpose the activation matrix. \n", - "\n", - "The gradient with respect to the output bias is then \n", - "\n", - "$$ \\nabla \\boldsymbol{b}_{L} = \\sum_{i=1}^{n_{inputs}} \\delta_L = (n_{categories}) .$$ \n", - "\n", - "The error in the hidden layer is \n", - "\n", - "$$ \\Delta_h = \\delta_L W_{L}^T \\circ f'(z_{h}) = \\delta_L W_{L}^T \\circ a_{h} \\circ (1 - a_{h}) = (n_{inputs}, n_{hidden}) ,$$ \n", - "\n", - "where $f'(a_{h})$ is the derivative of the activation in the hidden layer. The matrix products mean\n", - "that we are summing up the products for each neuron in the output layer. The symbol $\\circ$ denotes\n", - "the *Hadamard product*, meaning element-wise multiplication. \n", - "\n", - "This again gives us the gradients in the hidden layer: \n", - "\n", - "$$ \\nabla W_{h} = X^T \\delta_h = (n_{features}, n_{hidden}) ,$$ \n", - "\n", - "$$ \\nabla b_{h} = \\sum_{i=1}^{n_{inputs}} \\delta_h = (n_{hidden}) .$$" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "356881fc", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# to categorical turns our integer vector into a onehot representation\n", - "from sklearn.metrics import accuracy_score\n", - "\n", - "# one-hot in numpy\n", - "def to_categorical_numpy(integer_vector):\n", - " n_inputs = len(integer_vector)\n", - " n_categories = np.max(integer_vector) + 1\n", - " onehot_vector = np.zeros((n_inputs, n_categories))\n", - " onehot_vector[range(n_inputs), integer_vector] = 1\n", - " \n", - " return onehot_vector\n", - "\n", - "#Y_train_onehot, Y_test_onehot = to_categorical(Y_train), to_categorical(Y_test)\n", - "Y_train_onehot, Y_test_onehot = to_categorical_numpy(Y_train), to_categorical_numpy(Y_test)\n", - "\n", - "def feed_forward_train(X):\n", - " # weighted sum of inputs to the hidden layer\n", - " z_h = np.matmul(X, hidden_weights) + hidden_bias\n", - " # activation in the hidden layer\n", - " a_h = sigmoid(z_h)\n", - " \n", - " # weighted sum of inputs to the output layer\n", - " z_o = np.matmul(a_h, output_weights) + output_bias\n", - " # softmax output\n", - " # axis 0 holds each input and axis 1 the probabilities of each category\n", - " exp_term = np.exp(z_o)\n", - " probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)\n", - " \n", - " # for backpropagation need activations in hidden and output layers\n", - " return a_h, probabilities\n", - "\n", - "def backpropagation(X, Y):\n", - " a_h, probabilities = feed_forward_train(X)\n", - " \n", - " # error in the output layer\n", - " error_output = probabilities - Y\n", - " # error in the hidden layer\n", - " error_hidden = np.matmul(error_output, output_weights.T) * a_h * (1 - a_h)\n", - " \n", - " # gradients for the output layer\n", - " output_weights_gradient = np.matmul(a_h.T, error_output)\n", - " output_bias_gradient = np.sum(error_output, axis=0)\n", - " \n", - " # gradient for the hidden layer\n", - " hidden_weights_gradient = np.matmul(X.T, error_hidden)\n", - " hidden_bias_gradient = np.sum(error_hidden, axis=0)\n", - "\n", - " return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient\n", - "\n", - "print(\"Old accuracy on training data: \" + str(accuracy_score(predict(X_train), Y_train)))\n", - "\n", - "eta = 0.01\n", - "lmbd = 0.01\n", - "for i in range(1000):\n", - " # calculate gradients\n", - " dWo, dBo, dWh, dBh = backpropagation(X_train, Y_train_onehot)\n", - " \n", - " # regularization term gradients\n", - " dWo += lmbd * output_weights\n", - " dWh += lmbd * hidden_weights\n", - " \n", - " # update weights and biases\n", - " output_weights -= eta * dWo\n", - " output_bias -= eta * dBo\n", - " hidden_weights -= eta * dWh\n", - " hidden_bias -= eta * dBh\n", - "\n", - "print(\"New accuracy on training data: \" + str(accuracy_score(predict(X_train), Y_train)))" - ] - }, - { - "cell_type": "markdown", - "id": "978a1d33", - "metadata": { - "editable": true - }, - "source": [ - "## Improving performance\n", - "\n", - "As we can see the network does not seem to be learning at all. It seems to be just guessing the label for each image. \n", - "In order to obtain a network that does something useful, we will have to do a bit more work. \n", - "\n", - "The choice of *hyperparameters* such as learning rate and regularization parameter is hugely influential for the performance of the network. Typically a *grid-search* is performed, wherein we test different hyperparameters separated by orders of magnitude. For example we could test the learning rates $\\eta = 10^{-6}, 10^{-5},...,10^{-1}$ with different regularization parameters $\\lambda = 10^{-6},...,10^{-0}$. \n", - "\n", - "Next, we haven't implemented minibatching yet, which introduces stochasticity and is though to act as an important regularizer on the weights. We call a feed-forward + backward pass with a minibatch an *iteration*, and a full training period\n", - "going through the entire dataset ($n/M$ batches) an *epoch*.\n", - "\n", - "If this does not improve network performance, you may want to consider altering the network architecture, adding more neurons or hidden layers. \n", - "Andrew Ng goes through some of these considerations in this [video](https://youtu.be/F1ka6a13S9I). You can find a summary of the video [here](https://kevinzakka.github.io/2016/09/26/applying-deep-learning/)." - ] - }, - { - "cell_type": "markdown", - "id": "2c42fc5d", - "metadata": { - "editable": true - }, - "source": [ - "## Full object-oriented implementation\n", - "\n", - "It is very natural to think of the network as an object, with specific instances of the network\n", - "being realizations of this object with different hyperparameters. An implementation using Python classes provides a clean structure and interface, and the full implementation of our neural network is given below." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "c54a3f5d", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "class NeuralNetwork:\n", - " def __init__(\n", - " self,\n", - " X_data,\n", - " Y_data,\n", - " n_hidden_neurons=50,\n", - " n_categories=10,\n", - " epochs=10,\n", - " batch_size=100,\n", - " eta=0.1,\n", - " lmbd=0.0):\n", - "\n", - " self.X_data_full = X_data\n", - " self.Y_data_full = Y_data\n", - "\n", - " self.n_inputs = X_data.shape[0]\n", - " self.n_features = X_data.shape[1]\n", - " self.n_hidden_neurons = n_hidden_neurons\n", - " self.n_categories = n_categories\n", - "\n", - " self.epochs = epochs\n", - " self.batch_size = batch_size\n", - " self.iterations = self.n_inputs // self.batch_size\n", - " self.eta = eta\n", - " self.lmbd = lmbd\n", - "\n", - " self.create_biases_and_weights()\n", - "\n", - " def create_biases_and_weights(self):\n", - " self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons)\n", - " self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01\n", - "\n", - " self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories)\n", - " self.output_bias = np.zeros(self.n_categories) + 0.01\n", - "\n", - " def feed_forward(self):\n", - " # feed-forward for training\n", - " self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias\n", - " self.a_h = sigmoid(self.z_h)\n", - "\n", - " self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias\n", - "\n", - " exp_term = np.exp(self.z_o)\n", - " self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)\n", - "\n", - " def feed_forward_out(self, X):\n", - " # feed-forward for output\n", - " z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias\n", - " a_h = sigmoid(z_h)\n", - "\n", - " z_o = np.matmul(a_h, self.output_weights) + self.output_bias\n", - " \n", - " exp_term = np.exp(z_o)\n", - " probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)\n", - " return probabilities\n", - "\n", - " def backpropagation(self):\n", - " error_output = self.probabilities - self.Y_data\n", - " error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h)\n", - "\n", - " self.output_weights_gradient = np.matmul(self.a_h.T, error_output)\n", - " self.output_bias_gradient = np.sum(error_output, axis=0)\n", - "\n", - " self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden)\n", - " self.hidden_bias_gradient = np.sum(error_hidden, axis=0)\n", - "\n", - " if self.lmbd > 0.0:\n", - " self.output_weights_gradient += self.lmbd * self.output_weights\n", - " self.hidden_weights_gradient += self.lmbd * self.hidden_weights\n", - "\n", - " self.output_weights -= self.eta * self.output_weights_gradient\n", - " self.output_bias -= self.eta * self.output_bias_gradient\n", - " self.hidden_weights -= self.eta * self.hidden_weights_gradient\n", - " self.hidden_bias -= self.eta * self.hidden_bias_gradient\n", - "\n", - " def predict(self, X):\n", - " probabilities = self.feed_forward_out(X)\n", - " return np.argmax(probabilities, axis=1)\n", - "\n", - " def predict_probabilities(self, X):\n", - " probabilities = self.feed_forward_out(X)\n", - " return probabilities\n", - "\n", - " def train(self):\n", - " data_indices = np.arange(self.n_inputs)\n", - "\n", - " for i in range(self.epochs):\n", - " for j in range(self.iterations):\n", - " # pick datapoints with replacement\n", - " chosen_datapoints = np.random.choice(\n", - " data_indices, size=self.batch_size, replace=False\n", - " )\n", - "\n", - " # minibatch training data\n", - " self.X_data = self.X_data_full[chosen_datapoints]\n", - " self.Y_data = self.Y_data_full[chosen_datapoints]\n", - "\n", - " self.feed_forward()\n", - " self.backpropagation()" - ] - }, - { - "cell_type": "markdown", - "id": "bde5d577", - "metadata": { - "editable": true - }, - "source": [ - "## Evaluate model performance on test data\n", - "\n", - "To measure the performance of our network we evaluate how well it does it data it has never seen before, i.e. the test data. \n", - "We measure the performance of the network using the *accuracy* score. \n", - "The accuracy is as you would expect just the number of images correctly labeled divided by the total number of images. A perfect classifier will have an accuracy score of $1$. \n", - "\n", - "$$ \\text{Accuracy} = \\frac{\\sum_{i=1}^n I(\\tilde{y}_i = y_i)}{n} ,$$ \n", - "\n", - "where $I$ is the indicator function, $1$ if $\\tilde{y}_i = y_i$ and $0$ otherwise." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "0ff4f685", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "epochs = 100\n", - "batch_size = 100\n", - "\n", - "dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,\n", - " n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)\n", - "dnn.train()\n", - "test_predict = dnn.predict(X_test)\n", - "\n", - "# accuracy score from scikit library\n", - "print(\"Accuracy score on test set: \", accuracy_score(Y_test, test_predict))\n", - "\n", - "# equivalent in numpy\n", - "def accuracy_score_numpy(Y_test, Y_pred):\n", - " return np.sum(Y_test == Y_pred) / len(Y_test)\n", - "\n", - "#print(\"Accuracy score on test set: \", accuracy_score_numpy(Y_test, test_predict))" - ] - }, - { - "cell_type": "markdown", - "id": "222281ee", - "metadata": { - "editable": true - }, - "source": [ - "## Adjust hyperparameters\n", - "\n", - "We now perform a grid search to find the optimal hyperparameters for the network. \n", - "Note that we are only using 1 layer with 50 neurons, and human performance is estimated to be around $98\\%$ ($2\\%$ error rate)." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "bff5aecd", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "eta_vals = np.logspace(-5, 1, 7)\n", - "lmbd_vals = np.logspace(-5, 1, 7)\n", - "# store the models for later use\n", - "DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n", - "\n", - "# grid search\n", - "for i, eta in enumerate(eta_vals):\n", - " for j, lmbd in enumerate(lmbd_vals):\n", - " dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size,\n", - " n_hidden_neurons=n_hidden_neurons, n_categories=n_categories)\n", - " dnn.train()\n", - " \n", - " DNN_numpy[i][j] = dnn\n", - " \n", - " test_predict = dnn.predict(X_test)\n", - " \n", - " print(\"Learning rate = \", eta)\n", - " print(\"Lambda = \", lmbd)\n", - " print(\"Accuracy score on test set: \", accuracy_score(Y_test, test_predict))\n", - " print()" - ] - }, - { - "cell_type": "markdown", - "id": "205932c1", - "metadata": { - "editable": true - }, - "source": [ - "## Visualization" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "90a6c9a8", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# visual representation of grid search\n", - "# uses seaborn heatmap, you can also do this with matplotlib imshow\n", - "import seaborn as sns\n", - "\n", - "sns.set()\n", - "\n", - "train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", - "test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", - "\n", - "for i in range(len(eta_vals)):\n", - " for j in range(len(lmbd_vals)):\n", - " dnn = DNN_numpy[i][j]\n", - " \n", - " train_pred = dnn.predict(X_train) \n", - " test_pred = dnn.predict(X_test)\n", - "\n", - " train_accuracy[i][j] = accuracy_score(Y_train, train_pred)\n", - " test_accuracy[i][j] = accuracy_score(Y_test, test_pred)\n", - "\n", - " \n", - "fig, ax = plt.subplots(figsize = (10, 10))\n", - "sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", - "ax.set_title(\"Training Accuracy\")\n", - "ax.set_ylabel(\"$\\eta$\")\n", - "ax.set_xlabel(\"$\\lambda$\")\n", - "plt.show()\n", - "\n", - "fig, ax = plt.subplots(figsize = (10, 10))\n", - "sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", - "ax.set_title(\"Test Accuracy\")\n", - "ax.set_ylabel(\"$\\eta$\")\n", - "ax.set_xlabel(\"$\\lambda$\")\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "id": "8616f12b", - "metadata": { - "editable": true - }, - "source": [ - "## scikit-learn implementation\n", - "\n", - "**scikit-learn** focuses more\n", - "on traditional machine learning methods, such as regression,\n", - "clustering, decision trees, etc. As such, it has only two types of\n", - "neural networks: Multi Layer Perceptron outputting continuous values,\n", - "*MPLRegressor*, and Multi Layer Perceptron outputting labels,\n", - "*MLPClassifier*. We will see how simple it is to use these classes.\n", - "\n", - "**scikit-learn** implements a few improvements from our neural network,\n", - "such as early stopping, a varying learning rate, different\n", - "optimization methods, etc. We would therefore expect a better\n", - "performance overall." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "38c2dff0", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.neural_network import MLPClassifier\n", - "# store models for later use\n", - "DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n", - "\n", - "for i, eta in enumerate(eta_vals):\n", - " for j, lmbd in enumerate(lmbd_vals):\n", - " dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic',\n", - " alpha=lmbd, learning_rate_init=eta, max_iter=epochs)\n", - " dnn.fit(X_train, Y_train)\n", - " \n", - " DNN_scikit[i][j] = dnn\n", - " \n", - " print(\"Learning rate = \", eta)\n", - " print(\"Lambda = \", lmbd)\n", - " print(\"Accuracy score on test set: \", dnn.score(X_test, Y_test))\n", - " print()" - ] - }, - { - "cell_type": "markdown", - "id": "766c15ae", - "metadata": { - "editable": true - }, - "source": [ - "## Visualization" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "b8670cd3", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# optional\n", - "# visual representation of grid search\n", - "# uses seaborn heatmap, could probably do this in matplotlib\n", - "import seaborn as sns\n", - "\n", - "sns.set()\n", - "\n", - "train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", - "test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", - "\n", - "for i in range(len(eta_vals)):\n", - " for j in range(len(lmbd_vals)):\n", - " dnn = DNN_scikit[i][j]\n", - " \n", - " train_pred = dnn.predict(X_train) \n", - " test_pred = dnn.predict(X_test)\n", - "\n", - " train_accuracy[i][j] = accuracy_score(Y_train, train_pred)\n", - " test_accuracy[i][j] = accuracy_score(Y_test, test_pred)\n", - "\n", - " \n", - "fig, ax = plt.subplots(figsize = (10, 10))\n", - "sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", - "ax.set_title(\"Training Accuracy\")\n", - "ax.set_ylabel(\"$\\eta$\")\n", - "ax.set_xlabel(\"$\\lambda$\")\n", - "plt.show()\n", - "\n", - "fig, ax = plt.subplots(figsize = (10, 10))\n", - "sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", - "ax.set_title(\"Test Accuracy\")\n", - "ax.set_ylabel(\"$\\eta$\")\n", - "ax.set_xlabel(\"$\\lambda$\")\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "id": "512ca005", + "id": "a29b38bc", "metadata": { "editable": true }, @@ -2019,7 +483,7 @@ }, { "cell_type": "markdown", - "id": "0fa97800", + "id": "f64479f0", "metadata": { "editable": true }, @@ -2053,8 +517,8 @@ }, { "cell_type": "code", - "execution_count": 12, - "id": "7bdc829d", + "execution_count": 1, + "id": "b27970e4", "metadata": { "collapsed": false, "editable": true @@ -2066,7 +530,7 @@ }, { "cell_type": "markdown", - "id": "1fcedfc6", + "id": "9427cab2", "metadata": { "editable": true }, @@ -2077,8 +541,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "id": "a96a6361", + "execution_count": 2, + "id": "265a9d8e", "metadata": { "collapsed": false, "editable": true @@ -2091,7 +555,7 @@ }, { "cell_type": "markdown", - "id": "540e8c9b", + "id": "d0362f60", "metadata": { "editable": true }, @@ -2101,8 +565,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "73b6c334", + "execution_count": 3, + "id": "31150e3d", "metadata": { "collapsed": false, "editable": true @@ -2115,7 +579,7 @@ }, { "cell_type": "markdown", - "id": "df6cd2ce", + "id": "d3ea5b10", "metadata": { "editable": true }, @@ -2129,8 +593,8 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "b5d544a0", + "execution_count": 4, + "id": "c9005b14", "metadata": { "collapsed": false, "editable": true @@ -2142,7 +606,7 @@ }, { "cell_type": "markdown", - "id": "a456ab5f", + "id": "6fd9e28c", "metadata": { "editable": true }, @@ -2154,7 +618,7 @@ }, { "cell_type": "markdown", - "id": "53a01445", + "id": "b2e58b9d", "metadata": { "editable": true }, @@ -2166,14 +630,16 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "3026f2a6", + "execution_count": 5, + "id": "6bcb2d1b", "metadata": { "collapsed": false, "editable": true }, "outputs": [], "source": [ + "%matplotlib inline\n", + "\n", "# import necessary packages\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", @@ -2221,8 +687,8 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "9b5cdbc5", + "execution_count": 6, + "id": "33f9b277", "metadata": { "collapsed": false, "editable": true @@ -2250,8 +716,8 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "62419d1b", + "execution_count": 7, + "id": "ef4311ca", "metadata": { "collapsed": false, "editable": true @@ -2280,8 +746,8 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "ba4de85c", + "execution_count": 8, + "id": "263854b8", "metadata": { "collapsed": false, "editable": true @@ -2307,8 +773,8 @@ }, { "cell_type": "code", - "execution_count": 20, - "id": "0ba97552", + "execution_count": 9, + "id": "b7d2c6cf", "metadata": { "collapsed": false, "editable": true @@ -2350,18 +816,116 @@ }, { "cell_type": "markdown", - "id": "e3785d9f", + "id": "e3189e7e", "metadata": { "editable": true }, "source": [ - "## The Breast Cancer Data, now with Keras" + "## Using Pytorch with the full MNIST data set" ] }, { "cell_type": "code", - "execution_count": 21, - "id": "9c50fc5e", + "execution_count": 10, + "id": "80b9b56f", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import torch\n", + "import torch.nn as nn\n", + "import torch.optim as optim\n", + "import torchvision\n", + "import torchvision.transforms as transforms\n", + "\n", + "# Device configuration: use GPU if available\n", + "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", + "\n", + "# MNIST dataset (downloads if not already present)\n", + "transform = transforms.Compose([\n", + " transforms.ToTensor(),\n", + " transforms.Normalize((0.5,), (0.5,)) # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)\n", + "])\n", + "train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)\n", + "test_dataset = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)\n", + "\n", + "train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)\n", + "test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)\n", + "\n", + "\n", + "class NeuralNet(nn.Module):\n", + " def __init__(self):\n", + " super(NeuralNet, self).__init__()\n", + " self.fc1 = nn.Linear(28*28, 100) # first hidden layer (784 -> 100)\n", + " self.fc2 = nn.Linear(100, 100) # second hidden layer (100 -> 100)\n", + " self.fc3 = nn.Linear(100, 10) # output layer (100 -> 10 classes)\n", + " def forward(self, x):\n", + " x = x.view(x.size(0), -1) # flatten images into vectors of size 784\n", + " x = torch.relu(self.fc1(x)) # hidden layer 1 + ReLU activation\n", + " x = torch.relu(self.fc2(x)) # hidden layer 2 + ReLU activation\n", + " x = self.fc3(x) # output layer (logits for 10 classes)\n", + " return x\n", + "\n", + "model = NeuralNet().to(device)\n", + "\n", + "\n", + "criterion = nn.CrossEntropyLoss()\n", + "optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)\n", + "\n", + "num_epochs = 10\n", + "for epoch in range(num_epochs):\n", + " model.train() # set model to training mode\n", + " running_loss = 0.0\n", + " for images, labels in train_loader:\n", + " # Move data to device (GPU if available, else CPU)\n", + " images, labels = images.to(device), labels.to(device)\n", + "\n", + " optimizer.zero_grad() # reset gradients to zero\n", + " outputs = model(images) # forward pass: compute predictions\n", + " loss = criterion(outputs, labels) # compute cross-entropy loss\n", + " loss.backward() # backpropagate to compute gradients\n", + " optimizer.step() # update weights using SGD step \n", + "\n", + " running_loss += loss.item()\n", + " # Compute average loss over all batches in this epoch\n", + " avg_loss = running_loss / len(train_loader)\n", + " print(f\"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}\")\n", + "\n", + "#Evaluation on the Test Set\n", + "\n", + "\n", + "\n", + "model.eval() # set model to evaluation mode \n", + "correct = 0\n", + "total = 0\n", + "with torch.no_grad(): # disable gradient calculation for evaluation \n", + " for images, labels in test_loader:\n", + " images, labels = images.to(device), labels.to(device)\n", + " outputs = model(images)\n", + " _, predicted = torch.max(outputs, dim=1) # class with highest score\n", + " total += labels.size(0)\n", + " correct += (predicted == labels).sum().item()\n", + "\n", + "accuracy = 100 * correct / total\n", + "print(f\"Test Accuracy: {accuracy:.2f}%\")" + ] + }, + { + "cell_type": "markdown", + "id": "38da87d8", + "metadata": { + "editable": true + }, + "source": [ + "## And a similar example using Tensorflow with Keras" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ebe99aeb", "metadata": { "collapsed": false, "editable": true @@ -2370,180 +934,63 @@ "source": [ "\n", "import tensorflow as tf\n", - "from tensorflow.keras.layers import Input\n", - "from tensorflow.keras.models import Sequential #This allows appending layers to existing models\n", - "from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer\n", - "from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)\n", - "from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)\n", - "from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import seaborn as sns\n", - "from sklearn.model_selection import train_test_split as splitter\n", - "from sklearn.datasets import load_breast_cancer\n", - "import pickle\n", - "import os \n", + "from tensorflow import keras\n", + "from tensorflow.keras import layers, regularizers\n", "\n", + "# Check for GPU (TensorFlow will use it automatically if available)\n", + "gpus = tf.config.list_physical_devices('GPU')\n", + "print(f\"GPUs available: {gpus}\")\n", "\n", - "\"\"\"Load breast cancer dataset\"\"\"\n", + "# 1) Load and preprocess MNIST\n", + "(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()\n", + "# Normalize to [0, 1]\n", + "x_train = (x_train.astype(\"float32\") / 255.0)\n", + "x_test = (x_test.astype(\"float32\") / 255.0)\n", "\n", - "np.random.seed(0) #create same seed for random number every time\n", + "# 2) Build the model: 784 -> 100 -> 100 -> 10\n", + "l2_reg = 1e-4 # L2 regularization strength\n", "\n", - "cancer=load_breast_cancer() #Download breast cancer dataset\n", + "model = keras.Sequential([\n", + " layers.Input(shape=(28, 28)),\n", + " layers.Flatten(),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(10, activation=\"softmax\") # output probabilities for 10 classes\n", + "])\n", "\n", - "inputs=cancer.data #Feature matrix of 569 rows (samples) and 30 columns (parameters)\n", - "outputs=cancer.target #Label array of 569 rows (0 for benign and 1 for malignant)\n", - "labels=cancer.feature_names[0:30]\n", + "# 3) Compile with SGD + weight decay via L2 regularizers\n", + "model.compile(\n", + " optimizer=keras.optimizers.SGD(learning_rate=0.01),\n", + " loss=\"sparse_categorical_crossentropy\",\n", + " metrics=[\"accuracy\"],\n", + ")\n", "\n", - "print('The content of the breast cancer dataset is:') #Print information about the datasets\n", - "print(labels)\n", - "print('-------------------------')\n", - "print(\"inputs = \" + str(inputs.shape))\n", - "print(\"outputs = \" + str(outputs.shape))\n", - "print(\"labels = \"+ str(labels.shape))\n", + "model.summary()\n", "\n", - "x=inputs #Reassign the Feature and Label matrices to other variables\n", - "y=outputs\n", + "# 4) Train\n", + "history = model.fit(\n", + " x_train, y_train,\n", + " epochs=10,\n", + " batch_size=64,\n", + " validation_split=0.1, # optional: monitor validation during training\n", + " verbose=1\n", + ")\n", "\n", - "#%% \n", - "\n", - "# Visualisation of dataset (for correlation analysis)\n", - "\n", - "plt.figure()\n", - "plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral)\n", - "plt.xlabel('Mean radius',fontweight='bold')\n", - "plt.ylabel('Mean perimeter',fontweight='bold')\n", - "plt.show()\n", - "\n", - "plt.figure()\n", - "plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral)\n", - "plt.xlabel('Mean compactness',fontweight='bold')\n", - "plt.ylabel('Mean concavity',fontweight='bold')\n", - "plt.show()\n", - "\n", - "\n", - "plt.figure()\n", - "plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)\n", - "plt.xlabel('Mean radius',fontweight='bold')\n", - "plt.ylabel('Mean texture',fontweight='bold')\n", - "plt.show()\n", - "\n", - "plt.figure()\n", - "plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral)\n", - "plt.xlabel('Mean perimeter',fontweight='bold')\n", - "plt.ylabel('Mean compactness',fontweight='bold')\n", - "plt.show()\n", - "\n", - "\n", - "# Generate training and testing datasets\n", - "\n", - "#Select features relevant to classification (texture,perimeter,compactness and symmetery) \n", - "#and add to input matrix\n", - "\n", - "temp1=np.reshape(x[:,1],(len(x[:,1]),1))\n", - "temp2=np.reshape(x[:,2],(len(x[:,2]),1))\n", - "X=np.hstack((temp1,temp2)) \n", - "temp=np.reshape(x[:,5],(len(x[:,5]),1))\n", - "X=np.hstack((X,temp)) \n", - "temp=np.reshape(x[:,8],(len(x[:,8]),1))\n", - "X=np.hstack((X,temp)) \n", - "\n", - "X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1) #Split datasets into training and testing\n", - "\n", - "y_train=to_categorical(y_train) #Convert labels to categorical when using categorical cross entropy\n", - "y_test=to_categorical(y_test)\n", - "\n", - "del temp1,temp2,temp\n", - "\n", - "# %%\n", - "\n", - "# Define tunable parameters\"\n", - "\n", - "eta=np.logspace(-3,-1,3) #Define vector of learning rates (parameter to SGD optimiser)\n", - "lamda=0.01 #Define hyperparameter\n", - "n_layers=2 #Define number of hidden layers in the model\n", - "n_neuron=np.logspace(0,3,4,dtype=int) #Define number of neurons per layer\n", - "epochs=100 #Number of reiterations over the input data\n", - "batch_size=100 #Number of samples per gradient update\n", - "\n", - "# %%\n", - "\n", - "\"\"\"Define function to return Deep Neural Network model\"\"\"\n", - "\n", - "def NN_model(inputsize,n_layers,n_neuron,eta,lamda):\n", - " model=Sequential() \n", - " for i in range(n_layers): #Run loop to add hidden layers to the model\n", - " if (i==0): #First layer requires input dimensions\n", - " model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize))\n", - " else: #Subsequent layers are capable of automatic shape inferencing\n", - " model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda)))\n", - " model.add(Dense(2,activation='softmax')) #2 outputs - ordered and disordered (softmax for prob)\n", - " sgd=optimizers.SGD(learning_rate=eta)\n", - " model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy'])\n", - " return model\n", - "\n", - " \n", - "Train_accuracy=np.zeros((len(n_neuron),len(eta))) #Define matrices to store accuracy scores as a function\n", - "Test_accuracy=np.zeros((len(n_neuron),len(eta))) #of learning rate and number of hidden neurons for \n", - "\n", - "for i in range(len(n_neuron)): #run loops over hidden neurons and learning rates to calculate \n", - " for j in range(len(eta)): #accuracy scores \n", - " DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda)\n", - " DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1)\n", - " Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1]\n", - " Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1]\n", - " \n", - "\n", - "def plot_data(x,y,data,title=None):\n", - "\n", - " # plot results\n", - " fontsize=16\n", - "\n", - "\n", - " fig = plt.figure()\n", - " ax = fig.add_subplot(111)\n", - " cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1)\n", - " \n", - " cbar=fig.colorbar(cax)\n", - " cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize)\n", - " cbar.set_ticks([0,.2,.4,0.6,0.8,1.0])\n", - " cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%'])\n", - "\n", - " # put text on matrix elements\n", - " for i, x_val in enumerate(np.arange(len(x))):\n", - " for j, y_val in enumerate(np.arange(len(y))):\n", - " c = \"${0:.1f}\\\\%$\".format( 100*data[j,i]) \n", - " ax.text(x_val, y_val, c, va='center', ha='center')\n", - "\n", - " # convert axis vaues to to string labels\n", - " x=[str(i) for i in x]\n", - " y=[str(i) for i in y]\n", - "\n", - "\n", - " ax.set_xticklabels(['']+x)\n", - " ax.set_yticklabels(['']+y)\n", - "\n", - " ax.set_xlabel('$\\\\mathrm{learning\\\\ rate}$',fontsize=fontsize)\n", - " ax.set_ylabel('$\\\\mathrm{hidden\\\\ neurons}$',fontsize=fontsize)\n", - " if title is not None:\n", - " ax.set_title(title)\n", - "\n", - " plt.tight_layout()\n", - "\n", - " plt.show()\n", - " \n", - "plot_data(eta,n_neuron,Train_accuracy, 'training')\n", - "plot_data(eta,n_neuron,Test_accuracy, 'testing')" + "# 5) Evaluate on test set\n", + "test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)\n", + "print(f\"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}\")" ] }, { "cell_type": "markdown", - "id": "ade357fd", + "id": "d675799d", "metadata": { "editable": true }, "source": [ - "## Building a neural network code\n", + "## Building our own neural network code\n", "\n", "Here we present a flexible object oriented codebase\n", "for a feed forward neural network, along with a demonstration of how\n", @@ -2557,7 +1004,7 @@ }, { "cell_type": "markdown", - "id": "77afb266", + "id": "5f0f9d3f", "metadata": { "editable": true }, @@ -2578,8 +1025,8 @@ }, { "cell_type": "code", - "execution_count": 22, - "id": "bfd96580", + "execution_count": 12, + "id": "d715d80c", "metadata": { "collapsed": false, "editable": true @@ -2720,7 +1167,7 @@ }, { "cell_type": "markdown", - "id": "ace26b9a", + "id": "c86a2a10", "metadata": { "editable": true }, @@ -2735,8 +1182,8 @@ }, { "cell_type": "code", - "execution_count": 23, - "id": "60867348", + "execution_count": 13, + "id": "c04fe314", "metadata": { "collapsed": false, "editable": true @@ -2749,7 +1196,7 @@ }, { "cell_type": "markdown", - "id": "12f1d032", + "id": "61a58ad8", "metadata": { "editable": true }, @@ -2760,8 +1207,8 @@ }, { "cell_type": "code", - "execution_count": 24, - "id": "78ae91c3", + "execution_count": 14, + "id": "c0662f37", "metadata": { "collapsed": false, "editable": true @@ -2783,7 +1230,7 @@ }, { "cell_type": "markdown", - "id": "e505e6ef", + "id": "c61d427f", "metadata": { "editable": true }, @@ -2798,8 +1245,8 @@ }, { "cell_type": "code", - "execution_count": 25, - "id": "195b3f3b", + "execution_count": 15, + "id": "b9393ed7", "metadata": { "collapsed": false, "editable": true @@ -2837,7 +1284,7 @@ }, { "cell_type": "markdown", - "id": "683f7300", + "id": "9b3e3442", "metadata": { "editable": true }, @@ -2849,8 +1296,8 @@ }, { "cell_type": "code", - "execution_count": 26, - "id": "5e9a52eb", + "execution_count": 16, + "id": "df1450c3", "metadata": { "collapsed": false, "editable": true @@ -2871,7 +1318,7 @@ }, { "cell_type": "markdown", - "id": "34fd5422", + "id": "12464028", "metadata": { "editable": true }, @@ -2886,8 +1333,8 @@ }, { "cell_type": "code", - "execution_count": 27, - "id": "429ec779", + "execution_count": 17, + "id": "030eac01", "metadata": { "collapsed": false, "editable": true @@ -2945,7 +1392,7 @@ }, { "cell_type": "markdown", - "id": "f1ffb711", + "id": "2e23398d", "metadata": { "editable": true }, @@ -2959,8 +1406,8 @@ }, { "cell_type": "code", - "execution_count": 28, - "id": "a08ff105", + "execution_count": 18, + "id": "dd8b1ca8", "metadata": { "collapsed": false, "editable": true @@ -2981,7 +1428,7 @@ }, { "cell_type": "markdown", - "id": "a6e789db", + "id": "5f3fee56", "metadata": { "editable": true }, @@ -3004,8 +1451,8 @@ }, { "cell_type": "code", - "execution_count": 29, - "id": "9f0ef730", + "execution_count": 19, + "id": "a687948a", "metadata": { "collapsed": false, "editable": true @@ -3477,7 +1924,7 @@ }, { "cell_type": "markdown", - "id": "6d6cae4f", + "id": "89b83980", "metadata": { "editable": true }, @@ -3488,8 +1935,8 @@ }, { "cell_type": "code", - "execution_count": 30, - "id": "e2c91847", + "execution_count": 20, + "id": "ec072ec1", "metadata": { "collapsed": false, "editable": true @@ -3533,7 +1980,7 @@ }, { "cell_type": "markdown", - "id": "e9049787", + "id": "299eeff2", "metadata": { "editable": true }, @@ -3548,8 +1995,8 @@ }, { "cell_type": "code", - "execution_count": 31, - "id": "a3af9356", + "execution_count": 21, + "id": "05c4af35", "metadata": { "collapsed": false, "editable": true @@ -3564,7 +2011,7 @@ }, { "cell_type": "markdown", - "id": "7c016294", + "id": "9731ba56", "metadata": { "editable": true }, @@ -3574,8 +2021,8 @@ }, { "cell_type": "code", - "execution_count": 32, - "id": "456a3a63", + "execution_count": 22, + "id": "daa31bab", "metadata": { "collapsed": false, "editable": true @@ -3590,7 +2037,7 @@ }, { "cell_type": "markdown", - "id": "a66bd6e5", + "id": "e59eb1cb", "metadata": { "editable": true }, @@ -3605,8 +2052,8 @@ }, { "cell_type": "code", - "execution_count": 33, - "id": "861e3e2b", + "execution_count": 23, + "id": "8045aaa7", "metadata": { "collapsed": false, "editable": true @@ -3620,7 +2067,7 @@ }, { "cell_type": "markdown", - "id": "614514f4", + "id": "f37f5dcc", "metadata": { "editable": true }, @@ -3634,8 +2081,8 @@ }, { "cell_type": "code", - "execution_count": 34, - "id": "595d3148", + "execution_count": 24, + "id": "81db6939", "metadata": { "collapsed": false, "editable": true @@ -3660,8 +2107,8 @@ }, { "cell_type": "code", - "execution_count": 35, - "id": "6d87e7d4", + "execution_count": 25, + "id": "23e49982", "metadata": { "collapsed": false, "editable": true @@ -3676,7 +2123,7 @@ }, { "cell_type": "markdown", - "id": "c21d1a42", + "id": "e6992d9e", "metadata": { "editable": true }, @@ -3686,8 +2133,8 @@ }, { "cell_type": "code", - "execution_count": 36, - "id": "a4c194ca", + "execution_count": 26, + "id": "48b68e30", "metadata": { "collapsed": false, "editable": true @@ -3702,7 +2149,7 @@ }, { "cell_type": "markdown", - "id": "11d9fe2d", + "id": "e5c5b96b", "metadata": { "editable": true }, @@ -3712,8 +2159,8 @@ }, { "cell_type": "code", - "execution_count": 37, - "id": "006df1f5", + "execution_count": 27, + "id": "8d367149", "metadata": { "collapsed": false, "editable": true @@ -3732,8 +2179,8 @@ }, { "cell_type": "code", - "execution_count": 38, - "id": "e5d4f374", + "execution_count": 28, + "id": "f1672be3", "metadata": { "collapsed": false, "editable": true @@ -3748,7 +2195,7 @@ }, { "cell_type": "markdown", - "id": "6d0775a4", + "id": "b23af8f2", "metadata": { "editable": true }, @@ -3762,8 +2209,8 @@ }, { "cell_type": "code", - "execution_count": 39, - "id": "0437ee65", + "execution_count": 29, + "id": "71ee7dd0", "metadata": { "collapsed": false, "editable": true @@ -3800,7 +2247,7 @@ }, { "cell_type": "markdown", - "id": "676f6839", + "id": "51fba00e", "metadata": { "editable": true }, @@ -3812,8 +2259,8 @@ }, { "cell_type": "code", - "execution_count": 40, - "id": "a0614327", + "execution_count": 30, + "id": "db11c06a", "metadata": { "collapsed": false, "editable": true @@ -3836,7 +2283,7 @@ }, { "cell_type": "markdown", - "id": "2e3e6a48", + "id": "e1909c0f", "metadata": { "editable": true }, @@ -3846,7 +2293,7 @@ }, { "cell_type": "markdown", - "id": "a0600f67", + "id": "b3b9b188", "metadata": { "editable": true }, @@ -3873,7 +2320,7 @@ }, { "cell_type": "markdown", - "id": "2e2db428", + "id": "3a7168e0", "metadata": { "editable": true }, @@ -3887,7 +2334,7 @@ }, { "cell_type": "markdown", - "id": "79bc94bf", + "id": "b0a223d2", "metadata": { "editable": true }, @@ -3904,7 +2351,7 @@ }, { "cell_type": "markdown", - "id": "8aae9608", + "id": "0fdac7ea", "metadata": { "editable": true }, @@ -3920,7 +2367,7 @@ }, { "cell_type": "markdown", - "id": "5d4d34df", + "id": "8d55e499", "metadata": { "editable": true }, @@ -3932,7 +2379,7 @@ }, { "cell_type": "markdown", - "id": "4789ccab", + "id": "5b17c7cf", "metadata": { "editable": true }, @@ -3950,7 +2397,7 @@ }, { "cell_type": "markdown", - "id": "f5bde685", + "id": "ebae7d02", "metadata": { "editable": true }, @@ -3971,7 +2418,7 @@ }, { "cell_type": "markdown", - "id": "4651cd07", + "id": "7616fec7", "metadata": { "editable": true }, @@ -3988,7 +2435,7 @@ }, { "cell_type": "markdown", - "id": "6254e156", + "id": "bd09d7f3", "metadata": { "editable": true }, @@ -4000,7 +2447,7 @@ }, { "cell_type": "markdown", - "id": "20333501", + "id": "cfdfa93e", "metadata": { "editable": true }, @@ -4011,7 +2458,7 @@ }, { "cell_type": "markdown", - "id": "813fe9a1", + "id": "30d21d85", "metadata": { "editable": true }, @@ -4028,7 +2475,7 @@ }, { "cell_type": "markdown", - "id": "ab52e1ed", + "id": "67dd2433", "metadata": { "editable": true }, @@ -4039,7 +2486,7 @@ }, { "cell_type": "markdown", - "id": "ad9ead42", + "id": "ea64e290", "metadata": { "editable": true }, @@ -4055,7 +2502,7 @@ }, { "cell_type": "markdown", - "id": "9d7307ee", + "id": "2d1100df", "metadata": { "editable": true }, @@ -4067,7 +2514,7 @@ }, { "cell_type": "markdown", - "id": "25cd1ecf", + "id": "17d0bc83", "metadata": { "editable": true }, @@ -4084,7 +2531,7 @@ }, { "cell_type": "markdown", - "id": "1628ddd6", + "id": "60b77787", "metadata": { "editable": true }, @@ -4096,7 +2543,7 @@ }, { "cell_type": "markdown", - "id": "6559be22", + "id": "1f0f808e", "metadata": { "editable": true }, @@ -4114,7 +2561,7 @@ }, { "cell_type": "markdown", - "id": "ad3489df", + "id": "7672566d", "metadata": { "editable": true }, @@ -4124,7 +2571,7 @@ }, { "cell_type": "markdown", - "id": "3baa5d51", + "id": "f6148b6d", "metadata": { "editable": true }, @@ -4136,7 +2583,7 @@ }, { "cell_type": "markdown", - "id": "6793951c", + "id": "8b47e354", "metadata": { "editable": true }, @@ -4153,7 +2600,7 @@ }, { "cell_type": "markdown", - "id": "029174ae", + "id": "60e92693", "metadata": { "editable": true }, @@ -4165,7 +2612,7 @@ }, { "cell_type": "markdown", - "id": "502a37dc", + "id": "30a51a78", "metadata": { "editable": true }, @@ -4176,7 +2623,7 @@ }, { "cell_type": "markdown", - "id": "86f46ea0", + "id": "5a70690e", "metadata": { "editable": true }, @@ -4188,7 +2635,7 @@ }, { "cell_type": "markdown", - "id": "3327e0e0", + "id": "b5500617", "metadata": { "editable": true }, @@ -4198,7 +2645,7 @@ }, { "cell_type": "markdown", - "id": "27d583c4", + "id": "b5620ab0", "metadata": { "editable": true }, @@ -4218,7 +2665,7 @@ }, { "cell_type": "markdown", - "id": "344a02b5", + "id": "12a1854b", "metadata": { "editable": true }, @@ -4235,7 +2682,7 @@ }, { "cell_type": "markdown", - "id": "2ba3f9de", + "id": "2cec4039", "metadata": { "editable": true }, @@ -4254,7 +2701,7 @@ }, { "cell_type": "markdown", - "id": "21fcac4a", + "id": "09c4d9c5", "metadata": { "editable": true }, @@ -4266,7 +2713,7 @@ }, { "cell_type": "markdown", - "id": "04a26245", + "id": "2600a336", "metadata": { "editable": true }, @@ -4276,7 +2723,7 @@ }, { "cell_type": "markdown", - "id": "bbe30d4d", + "id": "f4d5b46a", "metadata": { "editable": true }, @@ -4293,7 +2740,7 @@ }, { "cell_type": "markdown", - "id": "bf115ba7", + "id": "23180206", "metadata": { "editable": true }, @@ -4303,7 +2750,7 @@ }, { "cell_type": "markdown", - "id": "e07822af", + "id": "74730d77", "metadata": { "editable": true }, @@ -4319,7 +2766,7 @@ }, { "cell_type": "markdown", - "id": "0bd949a8", + "id": "b6ef3cb5", "metadata": { "editable": true }, @@ -4331,7 +2778,7 @@ }, { "cell_type": "markdown", - "id": "e682bd3f", + "id": "9cd49077", "metadata": { "editable": true }, @@ -4343,7 +2790,7 @@ }, { "cell_type": "markdown", - "id": "9a5d7cbb", + "id": "dce863d6", "metadata": { "editable": true }, @@ -4355,7 +2802,7 @@ }, { "cell_type": "markdown", - "id": "5005ba3b", + "id": "47a18e0b", "metadata": { "editable": true }, @@ -4365,7 +2812,7 @@ }, { "cell_type": "markdown", - "id": "a6c678bc", + "id": "726be424", "metadata": { "editable": true }, @@ -4377,7 +2824,7 @@ }, { "cell_type": "markdown", - "id": "5d9081a6", + "id": "0c9bf93e", "metadata": { "editable": true }, @@ -4394,7 +2841,7 @@ }, { "cell_type": "markdown", - "id": "d30b3296", + "id": "74c4ca01", "metadata": { "editable": true }, @@ -4404,7 +2851,7 @@ }, { "cell_type": "markdown", - "id": "ba7ad1dc", + "id": "8a043149", "metadata": { "editable": true }, @@ -4416,7 +2863,7 @@ }, { "cell_type": "markdown", - "id": "c5c85fae", + "id": "2ba13c5b", "metadata": { "editable": true }, @@ -4430,7 +2877,7 @@ }, { "cell_type": "markdown", - "id": "31455ab3", + "id": "aa9dbb9c", "metadata": { "editable": true }, @@ -4446,7 +2893,7 @@ }, { "cell_type": "markdown", - "id": "db892730", + "id": "24f5114f", "metadata": { "editable": true }, @@ -4458,7 +2905,7 @@ }, { "cell_type": "markdown", - "id": "77581ff5", + "id": "08733763", "metadata": { "editable": true }, @@ -4480,7 +2927,7 @@ }, { "cell_type": "markdown", - "id": "2066b3b8", + "id": "cf59ecfa", "metadata": { "editable": true }, @@ -4492,7 +2939,7 @@ }, { "cell_type": "markdown", - "id": "e5b2ec88", + "id": "cedbdb65", "metadata": { "editable": true }, @@ -4515,7 +2962,7 @@ }, { "cell_type": "markdown", - "id": "7e73e4d1", + "id": "7eabe8fa", "metadata": { "editable": true }, @@ -4531,7 +2978,7 @@ }, { "cell_type": "markdown", - "id": "6e75a17f", + "id": "3a26f5fa", "metadata": { "editable": true }, @@ -4543,7 +2990,7 @@ }, { "cell_type": "markdown", - "id": "508d5800", + "id": "e185ec9d", "metadata": { "editable": true }, @@ -4567,7 +3014,7 @@ }, { "cell_type": "markdown", - "id": "c2e068bb", + "id": "e940dec8", "metadata": { "editable": true }, @@ -4579,7 +3026,7 @@ }, { "cell_type": "markdown", - "id": "1c41a567", + "id": "18bede18", "metadata": { "editable": true }, @@ -4600,7 +3047,7 @@ }, { "cell_type": "markdown", - "id": "ee777fc2", + "id": "c45a3bda", "metadata": { "editable": true }, @@ -4612,7 +3059,7 @@ }, { "cell_type": "markdown", - "id": "4867702f", + "id": "53591954", "metadata": { "editable": true }, @@ -4631,7 +3078,7 @@ }, { "cell_type": "markdown", - "id": "e8b191a7", + "id": "0480113d", "metadata": { "editable": true }, @@ -4641,7 +3088,7 @@ }, { "cell_type": "markdown", - "id": "07edf9ef", + "id": "3ed45441", "metadata": { "editable": true }, @@ -4655,7 +3102,7 @@ }, { "cell_type": "markdown", - "id": "a44c683c", + "id": "b71fbab3", "metadata": { "editable": true }, @@ -4667,7 +3114,7 @@ }, { "cell_type": "markdown", - "id": "8e35cfd6", + "id": "f3a5de19", "metadata": { "editable": true }, @@ -4679,7 +3126,7 @@ }, { "cell_type": "markdown", - "id": "cad756d7", + "id": "f13cf97e", "metadata": { "editable": true }, @@ -4696,7 +3143,7 @@ }, { "cell_type": "markdown", - "id": "e89f3475", + "id": "e0dd9288", "metadata": { "editable": true }, @@ -4708,7 +3155,7 @@ }, { "cell_type": "markdown", - "id": "05770b4f", + "id": "455a7242", "metadata": { "editable": true }, @@ -4730,7 +3177,7 @@ }, { "cell_type": "markdown", - "id": "aba3f2e6", + "id": "42cf5d46", "metadata": { "editable": true }, @@ -4745,7 +3192,7 @@ }, { "cell_type": "markdown", - "id": "b9bfa280", + "id": "d5e3b554", "metadata": { "editable": true }, @@ -4755,8 +3202,8 @@ }, { "cell_type": "code", - "execution_count": 41, - "id": "4eebdf51", + "execution_count": 31, + "id": "0c3e3737", "metadata": { "collapsed": false, "editable": true @@ -4911,7 +3358,7 @@ }, { "cell_type": "markdown", - "id": "091cc419", + "id": "405313c5", "metadata": { "editable": true }, @@ -4925,8 +3372,8 @@ }, { "cell_type": "code", - "execution_count": 42, - "id": "665731ce", + "execution_count": 32, + "id": "6afd8ade", "metadata": { "collapsed": false, "editable": true @@ -5095,7 +3542,7 @@ }, { "cell_type": "markdown", - "id": "50bc17b7", + "id": "5751a242", "metadata": { "editable": true }, @@ -5108,7 +3555,7 @@ }, { "cell_type": "markdown", - "id": "340763a0", + "id": "6d1c21f9", "metadata": { "editable": true }, @@ -5125,7 +3572,7 @@ }, { "cell_type": "markdown", - "id": "26658651", + "id": "11c12b59", "metadata": { "editable": true }, @@ -5141,7 +3588,7 @@ }, { "cell_type": "markdown", - "id": "6abebf29", + "id": "38d3e5e2", "metadata": { "editable": true }, @@ -5154,7 +3601,7 @@ }, { "cell_type": "markdown", - "id": "a68128ae", + "id": "009b3e5f", "metadata": { "editable": true }, @@ -5171,7 +3618,7 @@ }, { "cell_type": "markdown", - "id": "b5000a32", + "id": "cca20977", "metadata": { "editable": true }, @@ -5183,7 +3630,7 @@ }, { "cell_type": "markdown", - "id": "306c6e46", + "id": "443a9c48", "metadata": { "editable": true }, @@ -5210,7 +3657,7 @@ }, { "cell_type": "markdown", - "id": "c7d0d8c3", + "id": "b8e68047", "metadata": { "editable": true }, @@ -5222,8 +3669,8 @@ }, { "cell_type": "code", - "execution_count": 43, - "id": "a2b6af75", + "execution_count": 33, + "id": "be900d51", "metadata": { "collapsed": false, "editable": true @@ -5402,7 +3849,7 @@ }, { "cell_type": "markdown", - "id": "78241a6c", + "id": "3683040a", "metadata": { "editable": true }, @@ -5422,7 +3869,7 @@ }, { "cell_type": "markdown", - "id": "e493bb17", + "id": "79e53a04", "metadata": { "editable": true }, @@ -5437,7 +3884,7 @@ }, { "cell_type": "markdown", - "id": "68995ee5", + "id": "48950bb1", "metadata": { "editable": true }, @@ -5451,7 +3898,7 @@ }, { "cell_type": "markdown", - "id": "f0e67441", + "id": "0e6fafd0", "metadata": { "editable": true }, @@ -5467,7 +3914,7 @@ }, { "cell_type": "markdown", - "id": "b0722fa9", + "id": "e1c87174", "metadata": { "editable": true }, @@ -5477,7 +3924,7 @@ }, { "cell_type": "markdown", - "id": "6376873b", + "id": "4fe0255f", "metadata": { "editable": true }, @@ -5499,7 +3946,7 @@ }, { "cell_type": "markdown", - "id": "57a0317c", + "id": "9537e9ef", "metadata": { "editable": true }, @@ -5512,8 +3959,8 @@ }, { "cell_type": "code", - "execution_count": 44, - "id": "d16f77f1", + "execution_count": 34, + "id": "cc9511ba", "metadata": { "collapsed": false, "editable": true @@ -5589,7 +4036,7 @@ }, { "cell_type": "markdown", - "id": "e704b947", + "id": "01b22037", "metadata": { "editable": true }, @@ -5601,7 +4048,7 @@ }, { "cell_type": "markdown", - "id": "1feb358d", + "id": "bc0da822", "metadata": { "editable": true }, @@ -5618,7 +4065,7 @@ }, { "cell_type": "markdown", - "id": "05027662", + "id": "e4ab7df8", "metadata": { "editable": true }, @@ -5630,7 +4077,7 @@ }, { "cell_type": "markdown", - "id": "96d6d6a0", + "id": "0f4d49b9", "metadata": { "editable": true }, @@ -5645,7 +4092,7 @@ }, { "cell_type": "markdown", - "id": "d4dfad8a", + "id": "f3570184", "metadata": { "editable": true }, @@ -5657,7 +4104,7 @@ }, { "cell_type": "markdown", - "id": "ffe7eb65", + "id": "1b905211", "metadata": { "editable": true }, @@ -5669,7 +4116,7 @@ }, { "cell_type": "markdown", - "id": "2e3acb6a", + "id": "789836cb", "metadata": { "editable": true }, @@ -5681,7 +4128,7 @@ }, { "cell_type": "markdown", - "id": "600af805", + "id": "0f363195", "metadata": { "editable": true }, @@ -5691,7 +4138,7 @@ }, { "cell_type": "markdown", - "id": "3a61de1c", + "id": "e1e7e2f5", "metadata": { "editable": true }, @@ -5708,7 +4155,7 @@ }, { "cell_type": "markdown", - "id": "6475eda5", + "id": "d1f651e2", "metadata": { "editable": true }, @@ -5720,7 +4167,7 @@ }, { "cell_type": "markdown", - "id": "4c506a87", + "id": "be94670f", "metadata": { "editable": true }, @@ -5732,7 +4179,7 @@ }, { "cell_type": "markdown", - "id": "24701ca8", + "id": "eca6785f", "metadata": { "editable": true }, @@ -5742,7 +4189,7 @@ }, { "cell_type": "markdown", - "id": "826b9055", + "id": "f68aa900", "metadata": { "editable": true }, @@ -5754,7 +4201,7 @@ }, { "cell_type": "markdown", - "id": "323573be", + "id": "e85f2435", "metadata": { "editable": true }, @@ -5764,8 +4211,8 @@ }, { "cell_type": "code", - "execution_count": 45, - "id": "4234c03b", + "execution_count": 35, + "id": "c0022a0a", "metadata": { "collapsed": false, "editable": true @@ -5930,7 +4377,7 @@ }, { "cell_type": "markdown", - "id": "5f7a90b0", + "id": "1ae49b85", "metadata": { "editable": true }, @@ -5952,7 +4399,7 @@ }, { "cell_type": "markdown", - "id": "532f1254", + "id": "f22aa870", "metadata": { "editable": true }, @@ -5969,7 +4416,7 @@ }, { "cell_type": "markdown", - "id": "ece44428", + "id": "12402f92", "metadata": { "editable": true }, @@ -5979,7 +4426,7 @@ }, { "cell_type": "markdown", - "id": "c34e3e05", + "id": "00b9799d", "metadata": { "editable": true }, @@ -5994,7 +4441,7 @@ }, { "cell_type": "markdown", - "id": "9186a55c", + "id": "63b91aa9", "metadata": { "editable": true }, @@ -6004,7 +4451,7 @@ }, { "cell_type": "markdown", - "id": "0644e2f2", + "id": "3e50772a", "metadata": { "editable": true }, @@ -6019,7 +4466,7 @@ }, { "cell_type": "markdown", - "id": "b3bdd092", + "id": "f9d74ee1", "metadata": { "editable": true }, @@ -6030,7 +4477,7 @@ }, { "cell_type": "markdown", - "id": "e1e12027", + "id": "9d885961", "metadata": { "editable": true }, @@ -6050,7 +4497,7 @@ }, { "cell_type": "markdown", - "id": "334ba808", + "id": "4bdb2a02", "metadata": { "editable": true }, @@ -6062,7 +4509,7 @@ }, { "cell_type": "markdown", - "id": "3e465af3", + "id": "c20b7d32", "metadata": { "editable": true }, @@ -6099,7 +4546,7 @@ }, { "cell_type": "markdown", - "id": "c854491a", + "id": "798502d3", "metadata": { "editable": true }, @@ -6109,7 +4556,7 @@ }, { "cell_type": "markdown", - "id": "6f5435eb", + "id": "ed43a985", "metadata": { "editable": true }, @@ -6121,8 +4568,8 @@ }, { "cell_type": "code", - "execution_count": 46, - "id": "aec3e689", + "execution_count": 36, + "id": "41414177", "metadata": { "collapsed": false, "editable": true @@ -6327,7 +4774,7 @@ }, { "cell_type": "markdown", - "id": "349c11e3", + "id": "b32f9258", "metadata": { "editable": true }, @@ -6344,7 +4791,7 @@ }, { "cell_type": "markdown", - "id": "d4adb530", + "id": "f211463a", "metadata": { "editable": true }, @@ -6361,7 +4808,7 @@ }, { "cell_type": "markdown", - "id": "8b9396bf", + "id": "2b4bd193", "metadata": { "editable": true }, @@ -6371,7 +4818,7 @@ }, { "cell_type": "markdown", - "id": "059b4467", + "id": "0ece9e81", "metadata": { "editable": true }, @@ -6386,7 +4833,7 @@ }, { "cell_type": "markdown", - "id": "5a7fcf9e", + "id": "e30e6123", "metadata": { "editable": true }, @@ -6400,7 +4847,7 @@ }, { "cell_type": "markdown", - "id": "df2d65c5", + "id": "01fabacb", "metadata": { "editable": true }, @@ -6413,7 +4860,7 @@ }, { "cell_type": "markdown", - "id": "ae173d6c", + "id": "c13d41fb", "metadata": { "editable": true }, @@ -6433,7 +4880,7 @@ }, { "cell_type": "markdown", - "id": "bdaf49ce", + "id": "eb96a414", "metadata": { "editable": true }, @@ -6445,7 +4892,7 @@ }, { "cell_type": "markdown", - "id": "8fc692b7", + "id": "f3bad2e3", "metadata": { "editable": true }, @@ -6457,7 +4904,7 @@ }, { "cell_type": "markdown", - "id": "3d9a8d27", + "id": "baf4acd6", "metadata": { "editable": true }, @@ -6469,7 +4916,7 @@ }, { "cell_type": "markdown", - "id": "8bb8693c", + "id": "32139235", "metadata": { "editable": true }, @@ -6479,7 +4926,7 @@ }, { "cell_type": "markdown", - "id": "8f12a71a", + "id": "dc2aa978", "metadata": { "editable": true }, @@ -6491,7 +4938,7 @@ }, { "cell_type": "markdown", - "id": "92c02c54", + "id": "1282e316", "metadata": { "editable": true }, @@ -6503,7 +4950,7 @@ }, { "cell_type": "markdown", - "id": "3574103a", + "id": "98dde5b2", "metadata": { "editable": true }, @@ -6515,7 +4962,7 @@ }, { "cell_type": "markdown", - "id": "0c5567ec", + "id": "d3e8bbe0", "metadata": { "editable": true }, @@ -6525,7 +4972,7 @@ }, { "cell_type": "markdown", - "id": "e239c04b", + "id": "8137a1b2", "metadata": { "editable": true }, @@ -6541,7 +4988,7 @@ }, { "cell_type": "markdown", - "id": "b32c6b70", + "id": "cbce36ed", "metadata": { "editable": true }, @@ -6551,7 +4998,7 @@ }, { "cell_type": "markdown", - "id": "dfb3bad0", + "id": "0a91d2c7", "metadata": { "editable": true }, @@ -6563,7 +5010,7 @@ }, { "cell_type": "markdown", - "id": "14519bf8", + "id": "df8b3382", "metadata": { "editable": true }, @@ -6580,7 +5027,7 @@ }, { "cell_type": "markdown", - "id": "a0882035", + "id": "1851cd76", "metadata": { "editable": true }, @@ -6590,7 +5037,7 @@ }, { "cell_type": "markdown", - "id": "bf1f5906", + "id": "a4246df0", "metadata": { "editable": true }, @@ -6606,7 +5053,7 @@ }, { "cell_type": "markdown", - "id": "61a16dd6", + "id": "cbecbbb8", "metadata": { "editable": true }, @@ -6620,7 +5067,7 @@ }, { "cell_type": "markdown", - "id": "99949d7b", + "id": "09484628", "metadata": { "editable": true }, @@ -6638,8 +5085,8 @@ }, { "cell_type": "code", - "execution_count": 47, - "id": "f9faf581", + "execution_count": 37, + "id": "dd51a62f", "metadata": { "collapsed": false, "editable": true @@ -6694,7 +5141,7 @@ }, { "cell_type": "markdown", - "id": "3cbeb7ac", + "id": "822af629", "metadata": { "editable": true }, @@ -6724,7 +5171,7 @@ }, { "cell_type": "markdown", - "id": "04a66fd1", + "id": "2c358905", "metadata": { "editable": true }, @@ -6752,8 +5199,8 @@ }, { "cell_type": "code", - "execution_count": 48, - "id": "83ad594f", + "execution_count": 38, + "id": "45c5e295", "metadata": { "collapsed": false, "editable": true @@ -6800,7 +5247,7 @@ }, { "cell_type": "markdown", - "id": "dbe6f74a", + "id": "4dd3869b", "metadata": { "editable": true }, @@ -6825,8 +5272,8 @@ }, { "cell_type": "code", - "execution_count": 49, - "id": "a29e5348", + "execution_count": 39, + "id": "7e2b77d3", "metadata": { "collapsed": false, "editable": true @@ -7060,7 +5507,7 @@ }, { "cell_type": "markdown", - "id": "f2171b20", + "id": "7bd8fcce", "metadata": { "editable": true }, @@ -7072,7 +5519,7 @@ }, { "cell_type": "markdown", - "id": "e2c87638", + "id": "fc2ee080", "metadata": { "editable": true }, @@ -7084,7 +5531,7 @@ }, { "cell_type": "markdown", - "id": "d8595812", + "id": "85ad3201", "metadata": { "editable": true }, @@ -7096,7 +5543,7 @@ }, { "cell_type": "markdown", - "id": "6969d557", + "id": "c1262c90", "metadata": { "editable": true }, @@ -7113,7 +5560,7 @@ }, { "cell_type": "markdown", - "id": "f39d16ef", + "id": "4bdfae8e", "metadata": { "editable": true }, @@ -7123,7 +5570,7 @@ }, { "cell_type": "markdown", - "id": "6c8e08dd", + "id": "35f806f3", "metadata": { "editable": true }, @@ -7135,7 +5582,7 @@ }, { "cell_type": "markdown", - "id": "699a4862", + "id": "5c0fa662", "metadata": { "editable": true }, @@ -7152,7 +5599,7 @@ }, { "cell_type": "markdown", - "id": "3e5b810b", + "id": "1ea04257", "metadata": { "editable": true }, @@ -7163,7 +5610,7 @@ }, { "cell_type": "markdown", - "id": "c3f9ac9b", + "id": "e55ce75f", "metadata": { "editable": true }, @@ -7183,7 +5630,7 @@ }, { "cell_type": "markdown", - "id": "56f7fba0", + "id": "43a96eca", "metadata": { "editable": true }, @@ -7193,7 +5640,7 @@ }, { "cell_type": "markdown", - "id": "2788d661", + "id": "3bdd1e79", "metadata": { "editable": true }, @@ -7219,7 +5666,7 @@ }, { "cell_type": "markdown", - "id": "2094e988", + "id": "5e607eee", "metadata": { "editable": true }, @@ -7235,7 +5682,7 @@ }, { "cell_type": "markdown", - "id": "aac9bb21", + "id": "aa448712", "metadata": { "editable": true }, @@ -7245,8 +5692,8 @@ }, { "cell_type": "code", - "execution_count": 50, - "id": "550bea3f", + "execution_count": 40, + "id": "e4e02379", "metadata": { "collapsed": false, "editable": true @@ -7477,7 +5924,7 @@ }, { "cell_type": "markdown", - "id": "80a6f6ef", + "id": "27428d8d", "metadata": { "editable": true }, diff --git a/doc/src/week43/Previousversions/exercisesweek43.do.txt b/doc/src/week43/Previousversions/exercisesweek43.do.txt new file mode 100644 index 000000000..105d59dd8 --- /dev/null +++ b/doc/src/week43/Previousversions/exercisesweek43.do.txt @@ -0,0 +1,1284 @@ +TITLE: Exercises weeks 43 and 44 +AUTHOR: October 23-27, 2023 +DATE: Deadline is Sunday November 5 at midnight + +You can hand in the exercises from week 43 and week 44 as one exercise and get a total score of two additional points. + +======= Overarching aims of the exercises weeks 43 and 44 ======= + +The aim of the exercises this week and next week is to get started with writing a neural network code +of relevance for project 2. + + +During week 41 we discussed three different types of gates, the +so-called XOR, the OR and the AND gates. In order to develop a code +for neural networks, it can be useful to set up a simpler system with +only two inputs and one output. This can make it easier to debug and +study the feed forward pass and the back propagation part. In the +exercise this and next week, we propose to study this system with just +one hidden layer and two hidden nodes. There is only one output node +and we can choose to use either a simple regression case (fitting a +line) or just a binary classification case with the cross-entropy as +cost function. + + +Their inputs and outputs can be +summarized using the following tables, first for the OR gate with +inputs $x_1$ and $x_2$ and outputs $y$: + +|---------------------| +| $x_1$ | $x_2$ | $y$ | +|---------------------| +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 1 | +|---------------------| + +!split +===== The AND and XOR Gates ===== + +The AND gate is defined as + +|---------------------| +| $x_1$ | $x_2$ | $y$ | +|---------------------| +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 1 | +|---------------------| + +And finally we have the XOR gate + +|---------------------| +| $x_1$ | $x_2$ | $y$ | +|---------------------| +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 0 | +|---------------------| + +!split +===== Representing the Data Sets ===== + +Our design matrix is defined by the input values $x_1$ and $x_2$. Since we have four possible outputs, our design matrix reads + +!bt +\bm{X}=\begin{bmatrix} 0 & 0 \\ + 0 & 1 \\ + 1 & 0 \\ + 1 & 1 \end{bmatrix}, +!et + +while the vector of outputs is $\bm{y}^T=[0,1,1,0]$ for the XOR gate, $\bm{y}^T=[0,0,0,1]$ for the AND gate and $\bm{y}^T=[0,1,1,1]$ for the OR gate. + + + +Your tasks here are + +o Set up the design matrix with the inputs as discussed above and a vector containing the output, the so-called targets. Note that the design matrix is the same for all gates. You need just to define different outputs. +o Construct a neural network with only one hidden layer and two hidden nodes using the Sigmoid function as activation function. +o Set up the output layer with only one output node and use again the Sigmoid function as activation function for the output. +o Initialize the weights and biases and perform a feed forward pass and compare the outputs with the targets. +o Set up the cost function (cross entropy for classification of binary cases). +o Calculate the gradients needed for the back propagation part. +o Use the gradients to train the network in the back propagation part. Think of using automatic differentiation. +o Train the network and study your results and compare with results obtained either with _scikit-learn_ or _TensorFlow_. + +Everything you develop here can be used directly into the code for the project. + + +!split +===== Setting up dimensionalities by hand ===== + +It can be useful to test the dimensionalities for the network. Let us assume we have performed an optimization for XOR gate and found that the weights for the hidden layer are given by +!bt +\bm{W_h}=\begin{bmatrix} 1 & 1 \\ + 1 & 1 \end{bmatrix}, +!et + +Multiplying $\bm{X}$ and $\bm{W}$ gives + +!bt +\bm{X}{W}_h=\begin{bmatrix} 0 & 0 \\ + 1 & 1 \\ + 1 & 1 \\ + 2 & 2 \end{bmatrix}, +!et +Assume also that the bias vector for the hidden layer is +!bt +\bm{b}_h=\begin{bmatrix} 0 \\ + -1\end{bmatrix}, +!et +Adding it gives us the input to the activation function of the hidden layer +!bt +\bm{z}_h=\bm{X}\bm{W}_h+\bm{b}_h=\begin{bmatrix} 0 & -1 \\ + 1 & 0 \\ + 1 & 0 \\ + 2 & 1 \end{bmatrix}, +!et + +Let us then assume that our activation function is the RELU function, which simply means that we take the max of $0$ and the elements of the input argument $\bm{z}_h$, that is we have +!bt +\bm{a}_h=\mathrm{RELU}(\bm{z}_h=\bm{X}\bm{W}_h+\bm{b}_h)=\begin{bmatrix} 0 & 0 \\ + 1 & 0 \\ + 1 & 0 \\ + 2 & 1 \end{bmatrix}, +!et +Assume also that the bias of the output layer is zero and that the weights of the output layer are +!bt +\bm{w}_o=\begin{bmatrix} 1 \\ + -2\end{bmatrix}, +!et +and multiplying with $\bm{a}_h$ gives the output +!bt +\bm{a}_o=\begin{bmatrix} 0 & 0 \\ + 1 & 0 \\ + 1 & 0 \\ + 2 & 1 \end{bmatrix}\begin{bmatrix} 1 \\ + -2\end{bmatrix}=\begin{bmatrix} 0 \\ 1 \\ 1 \\0\end{bmatrix}, +!et +the wanted result. Pay attention to the dimensionalities as well. + + +!split +===== Setting up the Neural Network ===== + +We define first our design matrix and the various output vectors for the different gates. + +!bc pycod +""" +Simple code that tests XOR, OR and AND gates with linear regression +""" + +# import necessary packages +import numpy as np +import matplotlib.pyplot as plt +from sklearn import datasets + +def sigmoid(x): + return 1/(1 + np.exp(-x)) + +def feed_forward(X): + # weighted sum of inputs to the hidden layer + z_h = np.matmul(X, hidden_weights) + hidden_bias + # activation in the hidden layer + a_h = sigmoid(z_h) + + # weighted sum of inputs to the output layer + z_o = np.matmul(a_h, output_weights) + output_bias + # softmax output + # axis 0 holds each input and axis 1 the probabilities of each category + probabilities = sigmoid(z_o) + return probabilities + + +# ensure the same random numbers appear every time +np.random.seed(0) + +# Design matrix +X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) + +# The XOR gate +yXOR = np.array( [ 0, 1 ,1, 0]) +# The OR gate +yOR = np.array( [ 0, 1 ,1, 1]) +# The AND gate +yAND = np.array( [ 0, 0 ,0, 1]) + +# Defining the neural network +n_inputs, n_features = X.shape +n_hidden_neurons = 2 +n_categories = 1 +n_features = 2 + +# we make the weights normally distributed using numpy.random.randn + +# weights and bias in the hidden layer +hidden_weights = np.random.randn(n_features, n_hidden_neurons) +hidden_bias = np.zeros(n_hidden_neurons) + 0.01 + +# weights and bias in the output layer +output_weights = np.random.randn(n_hidden_neurons, n_categories) +output_bias = np.zeros(n_categories) + 0.01 + +probabilities = feed_forward(X) +print(probabilities) + +!ec + +Not an impressive result, but this was our first forward pass with randomly assigned weights. Let us now add the full network with the back-propagation algorithm discussed above. + +!split +===== The Code using Scikit-Learn ===== + +!bc pycod +# import necessary packages +import numpy as np +import matplotlib.pyplot as plt +from sklearn.neural_network import MLPClassifier +from sklearn.metrics import accuracy_score +import seaborn as sns + +# ensure the same random numbers appear every time +np.random.seed(0) + +# Design matrix +X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) + +# The XOR gate +yXOR = np.array( [ 0, 1 ,1, 0]) +# The OR gate +yOR = np.array( [ 0, 1 ,1, 1]) +# The AND gate +yAND = np.array( [ 0, 0 ,0, 1]) + +# Defining the neural network +n_hidden_neurons = 2 + +eta_vals = np.logspace(-5, 1, 7) +lmbd_vals = np.logspace(-5, 1, 7) +# store models for later use +DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) +epochs = 100 + +for i, eta in enumerate(eta_vals): + for j, lmbd in enumerate(lmbd_vals): + dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic', + alpha=lmbd, learning_rate_init=eta, max_iter=epochs) + dnn.fit(X, yXOR) + DNN_scikit[i][j] = dnn + print("Learning rate = ", eta) + print("Lambda = ", lmbd) + print("Accuracy score on data set: ", dnn.score(X, yXOR)) + print() + +sns.set() +test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) +for i in range(len(eta_vals)): + for j in range(len(lmbd_vals)): + dnn = DNN_scikit[i][j] + test_pred = dnn.predict(X) + test_accuracy[i][j] = accuracy_score(yXOR, test_pred) + +fig, ax = plt.subplots(figsize = (10, 10)) +sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") +ax.set_title("Test Accuracy") +ax.set_ylabel("$\eta$") +ax.set_xlabel("$\lambda$") +plt.show() + +!ec + +!split +===== Building a neural network code ===== + +Here we present a flexible object oriented codebase +for a feed forward neural network, along with a demonstration of how +to use it. Before we get into the details of the neural network, we +will first present some implementations of various schedulers, cost +functions and activation functions that can be used together with the +neural network. + +The codes here were developed by Eric Reber and Gregor Kajda during spring 2023. + +=== Learning rate methods === + +The code below shows object oriented implementations of the Constant, +Momentum, Adagrad, AdagradMomentum, RMS prop and Adam schedulers. All +of the classes belong to the shared abstract Scheduler class, and +share the update_change() and reset() methods allowing for any of the +schedulers to be seamlessly used during the training stage, as will +later be shown in the fit() method of the neural +network. Update_change() only has one parameter, the gradient +($δ^l_ja^{l−1}_k$), and returns the change which will be subtracted +from the weights. The reset() function takes no parameters, and resets +the desired variables. For Constant and Momentum, reset does nothing. + + +!bc pycod +import autograd.numpy as np + +class Scheduler: + """ + Abstract class for Schedulers + """ + + def __init__(self, eta): + self.eta = eta + + # should be overwritten + def update_change(self, gradient): + raise NotImplementedError + + # overwritten if needed + def reset(self): + pass + + +class Constant(Scheduler): + def __init__(self, eta): + super().__init__(eta) + + def update_change(self, gradient): + return self.eta * gradient + + def reset(self): + pass + + +class Momentum(Scheduler): + def __init__(self, eta: float, momentum: float): + super().__init__(eta) + self.momentum = momentum + self.change = 0 + + def update_change(self, gradient): + self.change = self.momentum * self.change + self.eta * gradient + return self.change + + def reset(self): + pass + + +class Adagrad(Scheduler): + def __init__(self, eta): + super().__init__(eta) + self.G_t = None + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + if self.G_t is None: + self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) + + self.G_t += gradient @ gradient.T + + G_t_inverse = 1 / ( + delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) + ) + return self.eta * gradient * G_t_inverse + + def reset(self): + self.G_t = None + + +class AdagradMomentum(Scheduler): + def __init__(self, eta, momentum): + super().__init__(eta) + self.G_t = None + self.momentum = momentum + self.change = 0 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + if self.G_t is None: + self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) + + self.G_t += gradient @ gradient.T + + G_t_inverse = 1 / ( + delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) + ) + self.change = self.change * self.momentum + self.eta * gradient * G_t_inverse + return self.change + + def reset(self): + self.G_t = None + + +class RMS_prop(Scheduler): + def __init__(self, eta, rho): + super().__init__(eta) + self.rho = rho + self.second = 0.0 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + self.second = self.rho * self.second + (1 - self.rho) * gradient * gradient + return self.eta * gradient / (np.sqrt(self.second + delta)) + + def reset(self): + self.second = 0.0 + + +class Adam(Scheduler): + def __init__(self, eta, rho, rho2): + super().__init__(eta) + self.rho = rho + self.rho2 = rho2 + self.moment = 0 + self.second = 0 + self.n_epochs = 1 + + def update_change(self, gradient): + delta = 1e-8 # avoid division ny zero + + self.moment = self.rho * self.moment + (1 - self.rho) * gradient + self.second = self.rho2 * self.second + (1 - self.rho2) * gradient * gradient + + moment_corrected = self.moment / (1 - self.rho**self.n_epochs) + second_corrected = self.second / (1 - self.rho2**self.n_epochs) + + return self.eta * moment_corrected / (np.sqrt(second_corrected + delta)) + + def reset(self): + self.n_epochs += 1 + self.moment = 0 + self.second = 0 + +!ec + +=== Usage of the above learning rate schedulers === + +To initalize a scheduler, simply create the object and pass in the +necessary parameters such as the learning rate and the momentum as +shown below. As the Scheduler class is an abstract class it should not +called directly, and will raise an error upon usage. + +!bc pycod +momentum_scheduler = Momentum(eta=1e-3, momentum=0.9) +adam_scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) +!ec + +Here is a small example for how a segment of code using schedulers +could look. Switching out the schedulers is simple. + +!bc pycod +weights = np.ones((3,3)) +print(f"Before scheduler:\n{weights=}") + +epochs = 10 +for e in range(epochs): + gradient = np.random.rand(3, 3) + change = adam_scheduler.update_change(gradient) + weights = weights - change + adam_scheduler.reset() + +print(f"\nAfter scheduler:\n{weights=}") +!ec + + +=== Cost functions === + +Here we discuss cost functions that can be used when creating the +neural network. Every cost function takes the target vector as its +parameter, and returns a function valued only at $x$ such that it may +easily be differentiated. + + +!bc pycod +import autograd.numpy as np + +def CostOLS(target): + + def func(X): + return (1.0 / target.shape[0]) * np.sum((target - X) ** 2) + + return func + + +def CostLogReg(target): + + def func(X): + + return -(1.0 / target.shape[0]) * np.sum( + (target * np.log(X + 10e-10)) + ((1 - target) * np.log(1 - X + 10e-10)) + ) + + return func + + +def CostCrossEntropy(target): + + def func(X): + return -(1.0 / target.size) * np.sum(target * np.log(X + 10e-10)) + + return func +!ec + + +Below we give a short example of how these cost function may be used +to obtain results if you wish to test them out on your own using +AutoGrad's automatics differentiation. + +!bc pycod +from autograd import grad + +target = np.array([[1, 2, 3]]).T +a = np.array([[4, 5, 6]]).T + +cost_func = CostCrossEntropy +cost_func_derivative = grad(cost_func(target)) + +valued_at_a = cost_func_derivative(a) +print(f"Derivative of cost function {cost_func.__name__} valued at a:\n{valued_at_a}") +!ec + + +=== Activation functions === + +Finally, before we look at the neural network, we will look at the +activation functions which can be specified between the hidden layers +and as the output function. Each function can be valued for any given +vector or matrix X, and can be differentiated via derivate(). + +!bc pycod +import autograd.numpy as np +from autograd import elementwise_grad + +def identity(X): + return X + + +def sigmoid(X): + try: + return 1.0 / (1 + np.exp(-X)) + except FloatingPointError: + return np.where(X > np.zeros(X.shape), np.ones(X.shape), np.zeros(X.shape)) + + +def softmax(X): + X = X - np.max(X, axis=-1, keepdims=True) + delta = 10e-10 + return np.exp(X) / (np.sum(np.exp(X), axis=-1, keepdims=True) + delta) + + +def RELU(X): + return np.where(X > np.zeros(X.shape), X, np.zeros(X.shape)) + + +def LRELU(X): + delta = 10e-4 + return np.where(X > np.zeros(X.shape), X, delta * X) + + +def derivate(func): + if func.__name__ == "RELU": + + def func(X): + return np.where(X > 0, 1, 0) + + return func + + elif func.__name__ == "LRELU": + + def func(X): + delta = 10e-4 + return np.where(X > 0, 1, delta) + + return func + + else: + return elementwise_grad(func) +!ec + +Below follows a short demonstration of how to use an activation +function. The derivative of the activation function will be important +when calculating the output delta term during backpropagation. Note +that derivate() can also be used for cost functions for a more +generalized approach. + +!bc pycod +z = np.array([[4, 5, 6]]).T +print(f"Input to activation function:\n{z}") + +act_func = sigmoid +a = act_func(z) +print(f"\nOutput from {act_func.__name__} activation function:\n{a}") + +act_func_derivative = derivate(act_func) +valued_at_z = act_func_derivative(a) +print(f"\nDerivative of {act_func.__name__} activation function valued at z:\n{valued_at_z}") +!ec + +=== The Neural Network === + +Now that we have gotten a good understanding of the implementation of +some important components, we can take a look at an object oriented +implementation of a feed forward neural network. The feed forward +neural network has been implemented as a class named FFNN, which can +be initiated as a regressor or classifier dependant on the choice of +cost function. The FFNN can have any number of input nodes, hidden +layers with any amount of hidden nodes, and any amount of output nodes +meaning it can perform multiclass classification as well as binary +classification and regression problems. Although there is a lot of +code present, it makes for an easy to use and generalizeable interface +for creating many types of neural networks as will be demonstrated +below. + +!bc pycod +import math +import autograd.numpy as np +import sys +import warnings +from autograd import grad, elementwise_grad +from random import random, seed +from copy import deepcopy, copy +from typing import Tuple, Callable +from sklearn.utils import resample + +warnings.simplefilter("error") + + +class FFNN: + """ + Description: + ------------ + Feed Forward Neural Network with interface enabling flexible design of a + nerual networks architecture and the specification of activation function + in the hidden layers and output layer respectively. This model can be used + for both regression and classification problems, depending on the output function. + + Attributes: + ------------ + I dimensions (tuple[int]): A list of positive integers, which specifies the + number of nodes in each of the networks layers. The first integer in the array + defines the number of nodes in the input layer, the second integer defines number + of nodes in the first hidden layer and so on until the last number, which + specifies the number of nodes in the output layer. + II hidden_func (Callable): The activation function for the hidden layers + III output_func (Callable): The activation function for the output layer + IV cost_func (Callable): Our cost function + V seed (int): Sets random seed, makes results reproducible + """ + + def __init__( + self, + dimensions: tuple[int], + hidden_func: Callable = sigmoid, + output_func: Callable = lambda x: x, + cost_func: Callable = CostOLS, + seed: int = None, + ): + self.dimensions = dimensions + self.hidden_func = hidden_func + self.output_func = output_func + self.cost_func = cost_func + self.seed = seed + self.weights = list() + self.schedulers_weight = list() + self.schedulers_bias = list() + self.a_matrices = list() + self.z_matrices = list() + self.classification = None + + self.reset_weights() + self._set_classification() + + def fit( + self, + X: np.ndarray, + t: np.ndarray, + scheduler: Scheduler, + batches: int = 1, + epochs: int = 100, + lam: float = 0, + X_val: np.ndarray = None, + t_val: np.ndarray = None, + ): + """ + Description: + ------------ + This function performs the training the neural network by performing the feedforward and backpropagation + algorithm to update the networks weights. + + Parameters: + ------------ + I X (np.ndarray) : training data + II t (np.ndarray) : target data + III scheduler (Scheduler) : specified scheduler (algorithm for optimization of gradient descent) + IV scheduler_args (list[int]) : list of all arguments necessary for scheduler + + Optional Parameters: + ------------ + V batches (int) : number of batches the datasets are split into, default equal to 1 + VI epochs (int) : number of iterations used to train the network, default equal to 100 + VII lam (float) : regularization hyperparameter lambda + VIII X_val (np.ndarray) : validation set + IX t_val (np.ndarray) : validation target set + + Returns: + ------------ + I scores (dict) : A dictionary containing the performance metrics of the model. + The number of the metrics depends on the parameters passed to the fit-function. + + """ + + # setup + if self.seed is not None: + np.random.seed(self.seed) + + val_set = False + if X_val is not None and t_val is not None: + val_set = True + + # creating arrays for score metrics + train_errors = np.empty(epochs) + train_errors.fill(np.nan) + val_errors = np.empty(epochs) + val_errors.fill(np.nan) + + train_accs = np.empty(epochs) + train_accs.fill(np.nan) + val_accs = np.empty(epochs) + val_accs.fill(np.nan) + + self.schedulers_weight = list() + self.schedulers_bias = list() + + batch_size = X.shape[0] // batches + + X, t = resample(X, t) + + # this function returns a function valued only at X + cost_function_train = self.cost_func(t) + if val_set: + cost_function_val = self.cost_func(t_val) + + # create schedulers for each weight matrix + for i in range(len(self.weights)): + self.schedulers_weight.append(copy(scheduler)) + self.schedulers_bias.append(copy(scheduler)) + + print(f"{scheduler.__class__.__name__}: Eta={scheduler.eta}, Lambda={lam}") + + try: + for e in range(epochs): + for i in range(batches): + # allows for minibatch gradient descent + if i == batches - 1: + # If the for loop has reached the last batch, take all thats left + X_batch = X[i * batch_size :, :] + t_batch = t[i * batch_size :, :] + else: + X_batch = X[i * batch_size : (i + 1) * batch_size, :] + t_batch = t[i * batch_size : (i + 1) * batch_size, :] + + self._feedforward(X_batch) + self._backpropagate(X_batch, t_batch, lam) + + # reset schedulers for each epoch (some schedulers pass in this call) + for scheduler in self.schedulers_weight: + scheduler.reset() + + for scheduler in self.schedulers_bias: + scheduler.reset() + + # computing performance metrics + pred_train = self.predict(X) + train_error = cost_function_train(pred_train) + + train_errors[e] = train_error + if val_set: + + pred_val = self.predict(X_val) + val_error = cost_function_val(pred_val) + val_errors[e] = val_error + + if self.classification: + train_acc = self._accuracy(self.predict(X), t) + train_accs[e] = train_acc + if val_set: + val_acc = self._accuracy(pred_val, t_val) + val_accs[e] = val_acc + + # printing progress bar + progression = e / epochs + print_length = self._progress_bar( + progression, + train_error=train_errors[e], + train_acc=train_accs[e], + val_error=val_errors[e], + val_acc=val_accs[e], + ) + except KeyboardInterrupt: + # allows for stopping training at any point and seeing the result + pass + + # visualization of training progression (similiar to tensorflow progression bar) + sys.stdout.write("\r" + " " * print_length) + sys.stdout.flush() + self._progress_bar( + 1, + train_error=train_errors[e], + train_acc=train_accs[e], + val_error=val_errors[e], + val_acc=val_accs[e], + ) + sys.stdout.write("") + + # return performance metrics for the entire run + scores = dict() + + scores["train_errors"] = train_errors + + if val_set: + scores["val_errors"] = val_errors + + if self.classification: + scores["train_accs"] = train_accs + + if val_set: + scores["val_accs"] = val_accs + + return scores + + def predict(self, X: np.ndarray, *, threshold=0.5): + """ + Description: + ------------ + Performs prediction after training of the network has been finished. + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each + + Optional Parameters: + ------------ + II threshold (float) : sets minimal value for a prediction to be predicted as the positive class + in classification problems + + Returns: + ------------ + I z (np.ndarray): A prediction vector (row) for each row in our design matrix + This vector is thresholded if regression=False, meaning that classification results + in a vector of 1s and 0s, while regressions in an array of decimal numbers + + """ + + predict = self._feedforward(X) + + if self.classification: + return np.where(predict > threshold, 1, 0) + else: + return predict + + def reset_weights(self): + """ + Description: + ------------ + Resets/Reinitializes the weights in order to train the network for a new problem. + + """ + if self.seed is not None: + np.random.seed(self.seed) + + self.weights = list() + for i in range(len(self.dimensions) - 1): + weight_array = np.random.randn( + self.dimensions[i] + 1, self.dimensions[i + 1] + ) + weight_array[0, :] = np.random.randn(self.dimensions[i + 1]) * 0.01 + + self.weights.append(weight_array) + + def _feedforward(self, X: np.ndarray): + """ + Description: + ------------ + Calculates the activation of each layer starting at the input and ending at the output. + Each following activation is calculated from a weighted sum of each of the preceeding + activations (except in the case of the input layer). + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each + + Returns: + ------------ + I z (np.ndarray): A prediction vector (row) for each row in our design matrix + """ + + # reset matrices + self.a_matrices = list() + self.z_matrices = list() + + # if X is just a vector, make it into a matrix + if len(X.shape) == 1: + X = X.reshape((1, X.shape[0])) + + # Add a coloumn of zeros as the first coloumn of the design matrix, in order + # to add bias to our data + bias = np.ones((X.shape[0], 1)) * 0.01 + X = np.hstack([bias, X]) + + # a^0, the nodes in the input layer (one a^0 for each row in X - where the + # exponent indicates layer number). + a = X + self.a_matrices.append(a) + self.z_matrices.append(a) + + # The feed forward algorithm + for i in range(len(self.weights)): + if i < len(self.weights) - 1: + z = a @ self.weights[i] + self.z_matrices.append(z) + a = self.hidden_func(z) + # bias column again added to the data here + bias = np.ones((a.shape[0], 1)) * 0.01 + a = np.hstack([bias, a]) + self.a_matrices.append(a) + else: + try: + # a^L, the nodes in our output layers + z = a @ self.weights[i] + a = self.output_func(z) + self.a_matrices.append(a) + self.z_matrices.append(z) + except Exception as OverflowError: + print( + "OverflowError in fit() in FFNN\nHOW TO DEBUG ERROR: Consider lowering your learning rate or scheduler specific parameters such as momentum, or check if your input values need scaling" + ) + + # this will be a^L + return a + + def _backpropagate(self, X, t, lam): + """ + Description: + ------------ + Performs the backpropagation algorithm. In other words, this method + calculates the gradient of all the layers starting at the + output layer, and moving from right to left accumulates the gradient until + the input layer is reached. Each layers respective weights are updated while + the algorithm propagates backwards from the output layer (auto-differentation in reverse mode). + + Parameters: + ------------ + I X (np.ndarray): The design matrix, with n rows of p features each. + II t (np.ndarray): The target vector, with n rows of p targets. + III lam (float32): regularization parameter used to punish the weights in case of overfitting + + Returns: + ------------ + No return value. + + """ + out_derivative = derivate(self.output_func) + hidden_derivative = derivate(self.hidden_func) + + for i in range(len(self.weights) - 1, -1, -1): + # delta terms for output + if i == len(self.weights) - 1: + # for multi-class classification + if ( + self.output_func.__name__ == "softmax" + ): + delta_matrix = self.a_matrices[i + 1] - t + # for single class classification + else: + cost_func_derivative = grad(self.cost_func(t)) + delta_matrix = out_derivative( + self.z_matrices[i + 1] + ) * cost_func_derivative(self.a_matrices[i + 1]) + + # delta terms for hidden layer + else: + delta_matrix = ( + self.weights[i + 1][1:, :] @ delta_matrix.T + ).T * hidden_derivative(self.z_matrices[i + 1]) + + # calculate gradient + gradient_weights = self.a_matrices[i][:, 1:].T @ delta_matrix + gradient_bias = np.sum(delta_matrix, axis=0).reshape( + 1, delta_matrix.shape[1] + ) + + # regularization term + gradient_weights += self.weights[i][1:, :] * lam + + # use scheduler + update_matrix = np.vstack( + [ + self.schedulers_bias[i].update_change(gradient_bias), + self.schedulers_weight[i].update_change(gradient_weights), + ] + ) + + # update weights and bias + self.weights[i] -= update_matrix + + def _accuracy(self, prediction: np.ndarray, target: np.ndarray): + """ + Description: + ------------ + Calculates accuracy of given prediction to target + + Parameters: + ------------ + I prediction (np.ndarray): vector of predicitons output network + (1s and 0s in case of classification, and real numbers in case of regression) + II target (np.ndarray): vector of true values (What the network ideally should predict) + + Returns: + ------------ + A floating point number representing the percentage of correctly classified instances. + """ + assert prediction.size == target.size + return np.average((target == prediction)) + def _set_classification(self): + """ + Description: + ------------ + Decides if FFNN acts as classifier (True) og regressor (False), + sets self.classification during init() + """ + self.classification = False + if ( + self.cost_func.__name__ == "CostLogReg" + or self.cost_func.__name__ == "CostCrossEntropy" + ): + self.classification = True + + def _progress_bar(self, progression, **kwargs): + """ + Description: + ------------ + Displays progress of training + """ + print_length = 40 + num_equals = int(progression * print_length) + num_not = print_length - num_equals + arrow = ">" if num_equals > 0 else "" + bar = "[" + "=" * (num_equals - 1) + arrow + "-" * num_not + "]" + perc_print = self._format(progression * 100, decimals=5) + line = f" {bar} {perc_print}% " + + for key in kwargs: + if not np.isnan(kwargs[key]): + value = self._format(kwargs[key], decimals=4) + line += f"| {key}: {value} " + sys.stdout.write("\r" + line) + sys.stdout.flush() + return len(line) + + def _format(self, value, decimals=4): + """ + Description: + ------------ + Formats decimal numbers for progress bar + """ + if value > 0: + v = value + elif value < 0: + v = -10 * value + else: + v = 1 + n = 1 + math.floor(math.log10(v)) + if n >= decimals - 1: + return str(round(value)) + return f"{value:.{decimals-n-1}f}" +!ec + +Before we make a model, we will quickly generate a dataset we can use +for our linear regression problem as shown below + +!bc pycod +import autograd.numpy as np +from sklearn.model_selection import train_test_split + +def SkrankeFunction(x, y): + return np.ravel(0 + 1*x + 2*y + 3*x**2 + 4*x*y + 5*y**2) + +def create_X(x, y, n): + if len(x.shape) > 1: + x = np.ravel(x) + y = np.ravel(y) + + N = len(x) + l = int((n + 1) * (n + 2) / 2) # Number of elements in beta + X = np.ones((N, l)) + + for i in range(1, n + 1): + q = int((i) * (i + 1) / 2) + for k in range(i + 1): + X[:, q + k] = (x ** (i - k)) * (y**k) + + return X + +step=0.5 +x = np.arange(0, 1, step) +y = np.arange(0, 1, step) +x, y = np.meshgrid(x, y) +target = SkrankeFunction(x, y) +target = target.reshape(target.shape[0], 1) + +poly_degree=3 +X = create_X(x, y, poly_degree) + +X_train, X_test, t_train, t_test = train_test_split(X, target) + +!ec + +Now that we have our dataset ready for the regression, we can create +our regressor. Note that with the seed parameter, we can make sure our +results stay the same every time we run the neural network. For +inititialization, we simply specify the dimensions (we wish the amount +of input nodes to be equal to the datapoints, and the output to +predict one value). + + +!bc pycod +input_nodes = X_train.shape[1] +output_nodes = 1 + +linear_regression = FFNN((input_nodes, output_nodes), output_func=identity, cost_func=CostOLS, seed=2023) + +!ec + +We then fit our model with our training data using the scheduler of our choice. + +!bc pycod +linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Constant(eta=1e-3) +scores = linear_regression.fit(X_train, t_train, scheduler) + + +!ec + +Due to the progress bar we can see the MSE (train_error) throughout +the FFNN's training. Note that the fit() function has some optional +parameters with defualt arguments. For example, the regularization +hyperparameter can be left ignored if not needed, and equally the FFNN +will by default run for 100 epochs. These can easily be changed, such +as for example: + +!bc pycod +linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scores = linear_regression.fit(X_train, t_train, scheduler, lam=1e-4, epochs=1000) + +!ec + +We see that given more epochs to train on, the regressor reaches a lower MSE. + +Let us then switch to a binary classification. We use a binary +classification dataset, and follow a similar setup to the regression +case. + + + +!bc pycod +from sklearn.datasets import load_breast_cancer +from sklearn.preprocessing import MinMaxScaler + +wisconsin = load_breast_cancer() +X = wisconsin.data +target = wisconsin.target +target = target.reshape(target.shape[0], 1) + +X_train, X_val, t_train, t_val = train_test_split(X, target) + +scaler = MinMaxScaler() +scaler.fit(X_train) +X_train = scaler.transform(X_train) +X_val = scaler.transform(X_val) + + +!ec + +!bc pycod +input_nodes = X_train.shape[1] +output_nodes = 1 + +logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) + +!ec + +We will now make use of our validation data by passing it into our fit function as a keyword argument + +!bc pycod +logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) +scores = logistic_regression.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) + + +!ec + +Finally, we will create a neural network with 2 hidden layers with activation functions. +!bc pycod +input_nodes = X_train.shape[1] +hidden_nodes1 = 100 +hidden_nodes2 = 30 +output_nodes = 1 + +dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) + +neural_network = FFNN(dims, hidden_func=RELU, output_func=sigmoid, cost_func=CostLogReg, seed=2023) + + +!ec + +!bc pycod +neural_network.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) +scores = neural_network.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) + +!ec + +=== Multiclass classification === + +Finally, we will demonstrate the use case of multiclass classification +using our FFNN with the famous MNIST dataset, which contain images of +digits between the range of 0 to 9. + + +!bc pycod +from sklearn.datasets import load_digits + +def onehot(target: np.ndarray): + onehot = np.zeros((target.size, target.max() + 1)) + onehot[np.arange(target.size), target] = 1 + return onehot + +digits = load_digits() + +X = digits.data +target = digits.target +target = onehot(target) + +input_nodes = 64 +hidden_nodes1 = 100 +hidden_nodes2 = 30 +output_nodes = 10 + +dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) + +multiclass = FFNN(dims, hidden_func=LRELU, output_func=softmax, cost_func=CostCrossEntropy) + +multiclass.reset_weights() # reset weights such that previous runs or reruns don't affect the weights + +scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) +scores = multiclass.fit(X, target, scheduler, epochs=1000) + +!ec + + + +!split +===== Testing the XOR gate and other gates ===== + +Let us now use our code to test the XOR gate. + +!bc pycod +X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) + +# The XOR gate +yXOR = np.array( [[ 0], [1] ,[1], [0]]) + +input_nodes = X.shape[1] +output_nodes = 1 + +logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) +logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights +scheduler = Adam(eta=1e-1, rho=0.9, rho2=0.999) +scores = logistic_regression.fit(X, yXOR, scheduler, epochs=1000) +!ec +Not bad, but the results depend strongly on the learning reate. Try different learning rates. diff --git a/doc/src/week43/week43.do.txt b/doc/src/week43/week43.do.txt index 4fb97b4f8..da849bad6 100644 --- a/doc/src/week43/week43.do.txt +++ b/doc/src/week43/week43.do.txt @@ -25,35 +25,12 @@ DATE: October 20, 2025 -!split -===== Mathematics of deep learning ===== - -!bblock Two recent books online -o The Modern Mathematics of Deep Learning, by Julius Berner, Philipp Grohs, Gitta Kutyniok, Philipp Petersen at URL:"https://arxiv.org/abs/2105.04026", published as "Mathematical Aspects of Deep Learning, pp. 1-111. Cambridge University Press, 2022":"https://doi.org/10.1017/9781009025096.002" - -o Mathematical Introduction to Deep Learning: Methods, Implementations, and Theory, Arnulf Jentzen, Benno Kuckuck, Philippe von Wurstemberger at URL:"https://doi.org/10.48550/arXiv.2310.20360" -!eblock - - -!split -===== Reminder on books with hands-on material and codes ===== -!bblock -* Sebastian Rashcka et al, Machine learning with Scikit-Learn and PyTorch at URL:"https://sebastianraschka.com/blog/2022/ml-pytorch-book.html" -!eblock - - -!split -===== Reading recommendations ===== - -o Rashkca et al., chapter 11, jupyter-notebook sent separately, from GitHub site at URL:"https://github.com/rasbt/machine-learning-book". See also chapters 12 and 13 on using Pytorch to make a Neural network code. -o Goodfellow et al, chapter 6 and 7 contain most of the neural network background. - !split ===== Using Automatic differentiation ===== In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example URL:"https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola" in computing gradients for deep learning. For the documentation of Autograd and examples see the lectures slides from "week 39":"https://compphysics.github.io/MachineLearning/doc/pub/week39/html/week39.html" and the Autograd documentation at URL:"https://github.com/HIPS/autograd". +we will also study the usage of Autograd, see for example URL:"https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola" in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at URL:"https://github.com/HIPS/autograd" and the lecture slides from week 40, see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". !split @@ -67,12 +44,12 @@ o Slides 12-44 at URL:"http://cs231n.stanford.edu/slides/2017/cs231n_2017_lectur !split -===== Lecture Monday October 21 ===== +===== Lecture Monday October 20 ===== !split ===== Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations ===== -This is a reminder from where we ended last week. +This is a reminder from last week. !bblock The architecture (our model) o Set up your inputs and outputs (scalars, vectors, matrices or higher-order arrays) @@ -260,996 +237,6 @@ _For the output layer:_ -!split -===== Setting up a Multi-layer perceptron model for classification ===== - -We are now gong to develop an example based on the MNIST data -base. This is a classification problem and we need to use our -cross-entropy function we discussed in connection with logistic -regression. The cross-entropy defines our cost function for the -classificaton problems with neural networks. - -In binary classification with two classes $(0, 1)$ we define the -logistic/sigmoid function as the probability that a particular input -is in class $0$ or $1$. This is possible because the logistic -function takes any input from the real numbers and inputs a number -between 0 and 1, and can therefore be interpreted as a probability. It -also has other nice properties, such as a derivative that is simple to -calculate. - -For an input $\boldsymbol{a}$ from the hidden layer, the probability that the input $\boldsymbol{x}$ -is in class 0 or 1 is just. We let $\theta$ represent the unknown weights and biases to be adjusted by our equations). The variable $x$ -represents our activation values $z$. We have -!bt -\[ -P(y = 0 \mid \bm{x}, \bm{\theta}) = \frac{1}{1 + \exp{(- \bm{x}})} , -\] -!et -and -!bt -\[ -P(y = 1 \mid \bm{x}, \bm{\theta}) = 1 - P(y = 0 \mid \bm{x}, \bm{\theta}) , -\] -!et - -where $y \in \{0, 1\}$ and $\bm{\theta}$ represents the weights and biases -of our network. - - -!split -===== Defining the cost function ===== - -Our cost function is given as (see the Logistic regression lectures) -!bt -\[ -\mathcal{C}(\bm{\theta}) = - \ln P(\mathcal{D} \mid \bm{\theta}) = - \sum_{i=1}^n -y_i \ln[P(y_i = 0)] + (1 - y_i) \ln [1 - P(y_i = 0)] = \sum_{i=1}^n \mathcal{L}_i(\bm{\theta}) . -\] -!et - -This last equality means that we can interpret our *cost* function as a sum over the *loss* function -for each point in the dataset $\mathcal{L}_i(\bm{\theta})$. -The negative sign is just so that we can think about our algorithm as minimizing a positive number, rather -than maximizing a negative number. - -In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: - -$y = 5 \quad \rightarrow \quad \bm{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$ and - - -$y = 1 \quad \rightarrow \quad \bm{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$ - - -i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset (numbers from $0$ to $9$).. - -If $\bm{x}_i$ is the $i$-th input (image), $y_{ic}$ refers to the $c$-th component of the $i$-th -output vector $\bm{y}_i$. -The probability of $\bm{x}_i$ being in class $c$ will be given by the softmax function: - -!bt -\[ -P(y_{ic} = 1 \mid \bm{x}_i, \bm{\theta}) = \frac{\exp{((\bm{a}_i^{hidden})^T \bm{w}_c)}} -{\sum_{c'=0}^{C-1} \exp{((\bm{a}_i^{hidden})^T \bm{w}_{c'})}} , -\] -!et - -which reduces to the logistic function in the binary case. -The likelihood of this $C$-class classifier -is now given as: - -!bt -\[ -P(\mathcal{D} \mid \bm{\theta}) = \prod_{i=1}^n \prod_{c=0}^{C-1} [P(y_{ic} = 1)]^{y_{ic}} . -\] -!et -Again we take the negative log-likelihood to define our cost function: - -!bt -\[ -\mathcal{C}(\bm{\theta}) = - \log{P(\mathcal{D} \mid \bm{\theta})}. -\] -!et -See the logistic regression lectures for a full definition of the cost function. - -The back propagation equations need now only a small change, namely the definition of a new cost function. We are thus ready to use the same equations as before! - -!split -===== Example: binary classification problem ===== - -As an example of the above, relevant for project 2 as well, let us consider a binary class. As discussed in our logistic regression lectures, we defined a cost function in terms of the parameters $\beta$ as -!bt -\[ -\mathcal{C}(\bm{\beta}) = - \sum_{i=1}^n \left(y_i\log{p(y_i \vert x_i,\bm{\beta})}+(1-y_i)\log{1-p(y_i \vert x_i,\bm{\beta})}\right), -\] -!et -where we had defined the logistic (sigmoid) function -!bt -\[ -p(y_i =1\vert x_i,\bm{\beta})=\frac{\exp{(\beta_0+\beta_1 x_i)}}{1+\exp{(\beta_0+\beta_1 x_i)}}, -\] -!et -and -!bt -\[ -p(y_i =0\vert x_i,\bm{\beta})=1-p(y_i =1\vert x_i,\bm{\beta}). -\] -!et -The parameters $\bm{\beta}$ were defined using a minimization method like gradient descent or Newton-Raphson's method. - -Now we replace $x_i$ with the activation $z_i^l$ for a given layer $l$ and the outputs as $y_i=a_i^l=f(z_i^l)$, with $z_i^l$ now being a function of the weights $w_{ij}^l$ and biases $b_i^l$. -We have then -!bt -\[ -a_i^l = y_i = \frac{\exp{(z_i^l)}}{1+\exp{(z_i^l)}}, -\] -!et -with -!bt -\[ -z_i^l = \sum_{j}w_{ij}^l a_j^{l-1}+b_i^l, -\] -!et -where the superscript $l-1$ indicates that these are the outputs from layer $l-1$. -Our cost function at the final layer $l=L$ is now -!bt -\[ -\mathcal{C}(\bm{W}) = - \sum_{i=1}^n \left(t_i\log{a_i^L}+(1-t_i)\log{(1-a_i^L)}\right), -\] -!et -where we have defined the targets $t_i$. The derivatives of the cost function with respect to the output $a_i^L$ are then easily calculated and we get -!bt -\[ -\frac{\partial \mathcal{C}(\bm{W})}{\partial a_i^L} = \frac{a_i^L-t_i}{a_i^L(1-a_i^L)}. -\] -!et -In case we use another activation function than the logistic one, we need to evaluate other derivatives. - - -!split -===== The Softmax function ===== -In case we employ the more general case given by the Softmax equation, we need to evaluate the derivative of the activation function with respect to the activation $z_i^l$, that is we need -!bt -\[ -\frac{\partial f(z_i^l)}{\partial w_{jk}^l} = -\frac{\partial f(z_i^l)}{\partial z_j^l} \frac{\partial z_j^l}{\partial w_{jk}^l}= \frac{\partial f(z_i^l)}{\partial z_j^l}a_k^{l-1}. -\] -!et -For the Softmax function we have -!bt -\[ -f(z_i^l) = \frac{\exp{(z_i^l)}}{\sum_{m=1}^K\exp{(z_m^l)}}. -\] -!et -Its derivative with respect to $z_j^l$ gives -!bt -\[ -\frac{\partial f(z_i^l)}{\partial z_j^l}= f(z_i^l)\left(\delta_{ij}-f(z_j^l)\right), -\] -!et -which in case of the simply binary model reduces to having $i=j$. - -!split -===== Developing a code for doing neural networks with back propagation ===== - - -One can identify a set of key steps when using neural networks to solve supervised learning problems: - -o Collect and pre-process data -o Define model and architecture -o Choose cost function and optimizer -o Train the model -o Evaluate model performance on test data -o Adjust hyperparameters (if necessary, network architecture) - -!split -===== Collect and pre-process data ===== - -Here we will be using the MNIST dataset, which is readily available through the _scikit-learn_ -package. You may also find it for example "here":"http://yann.lecun.com/exdb/mnist/". -The *MNIST* (Modified National Institute of Standards and Technology) database is a large database -of handwritten digits that is commonly used for training various image processing systems. -The MNIST dataset consists of 70 000 images of size $28\times 28$ pixels, each labeled from 0 to 9. -The scikit-learn dataset we will use consists of a selection of 1797 images of size $8\times 8$ collected and processed from this database. - -To feed data into a feed-forward neural network we need to represent -the inputs as a design/feature matrix $X = (n_{inputs}, n_{features})$. Each -row represents an *input*, in this case a handwritten digit, and -each column represents a *feature*, in this case a pixel. The -correct answers, also known as *labels* or *targets* are -represented as a 1D array of integers -$Y = (n_{inputs}) = (5, 3, 1, 8,...)$. - -As an example, say we want to build a neural network using supervised learning to predict Body-Mass Index (BMI) from -measurements of height (in m) -and weight (in kg). If we have measurements of 5 people the design/feature matrix could be for example: - -$$ X = \begin{bmatrix} -1.85 & 81\\ -1.71 & 65\\ -1.95 & 103\\ -1.55 & 42\\ -1.63 & 56 -\end{bmatrix} ,$$ - -and the targets would be: - -$$ Y = (23.7, 22.2, 27.1, 17.5, 21.1) $$ - -Since each input image is a 2D matrix, we need to flatten the image -(i.e. "unravel" the 2D matrix into a 1D array) to turn the data into a -design/feature matrix. This means we lose all spatial information in the -image, such as locality and translational invariance. More complicated -architectures such as Convolutional Neural Networks can take advantage -of such information, and are most commonly applied when analyzing -images. - - -!bc pycod -# import necessary packages -import numpy as np -import matplotlib.pyplot as plt -from sklearn import datasets - - -# ensure the same random numbers appear every time -np.random.seed(0) - -# display images in notebook -%matplotlib inline -plt.rcParams['figure.figsize'] = (12,12) - - -# download MNIST dataset -digits = datasets.load_digits() - -# define inputs and labels -inputs = digits.images -labels = digits.target - -print("inputs = (n_inputs, pixel_width, pixel_height) = " + str(inputs.shape)) -print("labels = (n_inputs) = " + str(labels.shape)) - - -# flatten the image -# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64 -n_inputs = len(inputs) -inputs = inputs.reshape(n_inputs, -1) -print("X = (n_inputs, n_features) = " + str(inputs.shape)) - - -# choose some random images to display -indices = np.arange(n_inputs) -random_indices = np.random.choice(indices, size=5) - -for i, image in enumerate(digits.images[random_indices]): - plt.subplot(1, 5, i+1) - plt.axis('off') - plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest') - plt.title("Label: %d" % digits.target[random_indices[i]]) -plt.show() -!ec - -!split -===== Train and test datasets ===== - -Performing analysis before partitioning the dataset is a major error, that can lead to incorrect conclusions. - -We will reserve $80 \%$ of our dataset for training and $20 \%$ for testing. - -It is important that the train and test datasets are drawn randomly from our dataset, to ensure -no bias in the sampling. -Say you are taking measurements of weather data to predict the weather in the coming 5 days. -You don't want to train your model on measurements taken from the hours 00.00 to 12.00, and then test it on data -collected from 12.00 to 24.00. - - -!bc pycod -from sklearn.model_selection import train_test_split - -# one-liner from scikit-learn library -train_size = 0.8 -test_size = 1 - train_size -X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size, - test_size=test_size) - -# equivalently in numpy -def train_test_split_numpy(inputs, labels, train_size, test_size): - n_inputs = len(inputs) - inputs_shuffled = inputs.copy() - labels_shuffled = labels.copy() - - np.random.shuffle(inputs_shuffled) - np.random.shuffle(labels_shuffled) - - train_end = int(n_inputs*train_size) - X_train, X_test = inputs_shuffled[:train_end], inputs_shuffled[train_end:] - Y_train, Y_test = labels_shuffled[:train_end], labels_shuffled[train_end:] - - return X_train, X_test, Y_train, Y_test - -#X_train, X_test, Y_train, Y_test = train_test_split_numpy(inputs, labels, train_size, test_size) - -print("Number of training images: " + str(len(X_train))) -print("Number of test images: " + str(len(X_test))) -!ec - -!split -===== Define model and architecture ===== - -Our simple feed-forward neural network will consist of an *input* layer, a single *hidden* layer and an *output* layer. The activation $y$ of each neuron is a weighted sum of inputs, passed through an activation function. In case of the simple perceptron model we have - -$$ z = \sum_{i=1}^n w_i a_i ,$$ - -$$ y = f(z) ,$$ - -where $f$ is the activation function, $a_i$ represents input from neuron $i$ in the preceding layer -and $w_i$ is the weight to input $i$. -The activation of the neurons in the input layer is just the features (e.g. a pixel value). - -The simplest activation function for a neuron is the *Heaviside* function: - -$$ f(z) = -\begin{cases} -1, & z > 0\\ -0, & \text{otherwise} -\end{cases} -$$ - -A feed-forward neural network with this activation is known as a *perceptron*. -For a binary classifier (i.e. two classes, 0 or 1, dog or not-dog) we can also use this in our output layer. -This activation can be generalized to $k$ classes (using e.g. the *one-against-all* strategy), -and we call these architectures *multiclass perceptrons*. - -However, it is now common to use the terms Single Layer Perceptron (SLP) (1 hidden layer) and -Multilayer Perceptron (MLP) (2 or more hidden layers) to refer to feed-forward neural networks with any activation function. - -Typical choices for activation functions include the sigmoid function, hyperbolic tangent, and Rectified Linear Unit (ReLU). -We will be using the sigmoid function $\sigma(x)$: - -$$ f(x) = \sigma(x) = \frac{1}{1 + e^{-x}} ,$$ - -which is inspired by probability theory (see logistic regression) and was most commonly used until about 2011. See the discussion below concerning other activation functions. - -!split -===== Layers ===== - -* Input -Since each input image has 8x8 = 64 pixels or features, we have an input layer of 64 neurons. - -* Hidden layer -We will use 50 neurons in the hidden layer receiving input from the neurons in the input layer. -Since each neuron in the hidden layer is connected to the 64 inputs we have 64x50 = 3200 weights to the hidden layer. - -* Output -If we were building a binary classifier, it would be sufficient with a single neuron in the output layer, -which could output 0 or 1 according to the Heaviside function. This would be an example of a *hard* classifier, meaning it outputs the class of the input directly. However, if we are dealing with noisy data it is often beneficial to use a *soft* classifier, which outputs the probability of being in class 0 or 1. - -For a soft binary classifier, we could use a single neuron and interpret the output as either being the probability of being in class 0 or the probability of being in class 1. Alternatively we could use 2 neurons, and interpret each neuron as the probability of being in each class. - -Since we are doing multiclass classification, with 10 categories, it is natural to use 10 neurons in the output layer. We number the neurons $j = 0,1,...,9$. The activation of each output neuron $j$ will be according to the *softmax* function: - -$$ P(\text{class $j$} \mid \text{input $\bm{a}$}) = \frac{\exp{(\bm{a}^T \bm{w}_j)}} -{\sum_{c=0}^{9} \exp{(\bm{a}^T \bm{w}_c)}} ,$$ - -i.e. each neuron $j$ outputs the probability of being in class $j$ given an input from the hidden layer $\bm{a}$, with $\bm{w}_j$ the weights of neuron $j$ to the inputs. -The denominator is a normalization factor to ensure the outputs (probabilities) sum up to 1. -The exponent is just the weighted sum of inputs as before: - -$$ z_j = \sum_{i=1}^n w_ {ij} a_i+b_j.$$ - -Since each neuron in the output layer is connected to the 50 inputs from the hidden layer we have 50x10 = 500 -weights to the output layer. - -!split -===== Weights and biases ===== - -Typically weights are initialized with small values distributed around zero, drawn from a uniform -or normal distribution. Setting all weights to zero means all neurons give the same output, making the network useless. - -Adding a bias value to the weighted sum of inputs allows the neural network to represent a greater range -of values. Without it, any input with the value 0 will be mapped to zero (before being passed through the activation). The bias unit has an output of 1, and a weight to each neuron $j$, $b_j$: - -$$ z_j = \sum_{i=1}^n w_ {ij} a_i + b_j.$$ - -The bias weights $\bm{b}$ are often initialized to zero, but a small value like $0.01$ ensures all neurons have some output which can be backpropagated in the first training cycle. -!bc pycod -# building our neural network - -n_inputs, n_features = X_train.shape -n_hidden_neurons = 50 -n_categories = 10 - -# we make the weights normally distributed using numpy.random.randn - -# weights and bias in the hidden layer -hidden_weights = np.random.randn(n_features, n_hidden_neurons) -hidden_bias = np.zeros(n_hidden_neurons) + 0.01 - -# weights and bias in the output layer -output_weights = np.random.randn(n_hidden_neurons, n_categories) -output_bias = np.zeros(n_categories) + 0.01 -!ec - -!split -===== Feed-forward pass ===== - -Denote $F$ the number of features, $H$ the number of hidden neurons and $C$ the number of categories. -For each input image we calculate a weighted sum of input features (pixel values) to each neuron $j$ in the hidden layer $l$: - -$$ z_{j}^{l} = \sum_{i=1}^{F} w_{ij}^{l} x_i + b_{j}^{l},$$ - -this is then passed through our activation function - -$$ a_{j}^{l} = f(z_{j}^{l}) .$$ - -We calculate a weighted sum of inputs (activations in the hidden layer) to each neuron $j$ in the output layer: - -$$ z_{j}^{L} = \sum_{i=1}^{H} w_{ij}^{L} a_{i}^{l} + b_{j}^{L}.$$ - -Finally we calculate the output of neuron $j$ in the output layer using the softmax function: - -$$ a_{j}^{L} = \frac{\exp{(z_j^{L})}} -{\sum_{c=0}^{C-1} \exp{(z_c^{L})}} .$$ - -!split -===== Matrix multiplications ===== - -Since our data has the dimensions $X = (n_{inputs}, n_{features})$ and our weights to the hidden -layer have the dimensions -$W_{hidden} = (n_{features}, n_{hidden})$, -we can easily feed the network all our training data in one go by taking the matrix product - -$$ X W^{h} = (n_{inputs}, n_{hidden}),$$ - -and obtain a matrix that holds the weighted sum of inputs to the hidden layer -for each input image and each hidden neuron. -We also add the bias to obtain a matrix of weighted sums to the hidden layer $Z^{h}$: - -$$ \bm{z}^{l} = \bm{X} \bm{W}^{l} + \bm{b}^{l} ,$$ - -meaning the same bias (1D array with size equal number of hidden neurons) is added to each input image. -This is then passed through the activation: - -$$ \bm{a}^{l} = f(\bm{z}^l) .$$ - -This is fed to the output layer: - -$$ \bm{z}^{L} = \bm{a}^{L} \bm{W}^{L} + \bm{b}^{L} .$$ - -Finally we receive our output values for each image and each category by passing it through the softmax function: - -$$ output = softmax (\bm{z}^{L}) = (n_{inputs}, n_{categories}) .$$ - - -!bc pycod -# setup the feed-forward pass, subscript h = hidden layer - -def sigmoid(x): - return 1/(1 + np.exp(-x)) - -def feed_forward(X): - # weighted sum of inputs to the hidden layer - z_h = np.matmul(X, hidden_weights) + hidden_bias - # activation in the hidden layer - a_h = sigmoid(z_h) - - # weighted sum of inputs to the output layer - z_o = np.matmul(a_h, output_weights) + output_bias - # softmax output - # axis 0 holds each input and axis 1 the probabilities of each category - exp_term = np.exp(z_o) - probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) - - return probabilities - -probabilities = feed_forward(X_train) -print("probabilities = (n_inputs, n_categories) = " + str(probabilities.shape)) -print("probability that image 0 is in category 0,1,2,...,9 = \n" + str(probabilities[0])) -print("probabilities sum up to: " + str(probabilities[0].sum())) -print() - -# we obtain a prediction by taking the class with the highest likelihood -def predict(X): - probabilities = feed_forward(X) - return np.argmax(probabilities, axis=1) - -predictions = predict(X_train) -print("predictions = (n_inputs) = " + str(predictions.shape)) -print("prediction for image 0: " + str(predictions[0])) -print("correct label for image 0: " + str(Y_train[0])) -!ec - -!split -===== Choose cost function and optimizer ===== - -To measure how well our neural network is doing we need to introduce a cost function. -We will call the function that gives the error of a single sample output the *loss* function, and the function -that gives the total error of our network across all samples the *cost* function. -A typical choice for multiclass classification is the *cross-entropy* loss, also known as the negative log likelihood. - -In *multiclass* classification it is common to treat each integer label as a so called *one-hot* vector: - -$$ y = 5 \quad \rightarrow \quad \bm{y} = (0, 0, 0, 0, 0, 1, 0, 0, 0, 0) ,$$ - - -$$ y = 1 \quad \rightarrow \quad \bm{y} = (0, 1, 0, 0, 0, 0, 0, 0, 0, 0) ,$$ - - -i.e. a binary bit string of length $C$, where $C = 10$ is the number of classes in the MNIST dataset. - -Let $y_{ic}$ denote the $c$-th component of the $i$-th one-hot vector. -We define the cost function $\mathcal{C}$ as a sum over the cross-entropy loss for each point $\bm{x}_i$ in the dataset. - -In the one-hot representation only one of the terms in the loss function is non-zero, namely the -probability of the correct category $c'$ -(i.e. the category $c'$ such that $y_{ic'} = 1$). This means that the cross entropy loss only punishes you for how wrong -you got the correct label. The probability of category $c$ is given by the softmax function. The vector $\bm{\theta}$ represents the parameters of our network, i.e. all the weights and biases. - - -!split -===== Optimizing the cost function ===== - -The network is trained by finding the weights and biases that minimize the cost function. One of the most widely used classes of methods is *gradient descent* and its generalizations. The idea behind gradient descent -is simply to adjust the weights in the direction where the gradient of the cost function is large and negative. This ensures we flow toward a *local* minimum of the cost function. -Each parameter $\theta$ is iteratively adjusted according to the rule - -$$ \theta_{i+1} = \theta_i - \eta \nabla \mathcal{C}(\theta_i) ,$$ - -where $\eta$ is known as the *learning rate*, which controls how big a step we take towards the minimum. -This update can be repeated for any number of iterations, or until we are satisfied with the result. - -A simple and effective improvement is a variant called *Batch Gradient Descent*. -Instead of calculating the gradient on the whole dataset, we calculate an approximation of the gradient -on a subset of the data called a *minibatch*. -If there are $N$ data points and we have a minibatch size of $M$, the total number of batches -is $N/M$. -We denote each minibatch $B_k$, with $k = 1, 2,...,N/M$. The gradient then becomes: - -$$ \nabla \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \nabla \mathcal{L}_i(\theta) \quad \rightarrow \quad -\frac{1}{M} \sum_{i \in B_k} \nabla \mathcal{L}_i(\theta) ,$$ - -i.e. instead of averaging the loss over the entire dataset, we average over a minibatch. - -This has two important benefits: -o Introducing stochasticity decreases the chance that the algorithm becomes stuck in a local minima. -o It significantly speeds up the calculation, since we do not have to use the entire dataset to calculate the gradient. - -The various optmization methods, with codes and algorithms, are discussed in our lectures on "Gradient descent approaches":"https://compphysics.github.io/MachineLearning/doc/pub/Splines/html/Splines-bs.html". - -!split -===== Regularization ===== - -It is common to add an extra term to the cost function, proportional -to the size of the weights. This is equivalent to constraining the -size of the weights, so that they do not grow out of control. -Constraining the size of the weights means that the weights cannot -grow arbitrarily large to fit the training data, and in this way -reduces *overfitting*. - -We will measure the size of the weights using the so called *L2-norm*, meaning our cost function becomes: - -$$ \mathcal{C}(\theta) = \frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) \quad \rightarrow \quad -\frac{1}{N} \sum_{i=1}^N \mathcal{L}_i(\theta) + \lambda \lvert \lvert \bm{w} \rvert \rvert_2^2 -= \frac{1}{N} \sum_{i=1}^N \mathcal{L}(\theta) + \lambda \sum_{ij} w_{ij}^2,$$ - -i.e. we sum up all the weights squared. The factor $\lambda$ is known as a regularization parameter. - - -In order to train the model, we need to calculate the derivative of -the cost function with respect to every bias and weight in the -network. In total our network has $(64 + 1)\times 50=3250$ weights in -the hidden layer and $(50 + 1)\times 10=510$ weights to the output -layer ($+1$ for the bias), and the gradient must be calculated for -every parameter. We use the *backpropagation* algorithm discussed -above. This is a clever use of the chain rule that allows us to -calculate the gradient efficently. - - -!split -===== Matrix multiplication ===== - -To more efficently train our network these equations are implemented using matrix operations. -The error in the output layer is calculated simply as, with $\bm{t}$ being our targets, - -$$ \delta_L = \bm{t} - \bm{y} = (n_{inputs}, n_{categories}) .$$ - -The gradient for the output weights is calculated as - -$$ \nabla W_{L} = \bm{a}^T \delta_L = (n_{hidden}, n_{categories}) ,$$ - -where $\bm{a} = (n_{inputs}, n_{hidden})$. This simply means that we are summing up the gradients for each input. -Since we are going backwards we have to transpose the activation matrix. - -The gradient with respect to the output bias is then - -$$ \nabla \bm{b}_{L} = \sum_{i=1}^{n_{inputs}} \delta_L = (n_{categories}) .$$ - -The error in the hidden layer is - -$$ \Delta_h = \delta_L W_{L}^T \circ f'(z_{h}) = \delta_L W_{L}^T \circ a_{h} \circ (1 - a_{h}) = (n_{inputs}, n_{hidden}) ,$$ - -where $f'(a_{h})$ is the derivative of the activation in the hidden layer. The matrix products mean -that we are summing up the products for each neuron in the output layer. The symbol $\circ$ denotes -the *Hadamard product*, meaning element-wise multiplication. - -This again gives us the gradients in the hidden layer: - -$$ \nabla W_{h} = X^T \delta_h = (n_{features}, n_{hidden}) ,$$ - -$$ \nabla b_{h} = \sum_{i=1}^{n_{inputs}} \delta_h = (n_{hidden}) .$$ - - -!bc pycod -# to categorical turns our integer vector into a onehot representation -from sklearn.metrics import accuracy_score - -# one-hot in numpy -def to_categorical_numpy(integer_vector): - n_inputs = len(integer_vector) - n_categories = np.max(integer_vector) + 1 - onehot_vector = np.zeros((n_inputs, n_categories)) - onehot_vector[range(n_inputs), integer_vector] = 1 - - return onehot_vector - -#Y_train_onehot, Y_test_onehot = to_categorical(Y_train), to_categorical(Y_test) -Y_train_onehot, Y_test_onehot = to_categorical_numpy(Y_train), to_categorical_numpy(Y_test) - -def feed_forward_train(X): - # weighted sum of inputs to the hidden layer - z_h = np.matmul(X, hidden_weights) + hidden_bias - # activation in the hidden layer - a_h = sigmoid(z_h) - - # weighted sum of inputs to the output layer - z_o = np.matmul(a_h, output_weights) + output_bias - # softmax output - # axis 0 holds each input and axis 1 the probabilities of each category - exp_term = np.exp(z_o) - probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) - - # for backpropagation need activations in hidden and output layers - return a_h, probabilities - -def backpropagation(X, Y): - a_h, probabilities = feed_forward_train(X) - - # error in the output layer - error_output = probabilities - Y - # error in the hidden layer - error_hidden = np.matmul(error_output, output_weights.T) * a_h * (1 - a_h) - - # gradients for the output layer - output_weights_gradient = np.matmul(a_h.T, error_output) - output_bias_gradient = np.sum(error_output, axis=0) - - # gradient for the hidden layer - hidden_weights_gradient = np.matmul(X.T, error_hidden) - hidden_bias_gradient = np.sum(error_hidden, axis=0) - - return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient - -print("Old accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train))) - -eta = 0.01 -lmbd = 0.01 -for i in range(1000): - # calculate gradients - dWo, dBo, dWh, dBh = backpropagation(X_train, Y_train_onehot) - - # regularization term gradients - dWo += lmbd * output_weights - dWh += lmbd * hidden_weights - - # update weights and biases - output_weights -= eta * dWo - output_bias -= eta * dBo - hidden_weights -= eta * dWh - hidden_bias -= eta * dBh - -print("New accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train))) -!ec - -!split -===== Improving performance ===== - -As we can see the network does not seem to be learning at all. It seems to be just guessing the label for each image. -In order to obtain a network that does something useful, we will have to do a bit more work. - -The choice of *hyperparameters* such as learning rate and regularization parameter is hugely influential for the performance of the network. Typically a *grid-search* is performed, wherein we test different hyperparameters separated by orders of magnitude. For example we could test the learning rates $\eta = 10^{-6}, 10^{-5},...,10^{-1}$ with different regularization parameters $\lambda = 10^{-6},...,10^{-0}$. - -Next, we haven't implemented minibatching yet, which introduces stochasticity and is though to act as an important regularizer on the weights. We call a feed-forward + backward pass with a minibatch an *iteration*, and a full training period -going through the entire dataset ($n/M$ batches) an *epoch*. - -If this does not improve network performance, you may want to consider altering the network architecture, adding more neurons or hidden layers. -Andrew Ng goes through some of these considerations in this "video":"https://youtu.be/F1ka6a13S9I". You can find a summary of the video "here":"https://kevinzakka.github.io/2016/09/26/applying-deep-learning/". - -!split -===== Full object-oriented implementation ===== - -It is very natural to think of the network as an object, with specific instances of the network -being realizations of this object with different hyperparameters. An implementation using Python classes provides a clean structure and interface, and the full implementation of our neural network is given below. - - -!bc pycod -class NeuralNetwork: - def __init__( - self, - X_data, - Y_data, - n_hidden_neurons=50, - n_categories=10, - epochs=10, - batch_size=100, - eta=0.1, - lmbd=0.0): - - self.X_data_full = X_data - self.Y_data_full = Y_data - - self.n_inputs = X_data.shape[0] - self.n_features = X_data.shape[1] - self.n_hidden_neurons = n_hidden_neurons - self.n_categories = n_categories - - self.epochs = epochs - self.batch_size = batch_size - self.iterations = self.n_inputs // self.batch_size - self.eta = eta - self.lmbd = lmbd - - self.create_biases_and_weights() - - def create_biases_and_weights(self): - self.hidden_weights = np.random.randn(self.n_features, self.n_hidden_neurons) - self.hidden_bias = np.zeros(self.n_hidden_neurons) + 0.01 - - self.output_weights = np.random.randn(self.n_hidden_neurons, self.n_categories) - self.output_bias = np.zeros(self.n_categories) + 0.01 - - def feed_forward(self): - # feed-forward for training - self.z_h = np.matmul(self.X_data, self.hidden_weights) + self.hidden_bias - self.a_h = sigmoid(self.z_h) - - self.z_o = np.matmul(self.a_h, self.output_weights) + self.output_bias - - exp_term = np.exp(self.z_o) - self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) - - def feed_forward_out(self, X): - # feed-forward for output - z_h = np.matmul(X, self.hidden_weights) + self.hidden_bias - a_h = sigmoid(z_h) - - z_o = np.matmul(a_h, self.output_weights) + self.output_bias - - exp_term = np.exp(z_o) - probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True) - return probabilities - - def backpropagation(self): - error_output = self.probabilities - self.Y_data - error_hidden = np.matmul(error_output, self.output_weights.T) * self.a_h * (1 - self.a_h) - - self.output_weights_gradient = np.matmul(self.a_h.T, error_output) - self.output_bias_gradient = np.sum(error_output, axis=0) - - self.hidden_weights_gradient = np.matmul(self.X_data.T, error_hidden) - self.hidden_bias_gradient = np.sum(error_hidden, axis=0) - - if self.lmbd > 0.0: - self.output_weights_gradient += self.lmbd * self.output_weights - self.hidden_weights_gradient += self.lmbd * self.hidden_weights - - self.output_weights -= self.eta * self.output_weights_gradient - self.output_bias -= self.eta * self.output_bias_gradient - self.hidden_weights -= self.eta * self.hidden_weights_gradient - self.hidden_bias -= self.eta * self.hidden_bias_gradient - - def predict(self, X): - probabilities = self.feed_forward_out(X) - return np.argmax(probabilities, axis=1) - - def predict_probabilities(self, X): - probabilities = self.feed_forward_out(X) - return probabilities - - def train(self): - data_indices = np.arange(self.n_inputs) - - for i in range(self.epochs): - for j in range(self.iterations): - # pick datapoints with replacement - chosen_datapoints = np.random.choice( - data_indices, size=self.batch_size, replace=False - ) - - # minibatch training data - self.X_data = self.X_data_full[chosen_datapoints] - self.Y_data = self.Y_data_full[chosen_datapoints] - - self.feed_forward() - self.backpropagation() -!ec - -!split -===== Evaluate model performance on test data ===== - -To measure the performance of our network we evaluate how well it does it data it has never seen before, i.e. the test data. -We measure the performance of the network using the *accuracy* score. -The accuracy is as you would expect just the number of images correctly labeled divided by the total number of images. A perfect classifier will have an accuracy score of $1$. - -$$ \text{Accuracy} = \frac{\sum_{i=1}^n I(\tilde{y}_i = y_i)}{n} ,$$ - -where $I$ is the indicator function, $1$ if $\tilde{y}_i = y_i$ and $0$ otherwise. - - -!bc pycod -epochs = 100 -batch_size = 100 - -dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size, - n_hidden_neurons=n_hidden_neurons, n_categories=n_categories) -dnn.train() -test_predict = dnn.predict(X_test) - -# accuracy score from scikit library -print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict)) - -# equivalent in numpy -def accuracy_score_numpy(Y_test, Y_pred): - return np.sum(Y_test == Y_pred) / len(Y_test) - -#print("Accuracy score on test set: ", accuracy_score_numpy(Y_test, test_predict)) -!ec - -!split -===== Adjust hyperparameters ===== - -We now perform a grid search to find the optimal hyperparameters for the network. -Note that we are only using 1 layer with 50 neurons, and human performance is estimated to be around $98\%$ ($2\%$ error rate). - -!bc pycod -eta_vals = np.logspace(-5, 1, 7) -lmbd_vals = np.logspace(-5, 1, 7) -# store the models for later use -DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) - -# grid search -for i, eta in enumerate(eta_vals): - for j, lmbd in enumerate(lmbd_vals): - dnn = NeuralNetwork(X_train, Y_train_onehot, eta=eta, lmbd=lmbd, epochs=epochs, batch_size=batch_size, - n_hidden_neurons=n_hidden_neurons, n_categories=n_categories) - dnn.train() - - DNN_numpy[i][j] = dnn - - test_predict = dnn.predict(X_test) - - print("Learning rate = ", eta) - print("Lambda = ", lmbd) - print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict)) - print() -!ec - -!split -===== Visualization ===== - -!bc pycod -# visual representation of grid search -# uses seaborn heatmap, you can also do this with matplotlib imshow -import seaborn as sns - -sns.set() - -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) - -for i in range(len(eta_vals)): - for j in range(len(lmbd_vals)): - dnn = DNN_numpy[i][j] - - train_pred = dnn.predict(X_train) - test_pred = dnn.predict(X_test) - - train_accuracy[i][j] = accuracy_score(Y_train, train_pred) - test_accuracy[i][j] = accuracy_score(Y_test, test_pred) - - -fig, ax = plt.subplots(figsize = (10, 10)) -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") -ax.set_title("Training Accuracy") -ax.set_ylabel("$\eta$") -ax.set_xlabel("$\lambda$") -plt.show() - -fig, ax = plt.subplots(figsize = (10, 10)) -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") -ax.set_title("Test Accuracy") -ax.set_ylabel("$\eta$") -ax.set_xlabel("$\lambda$") -plt.show() -!ec - -!split -===== scikit-learn implementation ===== - -_scikit-learn_ focuses more -on traditional machine learning methods, such as regression, -clustering, decision trees, etc. As such, it has only two types of -neural networks: Multi Layer Perceptron outputting continuous values, -*MPLRegressor*, and Multi Layer Perceptron outputting labels, -*MLPClassifier*. We will see how simple it is to use these classes. - -_scikit-learn_ implements a few improvements from our neural network, -such as early stopping, a varying learning rate, different -optimization methods, etc. We would therefore expect a better -performance overall. - -!bc pycod -from sklearn.neural_network import MLPClassifier -# store models for later use -DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) - -for i, eta in enumerate(eta_vals): - for j, lmbd in enumerate(lmbd_vals): - dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic', - alpha=lmbd, learning_rate_init=eta, max_iter=epochs) - dnn.fit(X_train, Y_train) - - DNN_scikit[i][j] = dnn - - print("Learning rate = ", eta) - print("Lambda = ", lmbd) - print("Accuracy score on test set: ", dnn.score(X_test, Y_test)) - print() -!ec - - -!split -===== Visualization ===== -!bc pycod -# optional -# visual representation of grid search -# uses seaborn heatmap, could probably do this in matplotlib -import seaborn as sns - -sns.set() - -train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) - -for i in range(len(eta_vals)): - for j in range(len(lmbd_vals)): - dnn = DNN_scikit[i][j] - - train_pred = dnn.predict(X_train) - test_pred = dnn.predict(X_test) - - train_accuracy[i][j] = accuracy_score(Y_train, train_pred) - test_accuracy[i][j] = accuracy_score(Y_test, test_pred) - - -fig, ax = plt.subplots(figsize = (10, 10)) -sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis") -ax.set_title("Training Accuracy") -ax.set_ylabel("$\eta$") -ax.set_xlabel("$\lambda$") -plt.show() - -fig, ax = plt.subplots(figsize = (10, 10)) -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") -ax.set_title("Test Accuracy") -ax.set_ylabel("$\eta$") -ax.set_xlabel("$\lambda$") -plt.show() -!ec - - - - - @@ -1468,186 +455,148 @@ plt.show() !ec - !split -===== The Breast Cancer Data, now with Keras ===== +===== Using Pytorch with the full MNIST data set ===== !bc pycod +import torch +import torch.nn as nn +import torch.optim as optim +import torchvision +import torchvision.transforms as transforms -import tensorflow as tf -from tensorflow.keras.layers import Input -from tensorflow.keras.models import Sequential #This allows appending layers to existing models -from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer -from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop) -from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2) -from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function -import numpy as np -import matplotlib.pyplot as plt -import seaborn as sns -from sklearn.model_selection import train_test_split as splitter -from sklearn.datasets import load_breast_cancer -import pickle -import os +# Device configuration: use GPU if available +device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + +# MNIST dataset (downloads if not already present) +transform = transforms.Compose([ + transforms.ToTensor(), + transforms.Normalize((0.5,), (0.5,)) # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range) +]) +train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform) +test_dataset = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform) + +train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True) +test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False) -"""Load breast cancer dataset""" +class NeuralNet(nn.Module): + def __init__(self): + super(NeuralNet, self).__init__() + self.fc1 = nn.Linear(28*28, 100) # first hidden layer (784 -> 100) + self.fc2 = nn.Linear(100, 100) # second hidden layer (100 -> 100) + self.fc3 = nn.Linear(100, 10) # output layer (100 -> 10 classes) + def forward(self, x): + x = x.view(x.size(0), -1) # flatten images into vectors of size 784 + x = torch.relu(self.fc1(x)) # hidden layer 1 + ReLU activation + x = torch.relu(self.fc2(x)) # hidden layer 2 + ReLU activation + x = self.fc3(x) # output layer (logits for 10 classes) + return x -np.random.seed(0) #create same seed for random number every time - -cancer=load_breast_cancer() #Download breast cancer dataset - -inputs=cancer.data #Feature matrix of 569 rows (samples) and 30 columns (parameters) -outputs=cancer.target #Label array of 569 rows (0 for benign and 1 for malignant) -labels=cancer.feature_names[0:30] - -print('The content of the breast cancer dataset is:') #Print information about the datasets -print(labels) -print('-------------------------') -print("inputs = " + str(inputs.shape)) -print("outputs = " + str(outputs.shape)) -print("labels = "+ str(labels.shape)) - -x=inputs #Reassign the Feature and Label matrices to other variables -y=outputs - -#%% - -# Visualisation of dataset (for correlation analysis) - -plt.figure() -plt.scatter(x[:,0],x[:,2],s=40,c=y,cmap=plt.cm.Spectral) -plt.xlabel('Mean radius',fontweight='bold') -plt.ylabel('Mean perimeter',fontweight='bold') -plt.show() - -plt.figure() -plt.scatter(x[:,5],x[:,6],s=40,c=y, cmap=plt.cm.Spectral) -plt.xlabel('Mean compactness',fontweight='bold') -plt.ylabel('Mean concavity',fontweight='bold') -plt.show() +model = NeuralNet().to(device) -plt.figure() -plt.scatter(x[:,0],x[:,1],s=40,c=y,cmap=plt.cm.Spectral) -plt.xlabel('Mean radius',fontweight='bold') -plt.ylabel('Mean texture',fontweight='bold') -plt.show() +criterion = nn.CrossEntropyLoss() +optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4) -plt.figure() -plt.scatter(x[:,2],x[:,1],s=40,c=y,cmap=plt.cm.Spectral) -plt.xlabel('Mean perimeter',fontweight='bold') -plt.ylabel('Mean compactness',fontweight='bold') -plt.show() +num_epochs = 10 +for epoch in range(num_epochs): + model.train() # set model to training mode + running_loss = 0.0 + for images, labels in train_loader: + # Move data to device (GPU if available, else CPU) + images, labels = images.to(device), labels.to(device) + + optimizer.zero_grad() # reset gradients to zero + outputs = model(images) # forward pass: compute predictions + loss = criterion(outputs, labels) # compute cross-entropy loss + loss.backward() # backpropagate to compute gradients + optimizer.step() # update weights using SGD step + + running_loss += loss.item() + # Compute average loss over all batches in this epoch + avg_loss = running_loss / len(train_loader) + print(f"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}") + +#Evaluation on the Test Set -# Generate training and testing datasets -#Select features relevant to classification (texture,perimeter,compactness and symmetery) -#and add to input matrix +model.eval() # set model to evaluation mode +correct = 0 +total = 0 +with torch.no_grad(): # disable gradient calculation for evaluation + for images, labels in test_loader: + images, labels = images.to(device), labels.to(device) + outputs = model(images) + _, predicted = torch.max(outputs, dim=1) # class with highest score + total += labels.size(0) + correct += (predicted == labels).sum().item() -temp1=np.reshape(x[:,1],(len(x[:,1]),1)) -temp2=np.reshape(x[:,2],(len(x[:,2]),1)) -X=np.hstack((temp1,temp2)) -temp=np.reshape(x[:,5],(len(x[:,5]),1)) -X=np.hstack((X,temp)) -temp=np.reshape(x[:,8],(len(x[:,8]),1)) -X=np.hstack((X,temp)) - -X_train,X_test,y_train,y_test=splitter(X,y,test_size=0.1) #Split datasets into training and testing - -y_train=to_categorical(y_train) #Convert labels to categorical when using categorical cross entropy -y_test=to_categorical(y_test) - -del temp1,temp2,temp - -# %% - -# Define tunable parameters" - -eta=np.logspace(-3,-1,3) #Define vector of learning rates (parameter to SGD optimiser) -lamda=0.01 #Define hyperparameter -n_layers=2 #Define number of hidden layers in the model -n_neuron=np.logspace(0,3,4,dtype=int) #Define number of neurons per layer -epochs=100 #Number of reiterations over the input data -batch_size=100 #Number of samples per gradient update - -# %% - -"""Define function to return Deep Neural Network model""" - -def NN_model(inputsize,n_layers,n_neuron,eta,lamda): - model=Sequential() - for i in range(n_layers): #Run loop to add hidden layers to the model - if (i==0): #First layer requires input dimensions - model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda),input_dim=inputsize)) - else: #Subsequent layers are capable of automatic shape inferencing - model.add(Dense(n_neuron,activation='relu',kernel_regularizer=regularizers.l2(lamda))) - model.add(Dense(2,activation='softmax')) #2 outputs - ordered and disordered (softmax for prob) - sgd=optimizers.SGD(learning_rate=eta) - model.compile(loss='categorical_crossentropy',optimizer=sgd,metrics=['accuracy']) - return model - - -Train_accuracy=np.zeros((len(n_neuron),len(eta))) #Define matrices to store accuracy scores as a function -Test_accuracy=np.zeros((len(n_neuron),len(eta))) #of learning rate and number of hidden neurons for - -for i in range(len(n_neuron)): #run loops over hidden neurons and learning rates to calculate - for j in range(len(eta)): #accuracy scores - DNN_model=NN_model(X_train.shape[1],n_layers,n_neuron[i],eta[j],lamda) - DNN_model.fit(X_train,y_train,epochs=epochs,batch_size=batch_size,verbose=1) - Train_accuracy[i,j]=DNN_model.evaluate(X_train,y_train)[1] - Test_accuracy[i,j]=DNN_model.evaluate(X_test,y_test)[1] - - -def plot_data(x,y,data,title=None): - - # plot results - fontsize=16 - - - fig = plt.figure() - ax = fig.add_subplot(111) - cax = ax.matshow(data, interpolation='nearest', vmin=0, vmax=1) - - cbar=fig.colorbar(cax) - cbar.ax.set_ylabel('accuracy (%)',rotation=90,fontsize=fontsize) - cbar.set_ticks([0,.2,.4,0.6,0.8,1.0]) - cbar.set_ticklabels(['0%','20%','40%','60%','80%','100%']) - - # put text on matrix elements - for i, x_val in enumerate(np.arange(len(x))): - for j, y_val in enumerate(np.arange(len(y))): - c = "${0:.1f}\\%$".format( 100*data[j,i]) - ax.text(x_val, y_val, c, va='center', ha='center') - - # convert axis vaues to to string labels - x=[str(i) for i in x] - y=[str(i) for i in y] - - - ax.set_xticklabels(['']+x) - ax.set_yticklabels(['']+y) - - ax.set_xlabel('$\\mathrm{learning\\ rate}$',fontsize=fontsize) - ax.set_ylabel('$\\mathrm{hidden\\ neurons}$',fontsize=fontsize) - if title is not None: - ax.set_title(title) - - plt.tight_layout() - - plt.show() - -plot_data(eta,n_neuron,Train_accuracy, 'training') -plot_data(eta,n_neuron,Test_accuracy, 'testing') +accuracy = 100 * correct / total +print(f"Test Accuracy: {accuracy:.2f}%") !ec +!split +===== And a similar example using Tensorflow with Keras ===== +!bc pycod +import tensorflow as tf +from tensorflow import keras +from tensorflow.keras import layers, regularizers + +# Check for GPU (TensorFlow will use it automatically if available) +gpus = tf.config.list_physical_devices('GPU') +print(f"GPUs available: {gpus}") + +# 1) Load and preprocess MNIST +(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data() +# Normalize to [0, 1] +x_train = (x_train.astype("float32") / 255.0) +x_test = (x_test.astype("float32") / 255.0) + +# 2) Build the model: 784 -> 100 -> 100 -> 10 +l2_reg = 1e-4 # L2 regularization strength + +model = keras.Sequential([ + layers.Input(shape=(28, 28)), + layers.Flatten(), + layers.Dense(100, activation="relu", + kernel_regularizer=regularizers.l2(l2_reg)), + layers.Dense(100, activation="relu", + kernel_regularizer=regularizers.l2(l2_reg)), + layers.Dense(10, activation="softmax") # output probabilities for 10 classes +]) + +# 3) Compile with SGD + weight decay via L2 regularizers +model.compile( + optimizer=keras.optimizers.SGD(learning_rate=0.01), + loss="sparse_categorical_crossentropy", + metrics=["accuracy"], +) + +model.summary() + +# 4) Train +history = model.fit( + x_train, y_train, + epochs=10, + batch_size=64, + validation_split=0.1, # optional: monitor validation during training + verbose=1 +) + +# 5) Evaluate on test set +test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0) +print(f"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}") + +!ec !split -===== Building a neural network code ===== +===== Building our own neural network code ===== Here we present a flexible object oriented codebase for a feed forward neural network, along with a demonstration of how From 861e47b0b9cfc080142ce6d4c36732dd6b21b726 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 07:46:58 +0200 Subject: [PATCH 03/14] update week 43 --- doc/pub/week43/html/week43-bs.html | 24 +- doc/pub/week43/html/week43-reveal.html | 29 +- doc/pub/week43/html/week43-solarized.html | 24 +- doc/pub/week43/html/week43.html | 24 +- doc/pub/week43/ipynb/ipynb-week43-src.tar.gz | Bin 191 -> 192 bytes doc/pub/week43/ipynb/week43.ipynb | 507 ++++++++++--------- doc/src/week43/week43.do.txt | 16 +- 7 files changed, 310 insertions(+), 314 deletions(-) diff --git a/doc/pub/week43/html/week43-bs.html b/doc/pub/week43/html/week43-bs.html index a991e9bc4..4b7cb355e 100644 --- a/doc/pub/week43/html/week43-bs.html +++ b/doc/pub/week43/html/week43-bs.html @@ -396,13 +396,14 @@ MathJax.Hub.Config({
    - + +
    @@ -412,11 +413,10 @@ MathJax.Hub.Config({
    -
      -
    • Exercise on writing your own neural network code
    • -
    • The exercises this week will be continued next week as well
    • -
    • Discussion of project 2
    • -
    +
      +
    1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.
    2. +
    3. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems
    4. +
    @@ -425,7 +425,7 @@ MathJax.Hub.Config({

    Using Automatic differentiation

    In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 41, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.

    diff --git a/doc/pub/week43/html/week43-reveal.html b/doc/pub/week43/html/week43-reveal.html index 6d8a445b5..3db80b689 100644 --- a/doc/pub/week43/html/week43-reveal.html +++ b/doc/pub/week43/html/week43-reveal.html @@ -197,15 +197,14 @@ MathJax.Hub.Config({
    Material for the lecture on Monday October 20, 2025

    -

    + +
    @@ -214,14 +213,10 @@ MathJax.Hub.Config({
    Lab sessions on Tuesday and Wednesday

    -

      - -

    • Exercise on writing your own neural network code
    • - -

    • The exercises this week will be continued next week as well
    • - -

    • Discussion of project 2
    • -
    +
      +

    1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.
    2. +

    3. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems
    4. +
    @@ -229,7 +224,7 @@ MathJax.Hub.Config({

    Using Automatic differentiation

    In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 41, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.

    diff --git a/doc/pub/week43/html/week43-solarized.html b/doc/pub/week43/html/week43-solarized.html index aad94e9d9..27c79506b 100644 --- a/doc/pub/week43/html/week43-solarized.html +++ b/doc/pub/week43/html/week43-solarized.html @@ -317,13 +317,14 @@ MathJax.Hub.Config({
    Material for the lecture on Monday October 20, 2025

    -

    + +
    @@ -332,11 +333,10 @@ MathJax.Hub.Config({
    Lab sessions on Tuesday and Wednesday

    -

      -
    • Exercise on writing your own neural network code
    • -
    • The exercises this week will be continued next week as well
    • -
    • Discussion of project 2
    • -
    +
      +
    1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.
    2. +
    3. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems
    4. +
    @@ -344,7 +344,7 @@ MathJax.Hub.Config({

    Using Automatic differentiation

    In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 41, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.











    diff --git a/doc/pub/week43/html/week43.html b/doc/pub/week43/html/week43.html index a5349e8d7..6c0b7933d 100644 --- a/doc/pub/week43/html/week43.html +++ b/doc/pub/week43/html/week43.html @@ -394,13 +394,14 @@ MathJax.Hub.Config({
    Material for the lecture on Monday October 20, 2025

    -

    + +
    @@ -409,11 +410,10 @@ MathJax.Hub.Config({
    Lab sessions on Tuesday and Wednesday

    -

      -
    • Exercise on writing your own neural network code
    • -
    • The exercises this week will be continued next week as well
    • -
    • Discussion of project 2
    • -
    +
      +
    1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.
    2. +
    3. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems
    4. +
    @@ -421,7 +421,7 @@ MathJax.Hub.Config({

    Using Automatic differentiation

    In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 40, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html. +we will also study the usage of Autograd, see for example https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at https://github.com/HIPS/autograd and the lecture slides from week 41, see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.











    diff --git a/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz b/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz index 686438690424bb06d48ac0af9e4470ee1f5a06c8..0ff6ebee5ce4f589a382d7983b817b65259181d0 100644 GIT binary patch literal 192 zcmV;x06+g9iwFS1%=Ksh1MSbv3c@f92k@Qu6nTP?*>*b%?%+WX@dY~8xjNU*wnO*! z?gR9sco`z}cli?%LUPE~n_U*Uy9*YBhzX@IW}2`maW&VIIA#ztOc|jG!4+Uk7{LH= zxszTx>$n+CX{xhOR;YJ#!&q5<*fYNZ&-@d|N?O?Ndsk@%N;{EjUBgX?nvzJiy~?4` u!j3I4;@U|gfU6#OQAj7X;+L>B`eb-xqwv?yc%J8ZUwZ)duHRh%2mk;qq+5Uh literal 191 zcmV;w06_mAiwFQ*$@ORe1MSaC3c@fD2H>uHia9|^P13FfyKo_hc!88oZLCddlA^u6 zeSoeMH${YeF#LoJ!^|ODZ+2Pa?k-piAtYf8#!M4FC0WhyNgQ*CIY~KXY$zZx<&+0N zmRsqivrd>{m8LqQvZ&tm4Q*xlVa|LCJo8T+D`{c7?_H%8DD5!Ux`rEK&1fXsUgc0| twBr{Tymrzc2-Slq3hAU);u5w-pNwd16#n`c&+|O*YY$@IoWcMI003IdRp9^t diff --git a/doc/pub/week43/ipynb/week43.ipynb b/doc/pub/week43/ipynb/week43.ipynb index bcf841703..3e86d5cdb 100644 --- a/doc/pub/week43/ipynb/week43.ipynb +++ b/doc/pub/week43/ipynb/week43.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "b4262ce2", + "id": "8c52cd3b", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "9203032a", + "id": "846eee41", "metadata": { "editable": true }, @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "56b9fe61", + "id": "ff057bd5", "metadata": { "editable": true }, @@ -36,17 +36,20 @@ "\n", "**Material for the lecture on Monday October 20, 2025.**\n", "\n", - " * Building our own Feed-forward Neural Network with intro to Tensorflow\n", + "1. Reminder from last week, see lalso ecture notes from week 42 at as well as those from week 41, see see . \n", "\n", - " * Solving differential equations with Neural Networks\n", + "2. Building our own Feed-forward Neural Network.\n", + "\n", + "3. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13.. \n", + "\n", + "4. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well.\n", "\n", - "\n", - "" + "" ] }, { "cell_type": "markdown", - "id": "0b8b78a7", + "id": "8d1fd0b3", "metadata": { "editable": true }, @@ -54,16 +57,14 @@ "## Exercises and lab session week 43\n", "**Lab sessions on Tuesday and Wednesday.**\n", "\n", - " * Exercise on writing your own neural network code\n", + "1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.\n", "\n", - " * The exercises this week will be continued next week as well\n", - "\n", - " * Discussion of project 2" + "2. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems" ] }, { "cell_type": "markdown", - "id": "211ed9dd", + "id": "4990faa2", "metadata": { "editable": true }, @@ -71,12 +72,12 @@ "## Using Automatic differentiation\n", "\n", "In our discussions of ordinary differential equations and neural network codes\n", - "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at and the lecture slides from week 40, see ." + "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at and the lecture slides from week 41, see ." ] }, { "cell_type": "markdown", - "id": "22d4d145", + "id": "76cb0250", "metadata": { "editable": true }, @@ -93,7 +94,7 @@ }, { "cell_type": "markdown", - "id": "96f43859", + "id": "5bdfe8a0", "metadata": { "editable": true }, @@ -103,7 +104,7 @@ }, { "cell_type": "markdown", - "id": "a38b1a5e", + "id": "b78c27be", "metadata": { "editable": true }, @@ -130,7 +131,7 @@ }, { "cell_type": "markdown", - "id": "8e9e7f7a", + "id": "db515eac", "metadata": { "editable": true }, @@ -153,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "64ec6fe3", + "id": "0d9e2c6d", "metadata": { "editable": true }, @@ -165,7 +166,7 @@ }, { "cell_type": "markdown", - "id": "ce7deff8", + "id": "c54ddbb9", "metadata": { "editable": true }, @@ -177,7 +178,7 @@ }, { "cell_type": "markdown", - "id": "0794bf9c", + "id": "0a074eb8", "metadata": { "editable": true }, @@ -187,7 +188,7 @@ }, { "cell_type": "markdown", - "id": "966295a4", + "id": "2916e7ad", "metadata": { "editable": true }, @@ -199,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "1a24ff59", + "id": "fc87090a", "metadata": { "editable": true }, @@ -213,7 +214,7 @@ }, { "cell_type": "markdown", - "id": "0e7ea1ba", + "id": "0fab3976", "metadata": { "editable": true }, @@ -225,7 +226,7 @@ }, { "cell_type": "markdown", - "id": "bdefff6b", + "id": "506b036e", "metadata": { "editable": true }, @@ -237,7 +238,7 @@ }, { "cell_type": "markdown", - "id": "de1257ed", + "id": "7230ebb2", "metadata": { "editable": true }, @@ -247,7 +248,7 @@ }, { "cell_type": "markdown", - "id": "3c04f532", + "id": "24dcabf8", "metadata": { "editable": true }, @@ -259,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "59d21e46", + "id": "769b4b46", "metadata": { "editable": true }, @@ -271,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "22face27", + "id": "0eb6e407", "metadata": { "editable": true }, @@ -281,7 +282,7 @@ }, { "cell_type": "markdown", - "id": "1e72f57e", + "id": "dd2caf09", "metadata": { "editable": true }, @@ -293,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "a9ebc5c4", + "id": "3ca5122d", "metadata": { "editable": true }, @@ -305,7 +306,7 @@ }, { "cell_type": "markdown", - "id": "2ab07a4a", + "id": "0297fbd7", "metadata": { "editable": true }, @@ -328,7 +329,7 @@ }, { "cell_type": "markdown", - "id": "15174e2a", + "id": "093209ef", "metadata": { "editable": true }, @@ -340,7 +341,7 @@ }, { "cell_type": "markdown", - "id": "3e037a7e", + "id": "52cacfbe", "metadata": { "editable": true }, @@ -352,7 +353,7 @@ }, { "cell_type": "markdown", - "id": "854aa7cd", + "id": "3ac82bdf", "metadata": { "editable": true }, @@ -362,7 +363,7 @@ }, { "cell_type": "markdown", - "id": "3b300627", + "id": "e3f9be3c", "metadata": { "editable": true }, @@ -374,7 +375,7 @@ }, { "cell_type": "markdown", - "id": "60c47f86", + "id": "fdb953a2", "metadata": { "editable": true }, @@ -395,7 +396,7 @@ }, { "cell_type": "markdown", - "id": "de3db402", + "id": "0d8677dd", "metadata": { "editable": true }, @@ -409,7 +410,7 @@ }, { "cell_type": "markdown", - "id": "c9b3f789", + "id": "6d2d4dcc", "metadata": { "editable": true }, @@ -421,7 +422,7 @@ }, { "cell_type": "markdown", - "id": "9e6ba2c1", + "id": "e17fbd6e", "metadata": { "editable": true }, @@ -443,7 +444,7 @@ }, { "cell_type": "markdown", - "id": "a0ca6ce2", + "id": "4464d159", "metadata": { "editable": true }, @@ -465,7 +466,7 @@ }, { "cell_type": "markdown", - "id": "a29b38bc", + "id": "d7dacac8", "metadata": { "editable": true }, @@ -483,7 +484,7 @@ }, { "cell_type": "markdown", - "id": "f64479f0", + "id": "cb79f5a6", "metadata": { "editable": true }, @@ -518,7 +519,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "b27970e4", + "id": "44cf829e", "metadata": { "collapsed": false, "editable": true @@ -530,7 +531,7 @@ }, { "cell_type": "markdown", - "id": "9427cab2", + "id": "bdf6f4be", "metadata": { "editable": true }, @@ -542,7 +543,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "265a9d8e", + "id": "784ed3b7", "metadata": { "collapsed": false, "editable": true @@ -555,7 +556,7 @@ }, { "cell_type": "markdown", - "id": "d0362f60", + "id": "30a63e04", "metadata": { "editable": true }, @@ -566,7 +567,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "31150e3d", + "id": "5ecbf45a", "metadata": { "collapsed": false, "editable": true @@ -579,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "d3ea5b10", + "id": "4a0568e9", "metadata": { "editable": true }, @@ -594,7 +595,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "c9005b14", + "id": "9982df74", "metadata": { "collapsed": false, "editable": true @@ -606,7 +607,7 @@ }, { "cell_type": "markdown", - "id": "6fd9e28c", + "id": "b81f34fd", "metadata": { "editable": true }, @@ -618,7 +619,7 @@ }, { "cell_type": "markdown", - "id": "b2e58b9d", + "id": "cf68391d", "metadata": { "editable": true }, @@ -631,7 +632,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "6bcb2d1b", + "id": "2594d47b", "metadata": { "collapsed": false, "editable": true @@ -688,7 +689,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "33f9b277", + "id": "060f0b22", "metadata": { "collapsed": false, "editable": true @@ -717,7 +718,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "ef4311ca", + "id": "5491ac4f", "metadata": { "collapsed": false, "editable": true @@ -747,7 +748,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "263854b8", + "id": "905a1d27", "metadata": { "collapsed": false, "editable": true @@ -774,7 +775,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "b7d2c6cf", + "id": "491849b6", "metadata": { "collapsed": false, "editable": true @@ -816,7 +817,7 @@ }, { "cell_type": "markdown", - "id": "e3189e7e", + "id": "25bfc059", "metadata": { "editable": true }, @@ -827,7 +828,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "80b9b56f", + "id": "29c660b4", "metadata": { "collapsed": false, "editable": true @@ -914,7 +915,7 @@ }, { "cell_type": "markdown", - "id": "38da87d8", + "id": "50468253", "metadata": { "editable": true }, @@ -925,7 +926,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "ebe99aeb", + "id": "1e430607", "metadata": { "collapsed": false, "editable": true @@ -985,7 +986,7 @@ }, { "cell_type": "markdown", - "id": "d675799d", + "id": "44c02ba1", "metadata": { "editable": true }, @@ -1004,7 +1005,7 @@ }, { "cell_type": "markdown", - "id": "5f0f9d3f", + "id": "87c53214", "metadata": { "editable": true }, @@ -1026,7 +1027,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "d715d80c", + "id": "b36b4c64", "metadata": { "collapsed": false, "editable": true @@ -1167,7 +1168,7 @@ }, { "cell_type": "markdown", - "id": "c86a2a10", + "id": "166220ac", "metadata": { "editable": true }, @@ -1183,7 +1184,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "c04fe314", + "id": "6e3221f8", "metadata": { "collapsed": false, "editable": true @@ -1196,7 +1197,7 @@ }, { "cell_type": "markdown", - "id": "61a58ad8", + "id": "44e094bb", "metadata": { "editable": true }, @@ -1208,7 +1209,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "c0662f37", + "id": "e8e938bd", "metadata": { "collapsed": false, "editable": true @@ -1230,7 +1231,7 @@ }, { "cell_type": "markdown", - "id": "c61d427f", + "id": "7546f778", "metadata": { "editable": true }, @@ -1246,7 +1247,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "b9393ed7", + "id": "55250ea2", "metadata": { "collapsed": false, "editable": true @@ -1284,7 +1285,7 @@ }, { "cell_type": "markdown", - "id": "9b3e3442", + "id": "6651b1cc", "metadata": { "editable": true }, @@ -1297,7 +1298,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "df1450c3", + "id": "48d70de6", "metadata": { "collapsed": false, "editable": true @@ -1318,7 +1319,7 @@ }, { "cell_type": "markdown", - "id": "12464028", + "id": "1763139f", "metadata": { "editable": true }, @@ -1334,7 +1335,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "030eac01", + "id": "2cf6bda9", "metadata": { "collapsed": false, "editable": true @@ -1392,7 +1393,7 @@ }, { "cell_type": "markdown", - "id": "2e23398d", + "id": "9e48a5a2", "metadata": { "editable": true }, @@ -1407,7 +1408,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "dd8b1ca8", + "id": "12995853", "metadata": { "collapsed": false, "editable": true @@ -1428,7 +1429,7 @@ }, { "cell_type": "markdown", - "id": "5f3fee56", + "id": "63d3c5bd", "metadata": { "editable": true }, @@ -1452,7 +1453,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "a687948a", + "id": "7e0107d8", "metadata": { "collapsed": false, "editable": true @@ -1924,7 +1925,7 @@ }, { "cell_type": "markdown", - "id": "89b83980", + "id": "2bd145b9", "metadata": { "editable": true }, @@ -1936,7 +1937,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "ec072ec1", + "id": "c7f3d7ad", "metadata": { "collapsed": false, "editable": true @@ -1980,7 +1981,7 @@ }, { "cell_type": "markdown", - "id": "299eeff2", + "id": "312deebb", "metadata": { "editable": true }, @@ -1996,7 +1997,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "05c4af35", + "id": "9c4f1717", "metadata": { "collapsed": false, "editable": true @@ -2011,7 +2012,7 @@ }, { "cell_type": "markdown", - "id": "9731ba56", + "id": "825279d3", "metadata": { "editable": true }, @@ -2022,7 +2023,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "daa31bab", + "id": "e6133768", "metadata": { "collapsed": false, "editable": true @@ -2037,7 +2038,7 @@ }, { "cell_type": "markdown", - "id": "e59eb1cb", + "id": "d561f849", "metadata": { "editable": true }, @@ -2053,7 +2054,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "8045aaa7", + "id": "22a52980", "metadata": { "collapsed": false, "editable": true @@ -2067,7 +2068,7 @@ }, { "cell_type": "markdown", - "id": "f37f5dcc", + "id": "e0dba967", "metadata": { "editable": true }, @@ -2082,7 +2083,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "81db6939", + "id": "d05f8035", "metadata": { "collapsed": false, "editable": true @@ -2108,7 +2109,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "23e49982", + "id": "dc7b7fec", "metadata": { "collapsed": false, "editable": true @@ -2123,7 +2124,7 @@ }, { "cell_type": "markdown", - "id": "e6992d9e", + "id": "7bfd050a", "metadata": { "editable": true }, @@ -2134,7 +2135,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "48b68e30", + "id": "02b08ed6", "metadata": { "collapsed": false, "editable": true @@ -2149,7 +2150,7 @@ }, { "cell_type": "markdown", - "id": "e5c5b96b", + "id": "59b85b1b", "metadata": { "editable": true }, @@ -2160,7 +2161,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "8d367149", + "id": "eebfa498", "metadata": { "collapsed": false, "editable": true @@ -2180,7 +2181,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "f1672be3", + "id": "cabc2b09", "metadata": { "collapsed": false, "editable": true @@ -2195,7 +2196,7 @@ }, { "cell_type": "markdown", - "id": "b23af8f2", + "id": "37d5b7bb", "metadata": { "editable": true }, @@ -2210,7 +2211,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "71ee7dd0", + "id": "ffc6fca1", "metadata": { "collapsed": false, "editable": true @@ -2247,7 +2248,7 @@ }, { "cell_type": "markdown", - "id": "51fba00e", + "id": "cc530309", "metadata": { "editable": true }, @@ -2260,7 +2261,7 @@ { "cell_type": "code", "execution_count": 30, - "id": "db11c06a", + "id": "0d61131c", "metadata": { "collapsed": false, "editable": true @@ -2283,7 +2284,7 @@ }, { "cell_type": "markdown", - "id": "e1909c0f", + "id": "ce4ce787", "metadata": { "editable": true }, @@ -2293,7 +2294,7 @@ }, { "cell_type": "markdown", - "id": "b3b9b188", + "id": "e5d7a6ab", "metadata": { "editable": true }, @@ -2320,7 +2321,7 @@ }, { "cell_type": "markdown", - "id": "3a7168e0", + "id": "56b23083", "metadata": { "editable": true }, @@ -2334,7 +2335,7 @@ }, { "cell_type": "markdown", - "id": "b0a223d2", + "id": "3f9d87d4", "metadata": { "editable": true }, @@ -2351,7 +2352,7 @@ }, { "cell_type": "markdown", - "id": "0fdac7ea", + "id": "ff7d3133", "metadata": { "editable": true }, @@ -2367,7 +2368,7 @@ }, { "cell_type": "markdown", - "id": "8d55e499", + "id": "f387989d", "metadata": { "editable": true }, @@ -2379,7 +2380,7 @@ }, { "cell_type": "markdown", - "id": "5b17c7cf", + "id": "d15b7ed8", "metadata": { "editable": true }, @@ -2397,7 +2398,7 @@ }, { "cell_type": "markdown", - "id": "ebae7d02", + "id": "8b0ad0fb", "metadata": { "editable": true }, @@ -2418,7 +2419,7 @@ }, { "cell_type": "markdown", - "id": "7616fec7", + "id": "c33b7fca", "metadata": { "editable": true }, @@ -2435,7 +2436,7 @@ }, { "cell_type": "markdown", - "id": "bd09d7f3", + "id": "d88cb1c8", "metadata": { "editable": true }, @@ -2447,7 +2448,7 @@ }, { "cell_type": "markdown", - "id": "cfdfa93e", + "id": "13593649", "metadata": { "editable": true }, @@ -2458,7 +2459,7 @@ }, { "cell_type": "markdown", - "id": "30d21d85", + "id": "a5e615d0", "metadata": { "editable": true }, @@ -2475,7 +2476,7 @@ }, { "cell_type": "markdown", - "id": "67dd2433", + "id": "952778b9", "metadata": { "editable": true }, @@ -2486,7 +2487,7 @@ }, { "cell_type": "markdown", - "id": "ea64e290", + "id": "63c41a29", "metadata": { "editable": true }, @@ -2502,7 +2503,7 @@ }, { "cell_type": "markdown", - "id": "2d1100df", + "id": "95ebdbc4", "metadata": { "editable": true }, @@ -2514,7 +2515,7 @@ }, { "cell_type": "markdown", - "id": "17d0bc83", + "id": "48862a28", "metadata": { "editable": true }, @@ -2531,7 +2532,7 @@ }, { "cell_type": "markdown", - "id": "60b77787", + "id": "98174490", "metadata": { "editable": true }, @@ -2543,7 +2544,7 @@ }, { "cell_type": "markdown", - "id": "1f0f808e", + "id": "f3d8ced5", "metadata": { "editable": true }, @@ -2561,7 +2562,7 @@ }, { "cell_type": "markdown", - "id": "7672566d", + "id": "0cdbddeb", "metadata": { "editable": true }, @@ -2571,7 +2572,7 @@ }, { "cell_type": "markdown", - "id": "f6148b6d", + "id": "8afed5da", "metadata": { "editable": true }, @@ -2583,7 +2584,7 @@ }, { "cell_type": "markdown", - "id": "8b47e354", + "id": "b6cdd16d", "metadata": { "editable": true }, @@ -2600,7 +2601,7 @@ }, { "cell_type": "markdown", - "id": "60e92693", + "id": "9423bac1", "metadata": { "editable": true }, @@ -2612,7 +2613,7 @@ }, { "cell_type": "markdown", - "id": "30a51a78", + "id": "e3ddd331", "metadata": { "editable": true }, @@ -2623,7 +2624,7 @@ }, { "cell_type": "markdown", - "id": "5a70690e", + "id": "41278f19", "metadata": { "editable": true }, @@ -2635,7 +2636,7 @@ }, { "cell_type": "markdown", - "id": "b5500617", + "id": "8d0ce198", "metadata": { "editable": true }, @@ -2645,7 +2646,7 @@ }, { "cell_type": "markdown", - "id": "b5620ab0", + "id": "dc70817c", "metadata": { "editable": true }, @@ -2665,7 +2666,7 @@ }, { "cell_type": "markdown", - "id": "12a1854b", + "id": "8c2e8dde", "metadata": { "editable": true }, @@ -2682,7 +2683,7 @@ }, { "cell_type": "markdown", - "id": "2cec4039", + "id": "5ad2bff5", "metadata": { "editable": true }, @@ -2701,7 +2702,7 @@ }, { "cell_type": "markdown", - "id": "09c4d9c5", + "id": "5f845ba6", "metadata": { "editable": true }, @@ -2713,7 +2714,7 @@ }, { "cell_type": "markdown", - "id": "2600a336", + "id": "2604055d", "metadata": { "editable": true }, @@ -2723,7 +2724,7 @@ }, { "cell_type": "markdown", - "id": "f4d5b46a", + "id": "b4ba9669", "metadata": { "editable": true }, @@ -2740,7 +2741,7 @@ }, { "cell_type": "markdown", - "id": "23180206", + "id": "875686e8", "metadata": { "editable": true }, @@ -2750,7 +2751,7 @@ }, { "cell_type": "markdown", - "id": "74730d77", + "id": "ee9f7d57", "metadata": { "editable": true }, @@ -2766,7 +2767,7 @@ }, { "cell_type": "markdown", - "id": "b6ef3cb5", + "id": "1e370697", "metadata": { "editable": true }, @@ -2778,7 +2779,7 @@ }, { "cell_type": "markdown", - "id": "9cd49077", + "id": "833f3b82", "metadata": { "editable": true }, @@ -2790,7 +2791,7 @@ }, { "cell_type": "markdown", - "id": "dce863d6", + "id": "35da5498", "metadata": { "editable": true }, @@ -2802,7 +2803,7 @@ }, { "cell_type": "markdown", - "id": "47a18e0b", + "id": "b44a64f2", "metadata": { "editable": true }, @@ -2812,7 +2813,7 @@ }, { "cell_type": "markdown", - "id": "726be424", + "id": "116b1937", "metadata": { "editable": true }, @@ -2824,7 +2825,7 @@ }, { "cell_type": "markdown", - "id": "0c9bf93e", + "id": "9ef6d929", "metadata": { "editable": true }, @@ -2841,7 +2842,7 @@ }, { "cell_type": "markdown", - "id": "74c4ca01", + "id": "bd901882", "metadata": { "editable": true }, @@ -2851,7 +2852,7 @@ }, { "cell_type": "markdown", - "id": "8a043149", + "id": "31348d62", "metadata": { "editable": true }, @@ -2863,7 +2864,7 @@ }, { "cell_type": "markdown", - "id": "2ba13c5b", + "id": "ae4a794d", "metadata": { "editable": true }, @@ -2877,7 +2878,7 @@ }, { "cell_type": "markdown", - "id": "aa9dbb9c", + "id": "a4ca4b65", "metadata": { "editable": true }, @@ -2893,7 +2894,7 @@ }, { "cell_type": "markdown", - "id": "24f5114f", + "id": "6cd19213", "metadata": { "editable": true }, @@ -2905,7 +2906,7 @@ }, { "cell_type": "markdown", - "id": "08733763", + "id": "e6d9fb88", "metadata": { "editable": true }, @@ -2927,7 +2928,7 @@ }, { "cell_type": "markdown", - "id": "cf59ecfa", + "id": "2b7229da", "metadata": { "editable": true }, @@ -2939,7 +2940,7 @@ }, { "cell_type": "markdown", - "id": "cedbdb65", + "id": "cd4f193b", "metadata": { "editable": true }, @@ -2962,7 +2963,7 @@ }, { "cell_type": "markdown", - "id": "7eabe8fa", + "id": "e475f927", "metadata": { "editable": true }, @@ -2978,7 +2979,7 @@ }, { "cell_type": "markdown", - "id": "3a26f5fa", + "id": "95a91bdd", "metadata": { "editable": true }, @@ -2990,7 +2991,7 @@ }, { "cell_type": "markdown", - "id": "e185ec9d", + "id": "56c75c71", "metadata": { "editable": true }, @@ -3014,7 +3015,7 @@ }, { "cell_type": "markdown", - "id": "e940dec8", + "id": "0cc6d1a9", "metadata": { "editable": true }, @@ -3026,7 +3027,7 @@ }, { "cell_type": "markdown", - "id": "18bede18", + "id": "0175da6a", "metadata": { "editable": true }, @@ -3047,7 +3048,7 @@ }, { "cell_type": "markdown", - "id": "c45a3bda", + "id": "5fe7bc0e", "metadata": { "editable": true }, @@ -3059,7 +3060,7 @@ }, { "cell_type": "markdown", - "id": "53591954", + "id": "7f0577a4", "metadata": { "editable": true }, @@ -3078,7 +3079,7 @@ }, { "cell_type": "markdown", - "id": "0480113d", + "id": "11c8c142", "metadata": { "editable": true }, @@ -3088,7 +3089,7 @@ }, { "cell_type": "markdown", - "id": "3ed45441", + "id": "01ca4d08", "metadata": { "editable": true }, @@ -3102,7 +3103,7 @@ }, { "cell_type": "markdown", - "id": "b71fbab3", + "id": "f5133d80", "metadata": { "editable": true }, @@ -3114,7 +3115,7 @@ }, { "cell_type": "markdown", - "id": "f3a5de19", + "id": "c1e40110", "metadata": { "editable": true }, @@ -3126,7 +3127,7 @@ }, { "cell_type": "markdown", - "id": "f13cf97e", + "id": "89f577fa", "metadata": { "editable": true }, @@ -3143,7 +3144,7 @@ }, { "cell_type": "markdown", - "id": "e0dd9288", + "id": "73db81fc", "metadata": { "editable": true }, @@ -3155,7 +3156,7 @@ }, { "cell_type": "markdown", - "id": "455a7242", + "id": "6956b9f1", "metadata": { "editable": true }, @@ -3177,7 +3178,7 @@ }, { "cell_type": "markdown", - "id": "42cf5d46", + "id": "13e5d04c", "metadata": { "editable": true }, @@ -3192,7 +3193,7 @@ }, { "cell_type": "markdown", - "id": "d5e3b554", + "id": "dd560ef7", "metadata": { "editable": true }, @@ -3203,7 +3204,7 @@ { "cell_type": "code", "execution_count": 31, - "id": "0c3e3737", + "id": "ac42510c", "metadata": { "collapsed": false, "editable": true @@ -3358,7 +3359,7 @@ }, { "cell_type": "markdown", - "id": "405313c5", + "id": "22aed435", "metadata": { "editable": true }, @@ -3373,7 +3374,7 @@ { "cell_type": "code", "execution_count": 32, - "id": "6afd8ade", + "id": "96179484", "metadata": { "collapsed": false, "editable": true @@ -3542,7 +3543,7 @@ }, { "cell_type": "markdown", - "id": "5751a242", + "id": "a0ff62a9", "metadata": { "editable": true }, @@ -3555,7 +3556,7 @@ }, { "cell_type": "markdown", - "id": "6d1c21f9", + "id": "e9112c77", "metadata": { "editable": true }, @@ -3572,7 +3573,7 @@ }, { "cell_type": "markdown", - "id": "11c12b59", + "id": "cf582ad1", "metadata": { "editable": true }, @@ -3588,7 +3589,7 @@ }, { "cell_type": "markdown", - "id": "38d3e5e2", + "id": "d945a6b3", "metadata": { "editable": true }, @@ -3601,7 +3602,7 @@ }, { "cell_type": "markdown", - "id": "009b3e5f", + "id": "e98cd638", "metadata": { "editable": true }, @@ -3618,7 +3619,7 @@ }, { "cell_type": "markdown", - "id": "cca20977", + "id": "8b5c6044", "metadata": { "editable": true }, @@ -3630,7 +3631,7 @@ }, { "cell_type": "markdown", - "id": "443a9c48", + "id": "74c055d2", "metadata": { "editable": true }, @@ -3657,7 +3658,7 @@ }, { "cell_type": "markdown", - "id": "b8e68047", + "id": "a65e3069", "metadata": { "editable": true }, @@ -3670,7 +3671,7 @@ { "cell_type": "code", "execution_count": 33, - "id": "be900d51", + "id": "b092c21e", "metadata": { "collapsed": false, "editable": true @@ -3849,7 +3850,7 @@ }, { "cell_type": "markdown", - "id": "3683040a", + "id": "1aa71f38", "metadata": { "editable": true }, @@ -3869,7 +3870,7 @@ }, { "cell_type": "markdown", - "id": "79e53a04", + "id": "9d1de21f", "metadata": { "editable": true }, @@ -3884,7 +3885,7 @@ }, { "cell_type": "markdown", - "id": "48950bb1", + "id": "826b08a1", "metadata": { "editable": true }, @@ -3898,7 +3899,7 @@ }, { "cell_type": "markdown", - "id": "0e6fafd0", + "id": "c4493848", "metadata": { "editable": true }, @@ -3914,7 +3915,7 @@ }, { "cell_type": "markdown", - "id": "e1c87174", + "id": "e37b66c6", "metadata": { "editable": true }, @@ -3924,7 +3925,7 @@ }, { "cell_type": "markdown", - "id": "4fe0255f", + "id": "264abdcc", "metadata": { "editable": true }, @@ -3946,7 +3947,7 @@ }, { "cell_type": "markdown", - "id": "9537e9ef", + "id": "afc2e4cc", "metadata": { "editable": true }, @@ -3960,7 +3961,7 @@ { "cell_type": "code", "execution_count": 34, - "id": "cc9511ba", + "id": "63c572f6", "metadata": { "collapsed": false, "editable": true @@ -4036,7 +4037,7 @@ }, { "cell_type": "markdown", - "id": "01b22037", + "id": "6381dfa2", "metadata": { "editable": true }, @@ -4048,7 +4049,7 @@ }, { "cell_type": "markdown", - "id": "bc0da822", + "id": "ddcc006d", "metadata": { "editable": true }, @@ -4065,7 +4066,7 @@ }, { "cell_type": "markdown", - "id": "e4ab7df8", + "id": "85639943", "metadata": { "editable": true }, @@ -4077,7 +4078,7 @@ }, { "cell_type": "markdown", - "id": "0f4d49b9", + "id": "f17eea8d", "metadata": { "editable": true }, @@ -4092,7 +4093,7 @@ }, { "cell_type": "markdown", - "id": "f3570184", + "id": "1efed335", "metadata": { "editable": true }, @@ -4104,7 +4105,7 @@ }, { "cell_type": "markdown", - "id": "1b905211", + "id": "23e866a2", "metadata": { "editable": true }, @@ -4116,7 +4117,7 @@ }, { "cell_type": "markdown", - "id": "789836cb", + "id": "2cfcda87", "metadata": { "editable": true }, @@ -4128,7 +4129,7 @@ }, { "cell_type": "markdown", - "id": "0f363195", + "id": "b2a2d58c", "metadata": { "editable": true }, @@ -4138,7 +4139,7 @@ }, { "cell_type": "markdown", - "id": "e1e7e2f5", + "id": "a7c84b58", "metadata": { "editable": true }, @@ -4155,7 +4156,7 @@ }, { "cell_type": "markdown", - "id": "d1f651e2", + "id": "9db2324e", "metadata": { "editable": true }, @@ -4167,7 +4168,7 @@ }, { "cell_type": "markdown", - "id": "be94670f", + "id": "f94f8d1a", "metadata": { "editable": true }, @@ -4179,7 +4180,7 @@ }, { "cell_type": "markdown", - "id": "eca6785f", + "id": "e8eaba06", "metadata": { "editable": true }, @@ -4189,7 +4190,7 @@ }, { "cell_type": "markdown", - "id": "f68aa900", + "id": "3c345647", "metadata": { "editable": true }, @@ -4201,7 +4202,7 @@ }, { "cell_type": "markdown", - "id": "e85f2435", + "id": "0d913be0", "metadata": { "editable": true }, @@ -4212,7 +4213,7 @@ { "cell_type": "code", "execution_count": 35, - "id": "c0022a0a", + "id": "96194d94", "metadata": { "collapsed": false, "editable": true @@ -4377,7 +4378,7 @@ }, { "cell_type": "markdown", - "id": "1ae49b85", + "id": "780c5c66", "metadata": { "editable": true }, @@ -4399,7 +4400,7 @@ }, { "cell_type": "markdown", - "id": "f22aa870", + "id": "b6dfbfdc", "metadata": { "editable": true }, @@ -4416,7 +4417,7 @@ }, { "cell_type": "markdown", - "id": "12402f92", + "id": "011ba117", "metadata": { "editable": true }, @@ -4426,7 +4427,7 @@ }, { "cell_type": "markdown", - "id": "00b9799d", + "id": "cdf079bc", "metadata": { "editable": true }, @@ -4441,7 +4442,7 @@ }, { "cell_type": "markdown", - "id": "63b91aa9", + "id": "bf2fc40c", "metadata": { "editable": true }, @@ -4451,7 +4452,7 @@ }, { "cell_type": "markdown", - "id": "3e50772a", + "id": "6662f05c", "metadata": { "editable": true }, @@ -4466,7 +4467,7 @@ }, { "cell_type": "markdown", - "id": "f9d74ee1", + "id": "fe9a0465", "metadata": { "editable": true }, @@ -4477,7 +4478,7 @@ }, { "cell_type": "markdown", - "id": "9d885961", + "id": "7603ea9a", "metadata": { "editable": true }, @@ -4497,7 +4498,7 @@ }, { "cell_type": "markdown", - "id": "4bdb2a02", + "id": "6744dfef", "metadata": { "editable": true }, @@ -4509,7 +4510,7 @@ }, { "cell_type": "markdown", - "id": "c20b7d32", + "id": "af13fca6", "metadata": { "editable": true }, @@ -4546,7 +4547,7 @@ }, { "cell_type": "markdown", - "id": "798502d3", + "id": "bd1bd149", "metadata": { "editable": true }, @@ -4556,7 +4557,7 @@ }, { "cell_type": "markdown", - "id": "ed43a985", + "id": "43e51ef4", "metadata": { "editable": true }, @@ -4569,7 +4570,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "41414177", + "id": "49c94dd9", "metadata": { "collapsed": false, "editable": true @@ -4774,7 +4775,7 @@ }, { "cell_type": "markdown", - "id": "b32f9258", + "id": "6d27256f", "metadata": { "editable": true }, @@ -4791,7 +4792,7 @@ }, { "cell_type": "markdown", - "id": "f211463a", + "id": "df08a8ac", "metadata": { "editable": true }, @@ -4808,7 +4809,7 @@ }, { "cell_type": "markdown", - "id": "2b4bd193", + "id": "ec4b9fd4", "metadata": { "editable": true }, @@ -4818,7 +4819,7 @@ }, { "cell_type": "markdown", - "id": "0ece9e81", + "id": "92f17705", "metadata": { "editable": true }, @@ -4833,7 +4834,7 @@ }, { "cell_type": "markdown", - "id": "e30e6123", + "id": "eec1785d", "metadata": { "editable": true }, @@ -4847,7 +4848,7 @@ }, { "cell_type": "markdown", - "id": "01fabacb", + "id": "544c3fce", "metadata": { "editable": true }, @@ -4860,7 +4861,7 @@ }, { "cell_type": "markdown", - "id": "c13d41fb", + "id": "74af5618", "metadata": { "editable": true }, @@ -4880,7 +4881,7 @@ }, { "cell_type": "markdown", - "id": "eb96a414", + "id": "9a7c5864", "metadata": { "editable": true }, @@ -4892,7 +4893,7 @@ }, { "cell_type": "markdown", - "id": "f3bad2e3", + "id": "3f2d680d", "metadata": { "editable": true }, @@ -4904,7 +4905,7 @@ }, { "cell_type": "markdown", - "id": "baf4acd6", + "id": "118044b0", "metadata": { "editable": true }, @@ -4916,7 +4917,7 @@ }, { "cell_type": "markdown", - "id": "32139235", + "id": "e9b82be4", "metadata": { "editable": true }, @@ -4926,7 +4927,7 @@ }, { "cell_type": "markdown", - "id": "dc2aa978", + "id": "d5e6b103", "metadata": { "editable": true }, @@ -4938,7 +4939,7 @@ }, { "cell_type": "markdown", - "id": "1282e316", + "id": "c9dec199", "metadata": { "editable": true }, @@ -4950,7 +4951,7 @@ }, { "cell_type": "markdown", - "id": "98dde5b2", + "id": "118d2522", "metadata": { "editable": true }, @@ -4962,7 +4963,7 @@ }, { "cell_type": "markdown", - "id": "d3e8bbe0", + "id": "1d13aaff", "metadata": { "editable": true }, @@ -4972,7 +4973,7 @@ }, { "cell_type": "markdown", - "id": "8137a1b2", + "id": "4de9c463", "metadata": { "editable": true }, @@ -4988,7 +4989,7 @@ }, { "cell_type": "markdown", - "id": "cbce36ed", + "id": "65b2ba09", "metadata": { "editable": true }, @@ -4998,7 +4999,7 @@ }, { "cell_type": "markdown", - "id": "0a91d2c7", + "id": "843d90aa", "metadata": { "editable": true }, @@ -5010,7 +5011,7 @@ }, { "cell_type": "markdown", - "id": "df8b3382", + "id": "77447bcd", "metadata": { "editable": true }, @@ -5027,7 +5028,7 @@ }, { "cell_type": "markdown", - "id": "1851cd76", + "id": "c3cf90aa", "metadata": { "editable": true }, @@ -5037,7 +5038,7 @@ }, { "cell_type": "markdown", - "id": "a4246df0", + "id": "257d1f48", "metadata": { "editable": true }, @@ -5053,7 +5054,7 @@ }, { "cell_type": "markdown", - "id": "cbecbbb8", + "id": "7f4f7d6a", "metadata": { "editable": true }, @@ -5067,7 +5068,7 @@ }, { "cell_type": "markdown", - "id": "09484628", + "id": "1e0c143a", "metadata": { "editable": true }, @@ -5086,7 +5087,7 @@ { "cell_type": "code", "execution_count": 37, - "id": "dd51a62f", + "id": "e52c49e9", "metadata": { "collapsed": false, "editable": true @@ -5141,7 +5142,7 @@ }, { "cell_type": "markdown", - "id": "822af629", + "id": "e6975906", "metadata": { "editable": true }, @@ -5171,7 +5172,7 @@ }, { "cell_type": "markdown", - "id": "2c358905", + "id": "d665f51c", "metadata": { "editable": true }, @@ -5200,7 +5201,7 @@ { "cell_type": "code", "execution_count": 38, - "id": "45c5e295", + "id": "152c290e", "metadata": { "collapsed": false, "editable": true @@ -5247,7 +5248,7 @@ }, { "cell_type": "markdown", - "id": "4dd3869b", + "id": "eac82d2c", "metadata": { "editable": true }, @@ -5273,7 +5274,7 @@ { "cell_type": "code", "execution_count": 39, - "id": "7e2b77d3", + "id": "df3d9605", "metadata": { "collapsed": false, "editable": true @@ -5507,7 +5508,7 @@ }, { "cell_type": "markdown", - "id": "7bd8fcce", + "id": "fec03008", "metadata": { "editable": true }, @@ -5519,7 +5520,7 @@ }, { "cell_type": "markdown", - "id": "fc2ee080", + "id": "403f7560", "metadata": { "editable": true }, @@ -5531,7 +5532,7 @@ }, { "cell_type": "markdown", - "id": "85ad3201", + "id": "dc05badf", "metadata": { "editable": true }, @@ -5543,7 +5544,7 @@ }, { "cell_type": "markdown", - "id": "c1262c90", + "id": "1daf1dd8", "metadata": { "editable": true }, @@ -5560,7 +5561,7 @@ }, { "cell_type": "markdown", - "id": "4bdfae8e", + "id": "4da632df", "metadata": { "editable": true }, @@ -5570,7 +5571,7 @@ }, { "cell_type": "markdown", - "id": "35f806f3", + "id": "851bb943", "metadata": { "editable": true }, @@ -5582,7 +5583,7 @@ }, { "cell_type": "markdown", - "id": "5c0fa662", + "id": "760b72fe", "metadata": { "editable": true }, @@ -5599,7 +5600,7 @@ }, { "cell_type": "markdown", - "id": "1ea04257", + "id": "e3e22598", "metadata": { "editable": true }, @@ -5610,7 +5611,7 @@ }, { "cell_type": "markdown", - "id": "e55ce75f", + "id": "59f39060", "metadata": { "editable": true }, @@ -5630,7 +5631,7 @@ }, { "cell_type": "markdown", - "id": "43a96eca", + "id": "bf3a2904", "metadata": { "editable": true }, @@ -5640,7 +5641,7 @@ }, { "cell_type": "markdown", - "id": "3bdd1e79", + "id": "4a633f01", "metadata": { "editable": true }, @@ -5666,7 +5667,7 @@ }, { "cell_type": "markdown", - "id": "5e607eee", + "id": "c09dc6a7", "metadata": { "editable": true }, @@ -5682,7 +5683,7 @@ }, { "cell_type": "markdown", - "id": "aa448712", + "id": "592d4d57", "metadata": { "editable": true }, @@ -5693,7 +5694,7 @@ { "cell_type": "code", "execution_count": 40, - "id": "e4e02379", + "id": "1c25dc4e", "metadata": { "collapsed": false, "editable": true @@ -5924,7 +5925,7 @@ }, { "cell_type": "markdown", - "id": "27428d8d", + "id": "5072a8bd", "metadata": { "editable": true }, diff --git a/doc/src/week43/week43.do.txt b/doc/src/week43/week43.do.txt index da849bad6..1fccfd4e0 100644 --- a/doc/src/week43/week43.do.txt +++ b/doc/src/week43/week43.do.txt @@ -6,11 +6,12 @@ DATE: October 20, 2025 ===== Plans for week 43 ===== !bblock Material for the lecture on Monday October 20, 2025 - * Building our own Feed-forward Neural Network with intro to Tensorflow - * Solving differential equations with Neural Networks +o Reminder from last week, see lalso ecture notes from week 42 at URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html" as well as those from week 41, see see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". +o Building our own Feed-forward Neural Network. +o Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13.. +o Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. # * Video of lecture at URL:"https://youtu.be/vkBNTn-MLqs" -# * Video os second part, solving differential equations with neural networks at URL:"https://youtu.be/2N8To65I2wQ" -# * Whiteboard notes on solving differential equations at URL:"https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2024/NotesOct21.pdf" +# * Whiteboard notes on solving differential equations at URL:"https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2025/FYSSTKweek43.pdf" !eblock @@ -18,9 +19,8 @@ DATE: October 20, 2025 !split ===== Exercises and lab session week 43 ===== !bblock Lab sessions on Tuesday and Wednesday - * Exercise on writing your own neural network code - * The exercises this week will be continued next week as well - * Discussion of project 2 +o Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code. +o The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems !eblock @@ -30,7 +30,7 @@ DATE: October 20, 2025 ===== Using Automatic differentiation ===== In our discussions of ordinary differential equations and neural network codes -we will also study the usage of Autograd, see for example URL:"https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola" in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at URL:"https://github.com/HIPS/autograd" and the lecture slides from week 40, see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". +we will also study the usage of Autograd, see for example URL:"https://www.youtube.com/watch?v=fRf4l5qaX1M&ab_channel=AlexSmola" in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at URL:"https://github.com/HIPS/autograd" and the lecture slides from week 41, see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". !split From b0ef411bea5b494c0247cc5e1b5016f36701862c Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 07:56:38 +0200 Subject: [PATCH 04/14] updated notes --- .../_build/.doctrees/environment.pickle | Bin 473864 -> 473882 bytes doc/LectureNotes/week43.ipynb | 5948 +++++++++++++++++ 2 files changed, 5948 insertions(+) create mode 100644 doc/LectureNotes/week43.ipynb diff --git a/doc/LectureNotes/_build/.doctrees/environment.pickle b/doc/LectureNotes/_build/.doctrees/environment.pickle index fd4f70d257c2151ce115c0a35dae74c3ad5df21c..9fcf28611fd201a8eb3dca60a22e130702ac2cc9 100644 GIT binary patch literal 473882 zcmd4437i~9bw6%d$4aYfbsv`Ow#T-1CC#pG$?~~6Ew3)L@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reACPY4xN?E z0LD^D41BDmh`Qu^k6Sx{+;V!~>XuUx6XkTuQ>6w@J{03&jr9-H@zcebR0hcAQpimC zp(vEhbG729-^YQtojRalRzyZ3OIj1#}x%yFnL80V-Q9|ODdVoDD_m=lYXM@9=5Il6xQ{G ZM?JoJ8e-K0{SWJ_c-&GxjG@}b{|_%MG!g&+ diff --git a/doc/LectureNotes/week43.ipynb b/doc/LectureNotes/week43.ipynb new file mode 100644 index 000000000..3e86d5cdb --- /dev/null +++ b/doc/LectureNotes/week43.ipynb @@ -0,0 +1,5948 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "8c52cd3b", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "846eee41", + "metadata": { + "editable": true + }, + "source": [ + "# Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations\n", + "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo, Norway\n", + "\n", + "Date: **October 20, 2025**" + ] + }, + { + "cell_type": "markdown", + "id": "ff057bd5", + "metadata": { + "editable": true + }, + "source": [ + "## Plans for week 43\n", + "\n", + "**Material for the lecture on Monday October 20, 2025.**\n", + "\n", + "1. Reminder from last week, see lalso ecture notes from week 42 at as well as those from week 41, see see . \n", + "\n", + "2. Building our own Feed-forward Neural Network.\n", + "\n", + "3. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13.. \n", + "\n", + "4. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well.\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "8d1fd0b3", + "metadata": { + "editable": true + }, + "source": [ + "## Exercises and lab session week 43\n", + "**Lab sessions on Tuesday and Wednesday.**\n", + "\n", + "1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.\n", + "\n", + "2. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems" + ] + }, + { + "cell_type": "markdown", + "id": "4990faa2", + "metadata": { + "editable": true + }, + "source": [ + "## Using Automatic differentiation\n", + "\n", + "In our discussions of ordinary differential equations and neural network codes\n", + "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at and the lecture slides from week 41, see ." + ] + }, + { + "cell_type": "markdown", + "id": "76cb0250", + "metadata": { + "editable": true + }, + "source": [ + "## Back propagation and automatic differentiation\n", + "\n", + "For more details on the back propagation algorithm and automatic differentiation see\n", + "1. \n", + "\n", + "2. \n", + "\n", + "3. Slides 12-44 at " + ] + }, + { + "cell_type": "markdown", + "id": "5bdfe8a0", + "metadata": { + "editable": true + }, + "source": [ + "## Lecture Monday October 20" + ] + }, + { + "cell_type": "markdown", + "id": "b78c27be", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations\n", + "This is a reminder from last week.\n", + "\n", + "**The architecture (our model).**\n", + "\n", + "1. Set up your inputs and outputs (scalars, vectors, matrices or higher-order arrays)\n", + "\n", + "2. Define the number of hidden layers and hidden nodes\n", + "\n", + "3. Define activation functions for hidden layers and output layers\n", + "\n", + "4. Define optimizer (plan learning rate, momentum, ADAgrad, RMSprop, ADAM etc) and array of initial learning rates\n", + "\n", + "5. Define cost function and possible regularization terms with hyperparameters\n", + "\n", + "6. Initialize weights and biases\n", + "\n", + "7. Fix number of iterations for the feed forward part and back propagation part" + ] + }, + { + "cell_type": "markdown", + "id": "db515eac", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm, part 1\n", + "\n", + "Let us write this out in the form of an algorithm.\n", + "\n", + "**First**, we set up the input data $\\boldsymbol{x}$ and the activations\n", + "$\\boldsymbol{z}_1$ of the input layer and compute the activation function and\n", + "the pertinent outputs $\\boldsymbol{a}^1$.\n", + "\n", + "**Secondly**, we perform then the feed forward till we reach the output\n", + "layer and compute all $\\boldsymbol{z}_l$ of the input layer and compute the\n", + "activation function and the pertinent outputs $\\boldsymbol{a}^l$ for\n", + "$l=1,2,3,\\dots,L$.\n", + "\n", + "**Notation**: The first hidden layer has $l=1$ as label and the final output layer has $l=L$." + ] + }, + { + "cell_type": "markdown", + "id": "0d9e2c6d", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm, part 2\n", + "\n", + "Thereafter we compute the ouput error $\\boldsymbol{\\delta}^L$ by computing all" + ] + }, + { + "cell_type": "markdown", + "id": "c54ddbb9", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^L = \\sigma'(z_j^L)\\frac{\\partial {\\cal C}}{\\partial (a_j^L)}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0a074eb8", + "metadata": { + "editable": true + }, + "source": [ + "Then we compute the back propagate error for each $l=L-1,L-2,\\dots,1$ as" + ] + }, + { + "cell_type": "markdown", + "id": "2916e7ad", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "fc87090a", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the Back propagation algorithm, part 3\n", + "\n", + "Finally, we update the weights and the biases using gradient descent\n", + "for each $l=L-1,L-2,\\dots,1$ (the first hidden layer) and update the weights and biases\n", + "according to the rules" + ] + }, + { + "cell_type": "markdown", + "id": "0fab3976", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "506b036e", + "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", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7230ebb2", + "metadata": { + "editable": true + }, + "source": [ + "with $\\eta$ being the learning rate." + ] + }, + { + "cell_type": "markdown", + "id": "24dcabf8", + "metadata": { + "editable": true + }, + "source": [ + "## Updating the gradients\n", + "\n", + "With the back propagate error for each $l=L-1,L-2,\\dots,1$ as" + ] + }, + { + "cell_type": "markdown", + "id": "769b4b46", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0eb6e407", + "metadata": { + "editable": true + }, + "source": [ + "we update the weights and the biases using gradient descent for each $l=L-1,L-2,\\dots,1$ and update the weights and biases according to the rules" + ] + }, + { + "cell_type": "markdown", + "id": "dd2caf09", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3ca5122d", + "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", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0297fbd7", + "metadata": { + "editable": true + }, + "source": [ + "## Activation functions\n", + "\n", + "A property that characterizes a neural network, other than its\n", + "connectivity, is the choice of activation function(s). The following\n", + "restrictions are imposed on an activation function for an FFNN to\n", + "fulfill the universal approximation theorem\n", + "\n", + " * Non-constant\n", + "\n", + " * Bounded\n", + "\n", + " * Monotonically-increasing\n", + "\n", + " * Continuous" + ] + }, + { + "cell_type": "markdown", + "id": "093209ef", + "metadata": { + "editable": true + }, + "source": [ + "### Activation functions, examples\n", + "\n", + "Typical examples are the logistic *Sigmoid*" + ] + }, + { + "cell_type": "markdown", + "id": "52cacfbe", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\sigma(x) = \\frac{1}{1 + e^{-x}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3ac82bdf", + "metadata": { + "editable": true + }, + "source": [ + "and the *hyperbolic tangent* function" + ] + }, + { + "cell_type": "markdown", + "id": "e3f9be3c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\sigma(x) = \\tanh(x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "fdb953a2", + "metadata": { + "editable": true + }, + "source": [ + "## The RELU function family\n", + "\n", + "The ReLU activation function suffers from a problem known as the dying\n", + "ReLUs: during training, some neurons effectively die, meaning they\n", + "stop outputting anything other than 0.\n", + "\n", + "In some cases, you may find that half of your network’s neurons are\n", + "dead, especially if you used a large learning rate. During training,\n", + "if a neuron’s weights get updated such that the weighted sum of the\n", + "neuron’s inputs is negative, it will start outputting 0. When this\n", + "happen, the neuron is unlikely to come back to life since the gradient\n", + "of the ReLU function is 0 when its input is negative." + ] + }, + { + "cell_type": "markdown", + "id": "0d8677dd", + "metadata": { + "editable": true + }, + "source": [ + "## ELU function\n", + "\n", + "To solve this problem, nowadays practitioners use a variant of the\n", + "ReLU function, such as the leaky ReLU discussed above or the so-called\n", + "exponential linear unit (ELU) function" + ] + }, + { + "cell_type": "markdown", + "id": "6d2d4dcc", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "ELU(z) = \\left\\{\\begin{array}{cc} \\alpha\\left( \\exp{(z)}-1\\right) & z < 0,\\\\ z & z \\ge 0.\\end{array}\\right.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e17fbd6e", + "metadata": { + "editable": true + }, + "source": [ + "## Which activation function should we use?\n", + "\n", + "In general it seems that the ELU activation function is better than\n", + "the leaky ReLU function (and its variants), which is better than\n", + "ReLU. ReLU performs better than $\\tanh$ which in turn performs better\n", + "than the logistic function.\n", + "\n", + "If runtime performance is an issue, then you may opt for the leaky\n", + "ReLU function over the ELU function If you don’t want to tweak yet\n", + "another hyperparameter, you may just use the default $\\alpha$ of\n", + "$0.01$ for the leaky ReLU, and $1$ for ELU. If you have spare time and\n", + "computing power, you can use cross-validation or bootstrap to evaluate\n", + "other activation functions." + ] + }, + { + "cell_type": "markdown", + "id": "4464d159", + "metadata": { + "editable": true + }, + "source": [ + "## More on activation functions, output layers\n", + "\n", + "In most cases you can use the ReLU activation function in the hidden\n", + "layers (or one of its variants).\n", + "\n", + "It is a bit faster to compute than other activation functions, and the\n", + "gradient descent optimization does in general not get stuck.\n", + "\n", + "**For the output layer:**\n", + "\n", + "* For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).\n", + "\n", + "* For regression tasks, you can simply use no activation function at all." + ] + }, + { + "cell_type": "markdown", + "id": "d7dacac8", + "metadata": { + "editable": true + }, + "source": [ + "## Building neural networks in Tensorflow and Keras\n", + "\n", + "Now we want to build on the experience gained from our neural network implementation in NumPy and scikit-learn\n", + "and use it to construct a neural network in Tensorflow. Once we have constructed a neural network in NumPy\n", + "and Tensorflow, building one in Keras is really quite trivial, though the performance may suffer. \n", + "\n", + "In our previous example we used only one hidden layer, and in this we will use two. From this it should be quite\n", + "clear how to build one using an arbitrary number of hidden layers, using data structures such as Python lists or\n", + "NumPy arrays." + ] + }, + { + "cell_type": "markdown", + "id": "cb79f5a6", + "metadata": { + "editable": true + }, + "source": [ + "## Tensorflow\n", + "\n", + "Tensorflow is an open source library machine learning library\n", + "developed by the Google Brain team for internal use. It was released\n", + "under the Apache 2.0 open source license in November 9, 2015.\n", + "\n", + "Tensorflow is a computational framework that allows you to construct\n", + "machine learning models at different levels of abstraction, from\n", + "high-level, object-oriented APIs like Keras, down to the C++ kernels\n", + "that Tensorflow is built upon. The higher levels of abstraction are\n", + "simpler to use, but less flexible, and our choice of implementation\n", + "should reflect the problems we are trying to solve.\n", + "\n", + "[Tensorflow uses](https://www.tensorflow.org/guide/graphs) so-called graphs to represent your computation\n", + "in terms of the dependencies between individual operations, such that you first build a Tensorflow *graph*\n", + "to represent your model, and then create a Tensorflow *session* to run the graph.\n", + "\n", + "In this guide we will analyze the same data as we did in our NumPy and\n", + "scikit-learn tutorial, gathered from the MNIST database of images. We\n", + "will give an introduction to the lower level Python Application\n", + "Program Interfaces (APIs), and see how we use them to build our graph.\n", + "Then we will build (effectively) the same graph in Keras, to see just\n", + "how simple solving a machine learning problem can be.\n", + "\n", + "To install tensorflow on Unix/Linux systems, use pip as" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "44cf829e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "pip3 install tensorflow" + ] + }, + { + "cell_type": "markdown", + "id": "bdf6f4be", + "metadata": { + "editable": true + }, + "source": [ + "and/or if you use **anaconda**, just write (or install from the graphical user interface)\n", + "(current release of CPU-only TensorFlow)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "784ed3b7", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda create -n tf tensorflow\n", + "conda activate tf" + ] + }, + { + "cell_type": "markdown", + "id": "30a63e04", + "metadata": { + "editable": true + }, + "source": [ + "To install the current release of GPU TensorFlow" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "5ecbf45a", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda create -n tf-gpu tensorflow-gpu\n", + "conda activate tf-gpu" + ] + }, + { + "cell_type": "markdown", + "id": "4a0568e9", + "metadata": { + "editable": true + }, + "source": [ + "## Using Keras\n", + "\n", + "Keras is a high level [neural network](https://en.wikipedia.org/wiki/Application_programming_interface)\n", + "that supports Tensorflow, CTNK and Theano as backends. \n", + "If you have Anaconda installed you may run the following command" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "9982df74", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda install keras" + ] + }, + { + "cell_type": "markdown", + "id": "b81f34fd", + "metadata": { + "editable": true + }, + "source": [ + "You can look up the [instructions here](https://keras.io/) for more information.\n", + "\n", + "We will to a large extent use **keras** in this course." + ] + }, + { + "cell_type": "markdown", + "id": "cf68391d", + "metadata": { + "editable": true + }, + "source": [ + "## Collect and pre-process data\n", + "\n", + "Let us look again at the MINST data set." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "2594d47b", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "\n", + "# import necessary packages\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import tensorflow as tf\n", + "from sklearn import datasets\n", + "\n", + "\n", + "# ensure the same random numbers appear every time\n", + "np.random.seed(0)\n", + "\n", + "# display images in notebook\n", + "%matplotlib inline\n", + "plt.rcParams['figure.figsize'] = (12,12)\n", + "\n", + "\n", + "# download MNIST dataset\n", + "digits = datasets.load_digits()\n", + "\n", + "# define inputs and labels\n", + "inputs = digits.images\n", + "labels = digits.target\n", + "\n", + "print(\"inputs = (n_inputs, pixel_width, pixel_height) = \" + str(inputs.shape))\n", + "print(\"labels = (n_inputs) = \" + str(labels.shape))\n", + "\n", + "\n", + "# flatten the image\n", + "# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64\n", + "n_inputs = len(inputs)\n", + "inputs = inputs.reshape(n_inputs, -1)\n", + "print(\"X = (n_inputs, n_features) = \" + str(inputs.shape))\n", + "\n", + "\n", + "# choose some random images to display\n", + "indices = np.arange(n_inputs)\n", + "random_indices = np.random.choice(indices, size=5)\n", + "\n", + "for i, image in enumerate(digits.images[random_indices]):\n", + " plt.subplot(1, 5, i+1)\n", + " plt.axis('off')\n", + " plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n", + " plt.title(\"Label: %d\" % digits.target[random_indices[i]])\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "060f0b22", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from tensorflow.keras.layers import Input\n", + "from tensorflow.keras.models import Sequential #This allows appending layers to existing models\n", + "from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer\n", + "from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)\n", + "from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)\n", + "from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function\n", + "\n", + "from sklearn.model_selection import train_test_split\n", + "\n", + "# one-hot representation of labels\n", + "labels = to_categorical(labels)\n", + "\n", + "# split into train and test data\n", + "train_size = 0.8\n", + "test_size = 1 - train_size\n", + "X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,\n", + " test_size=test_size)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "5491ac4f", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "epochs = 100\n", + "batch_size = 100\n", + "n_neurons_layer1 = 100\n", + "n_neurons_layer2 = 50\n", + "n_categories = 10\n", + "eta_vals = np.logspace(-5, 1, 7)\n", + "lmbd_vals = np.logspace(-5, 1, 7)\n", + "def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):\n", + " model = Sequential()\n", + " model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))\n", + " model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))\n", + " model.add(Dense(n_categories, activation='softmax'))\n", + " \n", + " sgd = optimizers.SGD(learning_rate=eta)\n", + " model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])\n", + " \n", + " return model" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "905a1d27", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "DNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n", + " \n", + "for i, eta in enumerate(eta_vals):\n", + " for j, lmbd in enumerate(lmbd_vals):\n", + " DNN = create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories,\n", + " eta=eta, lmbd=lmbd)\n", + " DNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)\n", + " scores = DNN.evaluate(X_test, Y_test)\n", + " \n", + " DNN_keras[i][j] = DNN\n", + " \n", + " print(\"Learning rate = \", eta)\n", + " print(\"Lambda = \", lmbd)\n", + " print(\"Test accuracy: %.3f\" % scores[1])\n", + " print()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "491849b6", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# optional\n", + "# visual representation of grid search\n", + "# uses seaborn heatmap, could probably do this in matplotlib\n", + "import seaborn as sns\n", + "\n", + "sns.set()\n", + "\n", + "train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", + "test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", + "\n", + "for i in range(len(eta_vals)):\n", + " for j in range(len(lmbd_vals)):\n", + " DNN = DNN_keras[i][j]\n", + "\n", + " train_accuracy[i][j] = DNN.evaluate(X_train, Y_train)[1]\n", + " test_accuracy[i][j] = DNN.evaluate(X_test, Y_test)[1]\n", + "\n", + " \n", + "fig, ax = plt.subplots(figsize = (10, 10))\n", + "sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", + "ax.set_title(\"Training Accuracy\")\n", + "ax.set_ylabel(\"$\\eta$\")\n", + "ax.set_xlabel(\"$\\lambda$\")\n", + "plt.show()\n", + "\n", + "fig, ax = plt.subplots(figsize = (10, 10))\n", + "sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", + "ax.set_title(\"Test Accuracy\")\n", + "ax.set_ylabel(\"$\\eta$\")\n", + "ax.set_xlabel(\"$\\lambda$\")\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "25bfc059", + "metadata": { + "editable": true + }, + "source": [ + "## Using Pytorch with the full MNIST data set" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "29c660b4", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import torch\n", + "import torch.nn as nn\n", + "import torch.optim as optim\n", + "import torchvision\n", + "import torchvision.transforms as transforms\n", + "\n", + "# Device configuration: use GPU if available\n", + "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", + "\n", + "# MNIST dataset (downloads if not already present)\n", + "transform = transforms.Compose([\n", + " transforms.ToTensor(),\n", + " transforms.Normalize((0.5,), (0.5,)) # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)\n", + "])\n", + "train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)\n", + "test_dataset = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)\n", + "\n", + "train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)\n", + "test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)\n", + "\n", + "\n", + "class NeuralNet(nn.Module):\n", + " def __init__(self):\n", + " super(NeuralNet, self).__init__()\n", + " self.fc1 = nn.Linear(28*28, 100) # first hidden layer (784 -> 100)\n", + " self.fc2 = nn.Linear(100, 100) # second hidden layer (100 -> 100)\n", + " self.fc3 = nn.Linear(100, 10) # output layer (100 -> 10 classes)\n", + " def forward(self, x):\n", + " x = x.view(x.size(0), -1) # flatten images into vectors of size 784\n", + " x = torch.relu(self.fc1(x)) # hidden layer 1 + ReLU activation\n", + " x = torch.relu(self.fc2(x)) # hidden layer 2 + ReLU activation\n", + " x = self.fc3(x) # output layer (logits for 10 classes)\n", + " return x\n", + "\n", + "model = NeuralNet().to(device)\n", + "\n", + "\n", + "criterion = nn.CrossEntropyLoss()\n", + "optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)\n", + "\n", + "num_epochs = 10\n", + "for epoch in range(num_epochs):\n", + " model.train() # set model to training mode\n", + " running_loss = 0.0\n", + " for images, labels in train_loader:\n", + " # Move data to device (GPU if available, else CPU)\n", + " images, labels = images.to(device), labels.to(device)\n", + "\n", + " optimizer.zero_grad() # reset gradients to zero\n", + " outputs = model(images) # forward pass: compute predictions\n", + " loss = criterion(outputs, labels) # compute cross-entropy loss\n", + " loss.backward() # backpropagate to compute gradients\n", + " optimizer.step() # update weights using SGD step \n", + "\n", + " running_loss += loss.item()\n", + " # Compute average loss over all batches in this epoch\n", + " avg_loss = running_loss / len(train_loader)\n", + " print(f\"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}\")\n", + "\n", + "#Evaluation on the Test Set\n", + "\n", + "\n", + "\n", + "model.eval() # set model to evaluation mode \n", + "correct = 0\n", + "total = 0\n", + "with torch.no_grad(): # disable gradient calculation for evaluation \n", + " for images, labels in test_loader:\n", + " images, labels = images.to(device), labels.to(device)\n", + " outputs = model(images)\n", + " _, predicted = torch.max(outputs, dim=1) # class with highest score\n", + " total += labels.size(0)\n", + " correct += (predicted == labels).sum().item()\n", + "\n", + "accuracy = 100 * correct / total\n", + "print(f\"Test Accuracy: {accuracy:.2f}%\")" + ] + }, + { + "cell_type": "markdown", + "id": "50468253", + "metadata": { + "editable": true + }, + "source": [ + "## And a similar example using Tensorflow with Keras" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "1e430607", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "import tensorflow as tf\n", + "from tensorflow import keras\n", + "from tensorflow.keras import layers, regularizers\n", + "\n", + "# Check for GPU (TensorFlow will use it automatically if available)\n", + "gpus = tf.config.list_physical_devices('GPU')\n", + "print(f\"GPUs available: {gpus}\")\n", + "\n", + "# 1) Load and preprocess MNIST\n", + "(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()\n", + "# Normalize to [0, 1]\n", + "x_train = (x_train.astype(\"float32\") / 255.0)\n", + "x_test = (x_test.astype(\"float32\") / 255.0)\n", + "\n", + "# 2) Build the model: 784 -> 100 -> 100 -> 10\n", + "l2_reg = 1e-4 # L2 regularization strength\n", + "\n", + "model = keras.Sequential([\n", + " layers.Input(shape=(28, 28)),\n", + " layers.Flatten(),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(10, activation=\"softmax\") # output probabilities for 10 classes\n", + "])\n", + "\n", + "# 3) Compile with SGD + weight decay via L2 regularizers\n", + "model.compile(\n", + " optimizer=keras.optimizers.SGD(learning_rate=0.01),\n", + " loss=\"sparse_categorical_crossentropy\",\n", + " metrics=[\"accuracy\"],\n", + ")\n", + "\n", + "model.summary()\n", + "\n", + "# 4) Train\n", + "history = model.fit(\n", + " x_train, y_train,\n", + " epochs=10,\n", + " batch_size=64,\n", + " validation_split=0.1, # optional: monitor validation during training\n", + " verbose=1\n", + ")\n", + "\n", + "# 5) Evaluate on test set\n", + "test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)\n", + "print(f\"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "44c02ba1", + "metadata": { + "editable": true + }, + "source": [ + "## Building our own neural network code\n", + "\n", + "Here we present a flexible object oriented codebase\n", + "for a feed forward neural network, along with a demonstration of how\n", + "to use it. Before we get into the details of the neural network, we\n", + "will first present some implementations of various schedulers, cost\n", + "functions and activation functions that can be used together with the\n", + "neural network.\n", + "\n", + "The codes here were developed by Eric Reber and Gregor Kajda during spring 2023." + ] + }, + { + "cell_type": "markdown", + "id": "87c53214", + "metadata": { + "editable": true + }, + "source": [ + "### Learning rate methods\n", + "\n", + "The code below shows object oriented implementations of the Constant,\n", + "Momentum, Adagrad, AdagradMomentum, RMS prop and Adam schedulers. All\n", + "of the classes belong to the shared abstract Scheduler class, and\n", + "share the update_change() and reset() methods allowing for any of the\n", + "schedulers to be seamlessly used during the training stage, as will\n", + "later be shown in the fit() method of the neural\n", + "network. Update_change() only has one parameter, the gradient\n", + "($δ^l_ja^{l−1}_k$), and returns the change which will be subtracted\n", + "from the weights. The reset() function takes no parameters, and resets\n", + "the desired variables. For Constant and Momentum, reset does nothing." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "b36b4c64", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "\n", + "class Scheduler:\n", + " \"\"\"\n", + " Abstract class for Schedulers\n", + " \"\"\"\n", + "\n", + " def __init__(self, eta):\n", + " self.eta = eta\n", + "\n", + " # should be overwritten\n", + " def update_change(self, gradient):\n", + " raise NotImplementedError\n", + "\n", + " # overwritten if needed\n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Constant(Scheduler):\n", + " def __init__(self, eta):\n", + " super().__init__(eta)\n", + "\n", + " def update_change(self, gradient):\n", + " return self.eta * gradient\n", + " \n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Momentum(Scheduler):\n", + " def __init__(self, eta: float, momentum: float):\n", + " super().__init__(eta)\n", + " self.momentum = momentum\n", + " self.change = 0\n", + "\n", + " def update_change(self, gradient):\n", + " self.change = self.momentum * self.change + self.eta * gradient\n", + " return self.change\n", + "\n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Adagrad(Scheduler):\n", + " def __init__(self, eta):\n", + " super().__init__(eta)\n", + " self.G_t = None\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " if self.G_t is None:\n", + " self.G_t = np.zeros((gradient.shape[0], gradient.shape[0]))\n", + "\n", + " self.G_t += gradient @ gradient.T\n", + "\n", + " G_t_inverse = 1 / (\n", + " delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1)))\n", + " )\n", + " return self.eta * gradient * G_t_inverse\n", + "\n", + " def reset(self):\n", + " self.G_t = None\n", + "\n", + "\n", + "class AdagradMomentum(Scheduler):\n", + " def __init__(self, eta, momentum):\n", + " super().__init__(eta)\n", + " self.G_t = None\n", + " self.momentum = momentum\n", + " self.change = 0\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " if self.G_t is None:\n", + " self.G_t = np.zeros((gradient.shape[0], gradient.shape[0]))\n", + "\n", + " self.G_t += gradient @ gradient.T\n", + "\n", + " G_t_inverse = 1 / (\n", + " delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1)))\n", + " )\n", + " self.change = self.change * self.momentum + self.eta * gradient * G_t_inverse\n", + " return self.change\n", + "\n", + " def reset(self):\n", + " self.G_t = None\n", + "\n", + "\n", + "class RMS_prop(Scheduler):\n", + " def __init__(self, eta, rho):\n", + " super().__init__(eta)\n", + " self.rho = rho\n", + " self.second = 0.0\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + " self.second = self.rho * self.second + (1 - self.rho) * gradient * gradient\n", + " return self.eta * gradient / (np.sqrt(self.second + delta))\n", + "\n", + " def reset(self):\n", + " self.second = 0.0\n", + "\n", + "\n", + "class Adam(Scheduler):\n", + " def __init__(self, eta, rho, rho2):\n", + " super().__init__(eta)\n", + " self.rho = rho\n", + " self.rho2 = rho2\n", + " self.moment = 0\n", + " self.second = 0\n", + " self.n_epochs = 1\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " self.moment = self.rho * self.moment + (1 - self.rho) * gradient\n", + " self.second = self.rho2 * self.second + (1 - self.rho2) * gradient * gradient\n", + "\n", + " moment_corrected = self.moment / (1 - self.rho**self.n_epochs)\n", + " second_corrected = self.second / (1 - self.rho2**self.n_epochs)\n", + "\n", + " return self.eta * moment_corrected / (np.sqrt(second_corrected + delta))\n", + "\n", + " def reset(self):\n", + " self.n_epochs += 1\n", + " self.moment = 0\n", + " self.second = 0" + ] + }, + { + "cell_type": "markdown", + "id": "166220ac", + "metadata": { + "editable": true + }, + "source": [ + "### Usage of the above learning rate schedulers\n", + "\n", + "To initalize a scheduler, simply create the object and pass in the\n", + "necessary parameters such as the learning rate and the momentum as\n", + "shown below. As the Scheduler class is an abstract class it should not\n", + "called directly, and will raise an error upon usage." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "6e3221f8", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "momentum_scheduler = Momentum(eta=1e-3, momentum=0.9)\n", + "adam_scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999)" + ] + }, + { + "cell_type": "markdown", + "id": "44e094bb", + "metadata": { + "editable": true + }, + "source": [ + "Here is a small example for how a segment of code using schedulers\n", + "could look. Switching out the schedulers is simple." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "e8e938bd", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "weights = np.ones((3,3))\n", + "print(f\"Before scheduler:\\n{weights=}\")\n", + "\n", + "epochs = 10\n", + "for e in range(epochs):\n", + " gradient = np.random.rand(3, 3)\n", + " change = adam_scheduler.update_change(gradient)\n", + " weights = weights - change\n", + " adam_scheduler.reset()\n", + "\n", + "print(f\"\\nAfter scheduler:\\n{weights=}\")" + ] + }, + { + "cell_type": "markdown", + "id": "7546f778", + "metadata": { + "editable": true + }, + "source": [ + "### Cost functions\n", + "\n", + "Here we discuss cost functions that can be used when creating the\n", + "neural network. Every cost function takes the target vector as its\n", + "parameter, and returns a function valued only at $x$ such that it may\n", + "easily be differentiated." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "55250ea2", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "\n", + "def CostOLS(target):\n", + " \n", + " def func(X):\n", + " return (1.0 / target.shape[0]) * np.sum((target - X) ** 2)\n", + "\n", + " return func\n", + "\n", + "\n", + "def CostLogReg(target):\n", + "\n", + " def func(X):\n", + " \n", + " return -(1.0 / target.shape[0]) * np.sum(\n", + " (target * np.log(X + 10e-10)) + ((1 - target) * np.log(1 - X + 10e-10))\n", + " )\n", + "\n", + " return func\n", + "\n", + "\n", + "def CostCrossEntropy(target):\n", + " \n", + " def func(X):\n", + " return -(1.0 / target.size) * np.sum(target * np.log(X + 10e-10))\n", + "\n", + " return func" + ] + }, + { + "cell_type": "markdown", + "id": "6651b1cc", + "metadata": { + "editable": true + }, + "source": [ + "Below we give a short example of how these cost function may be used\n", + "to obtain results if you wish to test them out on your own using\n", + "AutoGrad's automatics differentiation." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "48d70de6", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from autograd import grad\n", + "\n", + "target = np.array([[1, 2, 3]]).T\n", + "a = np.array([[4, 5, 6]]).T\n", + "\n", + "cost_func = CostCrossEntropy\n", + "cost_func_derivative = grad(cost_func(target))\n", + "\n", + "valued_at_a = cost_func_derivative(a)\n", + "print(f\"Derivative of cost function {cost_func.__name__} valued at a:\\n{valued_at_a}\")" + ] + }, + { + "cell_type": "markdown", + "id": "1763139f", + "metadata": { + "editable": true + }, + "source": [ + "### Activation functions\n", + "\n", + "Finally, before we look at the neural network, we will look at the\n", + "activation functions which can be specified between the hidden layers\n", + "and as the output function. Each function can be valued for any given\n", + "vector or matrix X, and can be differentiated via derivate()." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "2cf6bda9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import elementwise_grad\n", + "\n", + "def identity(X):\n", + " return X\n", + "\n", + "\n", + "def sigmoid(X):\n", + " try:\n", + " return 1.0 / (1 + np.exp(-X))\n", + " except FloatingPointError:\n", + " return np.where(X > np.zeros(X.shape), np.ones(X.shape), np.zeros(X.shape))\n", + "\n", + "\n", + "def softmax(X):\n", + " X = X - np.max(X, axis=-1, keepdims=True)\n", + " delta = 10e-10\n", + " return np.exp(X) / (np.sum(np.exp(X), axis=-1, keepdims=True) + delta)\n", + "\n", + "\n", + "def RELU(X):\n", + " return np.where(X > np.zeros(X.shape), X, np.zeros(X.shape))\n", + "\n", + "\n", + "def LRELU(X):\n", + " delta = 10e-4\n", + " return np.where(X > np.zeros(X.shape), X, delta * X)\n", + "\n", + "\n", + "def derivate(func):\n", + " if func.__name__ == \"RELU\":\n", + "\n", + " def func(X):\n", + " return np.where(X > 0, 1, 0)\n", + "\n", + " return func\n", + "\n", + " elif func.__name__ == \"LRELU\":\n", + "\n", + " def func(X):\n", + " delta = 10e-4\n", + " return np.where(X > 0, 1, delta)\n", + "\n", + " return func\n", + "\n", + " else:\n", + " return elementwise_grad(func)" + ] + }, + { + "cell_type": "markdown", + "id": "9e48a5a2", + "metadata": { + "editable": true + }, + "source": [ + "Below follows a short demonstration of how to use an activation\n", + "function. The derivative of the activation function will be important\n", + "when calculating the output delta term during backpropagation. Note\n", + "that derivate() can also be used for cost functions for a more\n", + "generalized approach." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "12995853", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "z = np.array([[4, 5, 6]]).T\n", + "print(f\"Input to activation function:\\n{z}\")\n", + "\n", + "act_func = sigmoid\n", + "a = act_func(z)\n", + "print(f\"\\nOutput from {act_func.__name__} activation function:\\n{a}\")\n", + "\n", + "act_func_derivative = derivate(act_func)\n", + "valued_at_z = act_func_derivative(a)\n", + "print(f\"\\nDerivative of {act_func.__name__} activation function valued at z:\\n{valued_at_z}\")" + ] + }, + { + "cell_type": "markdown", + "id": "63d3c5bd", + "metadata": { + "editable": true + }, + "source": [ + "### The Neural Network\n", + "\n", + "Now that we have gotten a good understanding of the implementation of\n", + "some important components, we can take a look at an object oriented\n", + "implementation of a feed forward neural network. The feed forward\n", + "neural network has been implemented as a class named FFNN, which can\n", + "be initiated as a regressor or classifier dependant on the choice of\n", + "cost function. The FFNN can have any number of input nodes, hidden\n", + "layers with any amount of hidden nodes, and any amount of output nodes\n", + "meaning it can perform multiclass classification as well as binary\n", + "classification and regression problems. Although there is a lot of\n", + "code present, it makes for an easy to use and generalizeable interface\n", + "for creating many types of neural networks as will be demonstrated\n", + "below." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "7e0107d8", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import math\n", + "import autograd.numpy as np\n", + "import sys\n", + "import warnings\n", + "from autograd import grad, elementwise_grad\n", + "from random import random, seed\n", + "from copy import deepcopy, copy\n", + "from typing import Tuple, Callable\n", + "from sklearn.utils import resample\n", + "\n", + "warnings.simplefilter(\"error\")\n", + "\n", + "\n", + "class FFNN:\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Feed Forward Neural Network with interface enabling flexible design of a\n", + " nerual networks architecture and the specification of activation function\n", + " in the hidden layers and output layer respectively. This model can be used\n", + " for both regression and classification problems, depending on the output function.\n", + "\n", + " Attributes:\n", + " ------------\n", + " I dimensions (tuple[int]): A list of positive integers, which specifies the\n", + " number of nodes in each of the networks layers. The first integer in the array\n", + " defines the number of nodes in the input layer, the second integer defines number\n", + " of nodes in the first hidden layer and so on until the last number, which\n", + " specifies the number of nodes in the output layer.\n", + " II hidden_func (Callable): The activation function for the hidden layers\n", + " III output_func (Callable): The activation function for the output layer\n", + " IV cost_func (Callable): Our cost function\n", + " V seed (int): Sets random seed, makes results reproducible\n", + " \"\"\"\n", + "\n", + " def __init__(\n", + " self,\n", + " dimensions: tuple[int],\n", + " hidden_func: Callable = sigmoid,\n", + " output_func: Callable = lambda x: x,\n", + " cost_func: Callable = CostOLS,\n", + " seed: int = None,\n", + " ):\n", + " self.dimensions = dimensions\n", + " self.hidden_func = hidden_func\n", + " self.output_func = output_func\n", + " self.cost_func = cost_func\n", + " self.seed = seed\n", + " self.weights = list()\n", + " self.schedulers_weight = list()\n", + " self.schedulers_bias = list()\n", + " self.a_matrices = list()\n", + " self.z_matrices = list()\n", + " self.classification = None\n", + "\n", + " self.reset_weights()\n", + " self._set_classification()\n", + "\n", + " def fit(\n", + " self,\n", + " X: np.ndarray,\n", + " t: np.ndarray,\n", + " scheduler: Scheduler,\n", + " batches: int = 1,\n", + " epochs: int = 100,\n", + " lam: float = 0,\n", + " X_val: np.ndarray = None,\n", + " t_val: np.ndarray = None,\n", + " ):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " This function performs the training the neural network by performing the feedforward and backpropagation\n", + " algorithm to update the networks weights.\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray) : training data\n", + " II t (np.ndarray) : target data\n", + " III scheduler (Scheduler) : specified scheduler (algorithm for optimization of gradient descent)\n", + " IV scheduler_args (list[int]) : list of all arguments necessary for scheduler\n", + "\n", + " Optional Parameters:\n", + " ------------\n", + " V batches (int) : number of batches the datasets are split into, default equal to 1\n", + " VI epochs (int) : number of iterations used to train the network, default equal to 100\n", + " VII lam (float) : regularization hyperparameter lambda\n", + " VIII X_val (np.ndarray) : validation set\n", + " IX t_val (np.ndarray) : validation target set\n", + "\n", + " Returns:\n", + " ------------\n", + " I scores (dict) : A dictionary containing the performance metrics of the model.\n", + " The number of the metrics depends on the parameters passed to the fit-function.\n", + "\n", + " \"\"\"\n", + "\n", + " # setup \n", + " if self.seed is not None:\n", + " np.random.seed(self.seed)\n", + "\n", + " val_set = False\n", + " if X_val is not None and t_val is not None:\n", + " val_set = True\n", + "\n", + " # creating arrays for score metrics\n", + " train_errors = np.empty(epochs)\n", + " train_errors.fill(np.nan)\n", + " val_errors = np.empty(epochs)\n", + " val_errors.fill(np.nan)\n", + "\n", + " train_accs = np.empty(epochs)\n", + " train_accs.fill(np.nan)\n", + " val_accs = np.empty(epochs)\n", + " val_accs.fill(np.nan)\n", + "\n", + " self.schedulers_weight = list()\n", + " self.schedulers_bias = list()\n", + "\n", + " batch_size = X.shape[0] // batches\n", + "\n", + " X, t = resample(X, t)\n", + "\n", + " # this function returns a function valued only at X\n", + " cost_function_train = self.cost_func(t)\n", + " if val_set:\n", + " cost_function_val = self.cost_func(t_val)\n", + "\n", + " # create schedulers for each weight matrix\n", + " for i in range(len(self.weights)):\n", + " self.schedulers_weight.append(copy(scheduler))\n", + " self.schedulers_bias.append(copy(scheduler))\n", + "\n", + " print(f\"{scheduler.__class__.__name__}: Eta={scheduler.eta}, Lambda={lam}\")\n", + "\n", + " try:\n", + " for e in range(epochs):\n", + " for i in range(batches):\n", + " # allows for minibatch gradient descent\n", + " if i == batches - 1:\n", + " # If the for loop has reached the last batch, take all thats left\n", + " X_batch = X[i * batch_size :, :]\n", + " t_batch = t[i * batch_size :, :]\n", + " else:\n", + " X_batch = X[i * batch_size : (i + 1) * batch_size, :]\n", + " t_batch = t[i * batch_size : (i + 1) * batch_size, :]\n", + "\n", + " self._feedforward(X_batch)\n", + " self._backpropagate(X_batch, t_batch, lam)\n", + "\n", + " # reset schedulers for each epoch (some schedulers pass in this call)\n", + " for scheduler in self.schedulers_weight:\n", + " scheduler.reset()\n", + "\n", + " for scheduler in self.schedulers_bias:\n", + " scheduler.reset()\n", + "\n", + " # computing performance metrics\n", + " pred_train = self.predict(X)\n", + " train_error = cost_function_train(pred_train)\n", + "\n", + " train_errors[e] = train_error\n", + " if val_set:\n", + " \n", + " pred_val = self.predict(X_val)\n", + " val_error = cost_function_val(pred_val)\n", + " val_errors[e] = val_error\n", + "\n", + " if self.classification:\n", + " train_acc = self._accuracy(self.predict(X), t)\n", + " train_accs[e] = train_acc\n", + " if val_set:\n", + " val_acc = self._accuracy(pred_val, t_val)\n", + " val_accs[e] = val_acc\n", + "\n", + " # printing progress bar\n", + " progression = e / epochs\n", + " print_length = self._progress_bar(\n", + " progression,\n", + " train_error=train_errors[e],\n", + " train_acc=train_accs[e],\n", + " val_error=val_errors[e],\n", + " val_acc=val_accs[e],\n", + " )\n", + " except KeyboardInterrupt:\n", + " # allows for stopping training at any point and seeing the result\n", + " pass\n", + "\n", + " # visualization of training progression (similiar to tensorflow progression bar)\n", + " sys.stdout.write(\"\\r\" + \" \" * print_length)\n", + " sys.stdout.flush()\n", + " self._progress_bar(\n", + " 1,\n", + " train_error=train_errors[e],\n", + " train_acc=train_accs[e],\n", + " val_error=val_errors[e],\n", + " val_acc=val_accs[e],\n", + " )\n", + " sys.stdout.write(\"\")\n", + "\n", + " # return performance metrics for the entire run\n", + " scores = dict()\n", + "\n", + " scores[\"train_errors\"] = train_errors\n", + "\n", + " if val_set:\n", + " scores[\"val_errors\"] = val_errors\n", + "\n", + " if self.classification:\n", + " scores[\"train_accs\"] = train_accs\n", + "\n", + " if val_set:\n", + " scores[\"val_accs\"] = val_accs\n", + "\n", + " return scores\n", + "\n", + " def predict(self, X: np.ndarray, *, threshold=0.5):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Performs prediction after training of the network has been finished.\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each\n", + "\n", + " Optional Parameters:\n", + " ------------\n", + " II threshold (float) : sets minimal value for a prediction to be predicted as the positive class\n", + " in classification problems\n", + "\n", + " Returns:\n", + " ------------\n", + " I z (np.ndarray): A prediction vector (row) for each row in our design matrix\n", + " This vector is thresholded if regression=False, meaning that classification results\n", + " in a vector of 1s and 0s, while regressions in an array of decimal numbers\n", + "\n", + " \"\"\"\n", + "\n", + " predict = self._feedforward(X)\n", + "\n", + " if self.classification:\n", + " return np.where(predict > threshold, 1, 0)\n", + " else:\n", + " return predict\n", + "\n", + " def reset_weights(self):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Resets/Reinitializes the weights in order to train the network for a new problem.\n", + "\n", + " \"\"\"\n", + " if self.seed is not None:\n", + " np.random.seed(self.seed)\n", + "\n", + " self.weights = list()\n", + " for i in range(len(self.dimensions) - 1):\n", + " weight_array = np.random.randn(\n", + " self.dimensions[i] + 1, self.dimensions[i + 1]\n", + " )\n", + " weight_array[0, :] = np.random.randn(self.dimensions[i + 1]) * 0.01\n", + "\n", + " self.weights.append(weight_array)\n", + "\n", + " def _feedforward(self, X: np.ndarray):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Calculates the activation of each layer starting at the input and ending at the output.\n", + " Each following activation is calculated from a weighted sum of each of the preceeding\n", + " activations (except in the case of the input layer).\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each\n", + "\n", + " Returns:\n", + " ------------\n", + " I z (np.ndarray): A prediction vector (row) for each row in our design matrix\n", + " \"\"\"\n", + "\n", + " # reset matrices\n", + " self.a_matrices = list()\n", + " self.z_matrices = list()\n", + "\n", + " # if X is just a vector, make it into a matrix\n", + " if len(X.shape) == 1:\n", + " X = X.reshape((1, X.shape[0]))\n", + "\n", + " # Add a coloumn of zeros as the first coloumn of the design matrix, in order\n", + " # to add bias to our data\n", + " bias = np.ones((X.shape[0], 1)) * 0.01\n", + " X = np.hstack([bias, X])\n", + "\n", + " # a^0, the nodes in the input layer (one a^0 for each row in X - where the\n", + " # exponent indicates layer number).\n", + " a = X\n", + " self.a_matrices.append(a)\n", + " self.z_matrices.append(a)\n", + "\n", + " # The feed forward algorithm\n", + " for i in range(len(self.weights)):\n", + " if i < len(self.weights) - 1:\n", + " z = a @ self.weights[i]\n", + " self.z_matrices.append(z)\n", + " a = self.hidden_func(z)\n", + " # bias column again added to the data here\n", + " bias = np.ones((a.shape[0], 1)) * 0.01\n", + " a = np.hstack([bias, a])\n", + " self.a_matrices.append(a)\n", + " else:\n", + " try:\n", + " # a^L, the nodes in our output layers\n", + " z = a @ self.weights[i]\n", + " a = self.output_func(z)\n", + " self.a_matrices.append(a)\n", + " self.z_matrices.append(z)\n", + " except Exception as OverflowError:\n", + " print(\n", + " \"OverflowError in fit() in FFNN\\nHOW TO DEBUG ERROR: Consider lowering your learning rate or scheduler specific parameters such as momentum, or check if your input values need scaling\"\n", + " )\n", + "\n", + " # this will be a^L\n", + " return a\n", + "\n", + " def _backpropagate(self, X, t, lam):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Performs the backpropagation algorithm. In other words, this method\n", + " calculates the gradient of all the layers starting at the\n", + " output layer, and moving from right to left accumulates the gradient until\n", + " the input layer is reached. Each layers respective weights are updated while\n", + " the algorithm propagates backwards from the output layer (auto-differentation in reverse mode).\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each.\n", + " II t (np.ndarray): The target vector, with n rows of p targets.\n", + " III lam (float32): regularization parameter used to punish the weights in case of overfitting\n", + "\n", + " Returns:\n", + " ------------\n", + " No return value.\n", + "\n", + " \"\"\"\n", + " out_derivative = derivate(self.output_func)\n", + " hidden_derivative = derivate(self.hidden_func)\n", + "\n", + " for i in range(len(self.weights) - 1, -1, -1):\n", + " # delta terms for output\n", + " if i == len(self.weights) - 1:\n", + " # for multi-class classification\n", + " if (\n", + " self.output_func.__name__ == \"softmax\"\n", + " ):\n", + " delta_matrix = self.a_matrices[i + 1] - t\n", + " # for single class classification\n", + " else:\n", + " cost_func_derivative = grad(self.cost_func(t))\n", + " delta_matrix = out_derivative(\n", + " self.z_matrices[i + 1]\n", + " ) * cost_func_derivative(self.a_matrices[i + 1])\n", + "\n", + " # delta terms for hidden layer\n", + " else:\n", + " delta_matrix = (\n", + " self.weights[i + 1][1:, :] @ delta_matrix.T\n", + " ).T * hidden_derivative(self.z_matrices[i + 1])\n", + "\n", + " # calculate gradient\n", + " gradient_weights = self.a_matrices[i][:, 1:].T @ delta_matrix\n", + " gradient_bias = np.sum(delta_matrix, axis=0).reshape(\n", + " 1, delta_matrix.shape[1]\n", + " )\n", + "\n", + " # regularization term\n", + " gradient_weights += self.weights[i][1:, :] * lam\n", + "\n", + " # use scheduler\n", + " update_matrix = np.vstack(\n", + " [\n", + " self.schedulers_bias[i].update_change(gradient_bias),\n", + " self.schedulers_weight[i].update_change(gradient_weights),\n", + " ]\n", + " )\n", + "\n", + " # update weights and bias\n", + " self.weights[i] -= update_matrix\n", + "\n", + " def _accuracy(self, prediction: np.ndarray, target: np.ndarray):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Calculates accuracy of given prediction to target\n", + "\n", + " Parameters:\n", + " ------------\n", + " I prediction (np.ndarray): vector of predicitons output network\n", + " (1s and 0s in case of classification, and real numbers in case of regression)\n", + " II target (np.ndarray): vector of true values (What the network ideally should predict)\n", + "\n", + " Returns:\n", + " ------------\n", + " A floating point number representing the percentage of correctly classified instances.\n", + " \"\"\"\n", + " assert prediction.size == target.size\n", + " return np.average((target == prediction))\n", + " def _set_classification(self):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Decides if FFNN acts as classifier (True) og regressor (False),\n", + " sets self.classification during init()\n", + " \"\"\"\n", + " self.classification = False\n", + " if (\n", + " self.cost_func.__name__ == \"CostLogReg\"\n", + " or self.cost_func.__name__ == \"CostCrossEntropy\"\n", + " ):\n", + " self.classification = True\n", + "\n", + " def _progress_bar(self, progression, **kwargs):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Displays progress of training\n", + " \"\"\"\n", + " print_length = 40\n", + " num_equals = int(progression * print_length)\n", + " num_not = print_length - num_equals\n", + " arrow = \">\" if num_equals > 0 else \"\"\n", + " bar = \"[\" + \"=\" * (num_equals - 1) + arrow + \"-\" * num_not + \"]\"\n", + " perc_print = self._format(progression * 100, decimals=5)\n", + " line = f\" {bar} {perc_print}% \"\n", + "\n", + " for key in kwargs:\n", + " if not np.isnan(kwargs[key]):\n", + " value = self._format(kwargs[key], decimals=4)\n", + " line += f\"| {key}: {value} \"\n", + " sys.stdout.write(\"\\r\" + line)\n", + " sys.stdout.flush()\n", + " return len(line)\n", + "\n", + " def _format(self, value, decimals=4):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Formats decimal numbers for progress bar\n", + " \"\"\"\n", + " if value > 0:\n", + " v = value\n", + " elif value < 0:\n", + " v = -10 * value\n", + " else:\n", + " v = 1\n", + " n = 1 + math.floor(math.log10(v))\n", + " if n >= decimals - 1:\n", + " return str(round(value))\n", + " return f\"{value:.{decimals-n-1}f}\"" + ] + }, + { + "cell_type": "markdown", + "id": "2bd145b9", + "metadata": { + "editable": true + }, + "source": [ + "Before we make a model, we will quickly generate a dataset we can use\n", + "for our linear regression problem as shown below" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "c7f3d7ad", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from sklearn.model_selection import train_test_split\n", + "\n", + "def SkrankeFunction(x, y):\n", + " return np.ravel(0 + 1*x + 2*y + 3*x**2 + 4*x*y + 5*y**2)\n", + "\n", + "def create_X(x, y, n):\n", + " if len(x.shape) > 1:\n", + " x = np.ravel(x)\n", + " y = np.ravel(y)\n", + "\n", + " N = len(x)\n", + " l = int((n + 1) * (n + 2) / 2) # Number of elements in beta\n", + " X = np.ones((N, l))\n", + "\n", + " for i in range(1, n + 1):\n", + " q = int((i) * (i + 1) / 2)\n", + " for k in range(i + 1):\n", + " X[:, q + k] = (x ** (i - k)) * (y**k)\n", + "\n", + " return X\n", + "\n", + "step=0.5\n", + "x = np.arange(0, 1, step)\n", + "y = np.arange(0, 1, step)\n", + "x, y = np.meshgrid(x, y)\n", + "target = SkrankeFunction(x, y)\n", + "target = target.reshape(target.shape[0], 1)\n", + "\n", + "poly_degree=3\n", + "X = create_X(x, y, poly_degree)\n", + "\n", + "X_train, X_test, t_train, t_test = train_test_split(X, target)" + ] + }, + { + "cell_type": "markdown", + "id": "312deebb", + "metadata": { + "editable": true + }, + "source": [ + "Now that we have our dataset ready for the regression, we can create\n", + "our regressor. Note that with the seed parameter, we can make sure our\n", + "results stay the same every time we run the neural network. For\n", + "inititialization, we simply specify the dimensions (we wish the amount\n", + "of input nodes to be equal to the datapoints, and the output to\n", + "predict one value)." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "9c4f1717", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "output_nodes = 1\n", + "\n", + "linear_regression = FFNN((input_nodes, output_nodes), output_func=identity, cost_func=CostOLS, seed=2023)" + ] + }, + { + "cell_type": "markdown", + "id": "825279d3", + "metadata": { + "editable": true + }, + "source": [ + "We then fit our model with our training data using the scheduler of our choice." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "e6133768", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Constant(eta=1e-3)\n", + "scores = linear_regression.fit(X_train, t_train, scheduler)" + ] + }, + { + "cell_type": "markdown", + "id": "d561f849", + "metadata": { + "editable": true + }, + "source": [ + "Due to the progress bar we can see the MSE (train_error) throughout\n", + "the FFNN's training. Note that the fit() function has some optional\n", + "parameters with defualt arguments. For example, the regularization\n", + "hyperparameter can be left ignored if not needed, and equally the FFNN\n", + "will by default run for 100 epochs. These can easily be changed, such\n", + "as for example:" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "22a52980", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scores = linear_regression.fit(X_train, t_train, scheduler, lam=1e-4, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "e0dba967", + "metadata": { + "editable": true + }, + "source": [ + "We see that given more epochs to train on, the regressor reaches a lower MSE.\n", + "\n", + "Let us then switch to a binary classification. We use a binary\n", + "classification dataset, and follow a similar setup to the regression\n", + "case." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "d05f8035", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_breast_cancer\n", + "from sklearn.preprocessing import MinMaxScaler\n", + "\n", + "wisconsin = load_breast_cancer()\n", + "X = wisconsin.data\n", + "target = wisconsin.target\n", + "target = target.reshape(target.shape[0], 1)\n", + "\n", + "X_train, X_val, t_train, t_val = train_test_split(X, target)\n", + "\n", + "scaler = MinMaxScaler()\n", + "scaler.fit(X_train)\n", + "X_train = scaler.transform(X_train)\n", + "X_val = scaler.transform(X_val)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "dc7b7fec", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "output_nodes = 1\n", + "\n", + "logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023)" + ] + }, + { + "cell_type": "markdown", + "id": "7bfd050a", + "metadata": { + "editable": true + }, + "source": [ + "We will now make use of our validation data by passing it into our fit function as a keyword argument" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "02b08ed6", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999)\n", + "scores = logistic_regression.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val)" + ] + }, + { + "cell_type": "markdown", + "id": "59b85b1b", + "metadata": { + "editable": true + }, + "source": [ + "Finally, we will create a neural network with 2 hidden layers with activation functions." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "eebfa498", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "hidden_nodes1 = 100\n", + "hidden_nodes2 = 30\n", + "output_nodes = 1\n", + "\n", + "dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes)\n", + "\n", + "neural_network = FFNN(dims, hidden_func=RELU, output_func=sigmoid, cost_func=CostLogReg, seed=2023)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "cabc2b09", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "neural_network.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999)\n", + "scores = neural_network.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val)" + ] + }, + { + "cell_type": "markdown", + "id": "37d5b7bb", + "metadata": { + "editable": true + }, + "source": [ + "### Multiclass classification\n", + "\n", + "Finally, we will demonstrate the use case of multiclass classification\n", + "using our FFNN with the famous MNIST dataset, which contain images of\n", + "digits between the range of 0 to 9." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "ffc6fca1", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_digits\n", + "\n", + "def onehot(target: np.ndarray):\n", + " onehot = np.zeros((target.size, target.max() + 1))\n", + " onehot[np.arange(target.size), target] = 1\n", + " return onehot\n", + "\n", + "digits = load_digits()\n", + "\n", + "X = digits.data\n", + "target = digits.target\n", + "target = onehot(target)\n", + "\n", + "input_nodes = 64\n", + "hidden_nodes1 = 100\n", + "hidden_nodes2 = 30\n", + "output_nodes = 10\n", + "\n", + "dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes)\n", + "\n", + "multiclass = FFNN(dims, hidden_func=LRELU, output_func=softmax, cost_func=CostCrossEntropy)\n", + "\n", + "multiclass.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999)\n", + "scores = multiclass.fit(X, target, scheduler, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "cc530309", + "metadata": { + "editable": true + }, + "source": [ + "## Testing the XOR gate and other gates\n", + "\n", + "Let us now use our code to test the XOR gate." + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "0d61131c", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64)\n", + "\n", + "# The XOR gate\n", + "yXOR = np.array( [[ 0], [1] ,[1], [0]])\n", + "\n", + "input_nodes = X.shape[1]\n", + "output_nodes = 1\n", + "\n", + "logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023)\n", + "logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "scheduler = Adam(eta=1e-1, rho=0.9, rho2=0.999)\n", + "scores = logistic_regression.fit(X, yXOR, scheduler, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "ce4ce787", + "metadata": { + "editable": true + }, + "source": [ + "Not bad, but the results depend strongly on the learning reate. Try different learning rates." + ] + }, + { + "cell_type": "markdown", + "id": "e5d7a6ab", + "metadata": { + "editable": true + }, + "source": [ + "## Solving differential equations with Deep Learning\n", + "\n", + "The Universal Approximation Theorem states that a neural network can\n", + "approximate any function at a single hidden layer along with one input\n", + "and output layer to any given precision.\n", + "\n", + "**Book on solving differential equations with ML methods.**\n", + "\n", + "[An Introduction to Neural Network Methods for Differential Equations](https://www.springer.com/gp/book/9789401798150), by Yadav and Kumar.\n", + "\n", + "**Physics informed neural networks.**\n", + "\n", + "[Scientific Machine Learning Through Physics–Informed Neural Networks: Where we are and What’s Next](https://link.springer.com/article/10.1007/s10915-022-01939-z), by Cuomo et al\n", + "\n", + "**Thanks to Kristine Baluka Hein.**\n", + "\n", + "The lectures on differential equations were developed by Kristine Baluka Hein, now PhD student at IFI.\n", + "A great thanks to Kristine." + ] + }, + { + "cell_type": "markdown", + "id": "56b23083", + "metadata": { + "editable": true + }, + "source": [ + "## Ordinary Differential Equations first\n", + "\n", + "An ordinary differential equation (ODE) is an equation involving functions having one variable.\n", + "\n", + "In general, an ordinary differential equation looks like" + ] + }, + { + "cell_type": "markdown", + "id": "3f9d87d4", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "

    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{ode} \\tag{1}\n", + "f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right) = 0\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ff7d3133", + "metadata": { + "editable": true + }, + "source": [ + "where $g(x)$ is the function to find, and $g^{(n)}(x)$ is the $n$-th derivative of $g(x)$.\n", + "\n", + "The $f\\left(x, g(x), g'(x), g''(x), \\, \\dots \\, , g^{(n)}(x)\\right)$ is just a way to write that there is an expression involving $x$ and $g(x), \\ g'(x), \\ g''(x), \\, \\dots \\, , \\text{ and } g^{(n)}(x)$ on the left side of the equality sign in ([1](#ode)).\n", + "The highest order of derivative, that is the value of $n$, determines to the order of the equation.\n", + "The equation is referred to as a $n$-th order ODE.\n", + "Along with ([1](#ode)), some additional conditions of the function $g(x)$ are typically given\n", + "for the solution to be unique." + ] + }, + { + "cell_type": "markdown", + "id": "f387989d", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "\n", + "Let the trial solution $g_t(x)$ be" + ] + }, + { + "cell_type": "markdown", + "id": "d15b7ed8", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation}\n", + "\tg_t(x) = h_1(x) + h_2(x,N(x,P))\n", + "\\label{_auto1} \\tag{2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "8b0ad0fb", + "metadata": { + "editable": true + }, + "source": [ + "where $h_1(x)$ is a function that makes $g_t(x)$ satisfy a given set\n", + "of conditions, $N(x,P)$ a neural network with weights and biases\n", + "described by $P$ and $h_2(x, N(x,P))$ some expression involving the\n", + "neural network. The role of the function $h_2(x, N(x,P))$, is to\n", + "ensure that the output from $N(x,P)$ is zero when $g_t(x)$ is\n", + "evaluated at the values of $x$ where the given conditions must be\n", + "satisfied. The function $h_1(x)$ should alone make $g_t(x)$ satisfy\n", + "the conditions.\n", + "\n", + "But what about the network $N(x,P)$?\n", + "\n", + "As described previously, an optimization method could be used to minimize the parameters of a neural network, that being its weights and biases, through backward propagation." + ] + }, + { + "cell_type": "markdown", + "id": "c33b7fca", + "metadata": { + "editable": true + }, + "source": [ + "## Minimization process\n", + "\n", + "For the minimization to be defined, we need to have a cost function at hand to minimize.\n", + "\n", + "It is given that $f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right)$ should be equal to zero in ([1](#ode)).\n", + "We can choose to consider the mean squared error as the cost function for an input $x$.\n", + "Since we are looking at one input, the cost function is just $f$ squared.\n", + "The cost function $c\\left(x, P \\right)$ can therefore be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "d88cb1c8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(x, P\\right) = \\big(f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right)\\big)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "13593649", + "metadata": { + "editable": true + }, + "source": [ + "If $N$ inputs are given as a vector $\\boldsymbol{x}$ with elements $x_i$ for $i = 1,\\dots,N$,\n", + "the cost function becomes" + ] + }, + { + "cell_type": "markdown", + "id": "a5e615d0", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{cost} \\tag{3}\n", + "\tC\\left(\\boldsymbol{x}, P\\right) = \\frac{1}{N} \\sum_{i=1}^N \\big(f\\left(x_i, \\, g(x_i), \\, g'(x_i), \\, g''(x_i), \\, \\dots \\, , \\, g^{(n)}(x_i)\\right)\\big)^2\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "952778b9", + "metadata": { + "editable": true + }, + "source": [ + "The neural net should then find the parameters $P$ that minimizes the cost function in\n", + "([3](#cost)) for a set of $N$ training samples $x_i$." + ] + }, + { + "cell_type": "markdown", + "id": "63c41a29", + "metadata": { + "editable": true + }, + "source": [ + "## Minimizing the cost function using gradient descent and automatic differentiation\n", + "\n", + "To perform the minimization using gradient descent, the gradient of $C\\left(\\boldsymbol{x}, P\\right)$ is needed.\n", + "It might happen so that finding an analytical expression of the gradient of $C(\\boldsymbol{x}, P)$ from ([3](#cost)) gets too messy, depending on which cost function one desires to use.\n", + "\n", + "Luckily, there exists libraries that makes the job for us through automatic differentiation.\n", + "Automatic differentiation is a method of finding the derivatives numerically with very high precision." + ] + }, + { + "cell_type": "markdown", + "id": "95ebdbc4", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Exponential decay\n", + "\n", + "An exponential decay of a quantity $g(x)$ is described by the equation" + ] + }, + { + "cell_type": "markdown", + "id": "48862a28", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solve_expdec} \\tag{4}\n", + " g'(x) = -\\gamma g(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "98174490", + "metadata": { + "editable": true + }, + "source": [ + "with $g(0) = g_0$ for some chosen initial value $g_0$.\n", + "\n", + "The analytical solution of ([4](#solve_expdec)) is" + ] + }, + { + "cell_type": "markdown", + "id": "f3d8ced5", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " g(x) = g_0 \\exp\\left(-\\gamma x\\right)\n", + "\\label{_auto2} \\tag{5}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0cdbddeb", + "metadata": { + "editable": true + }, + "source": [ + "Having an analytical solution at hand, it is possible to use it to compare how well a neural network finds a solution of ([4](#solve_expdec))." + ] + }, + { + "cell_type": "markdown", + "id": "8afed5da", + "metadata": { + "editable": true + }, + "source": [ + "## The function to solve for\n", + "\n", + "The program will use a neural network to solve" + ] + }, + { + "cell_type": "markdown", + "id": "b6cdd16d", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solveode} \\tag{6}\n", + "g'(x) = -\\gamma g(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "9423bac1", + "metadata": { + "editable": true + }, + "source": [ + "where $g(0) = g_0$ with $\\gamma$ and $g_0$ being some chosen values.\n", + "\n", + "In this example, $\\gamma = 2$ and $g_0 = 10$." + ] + }, + { + "cell_type": "markdown", + "id": "e3ddd331", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "To begin with, a trial solution $g_t(t)$ must be chosen. A general trial solution for ordinary differential equations could be" + ] + }, + { + "cell_type": "markdown", + "id": "41278f19", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x, P) = h_1(x) + h_2(x, N(x, P))\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "8d0ce198", + "metadata": { + "editable": true + }, + "source": [ + "with $h_1(x)$ ensuring that $g_t(x)$ satisfies some conditions and $h_2(x,N(x, P))$ an expression involving $x$ and the output from the neural network $N(x,P)$ with $P $ being the collection of the weights and biases for each layer. For now, it is assumed that the network consists of one input layer, one hidden layer, and one output layer." + ] + }, + { + "cell_type": "markdown", + "id": "dc70817c", + "metadata": { + "editable": true + }, + "source": [ + "## Setup of Network\n", + "\n", + "In this network, there are no weights and bias at the input layer, so $P = \\{ P_{\\text{hidden}}, P_{\\text{output}} \\}$.\n", + "If there are $N_{\\text{hidden} }$ neurons in the hidden layer, then $P_{\\text{hidden}}$ is a $N_{\\text{hidden} } \\times (1 + N_{\\text{input}})$ matrix, given that there are $N_{\\text{input}}$ neurons in the input layer.\n", + "\n", + "The first column in $P_{\\text{hidden} }$ represents the bias for each neuron in the hidden layer and the second column represents the weights for each neuron in the hidden layer from the input layer.\n", + "If there are $N_{\\text{output} }$ neurons in the output layer, then $P_{\\text{output}} $ is a $N_{\\text{output} } \\times (1 + N_{\\text{hidden} })$ matrix.\n", + "\n", + "Its first column represents the bias of each neuron and the remaining columns represents the weights to each neuron.\n", + "\n", + "It is given that $g(0) = g_0$. The trial solution must fulfill this condition to be a proper solution of ([6](#solveode)). A possible way to ensure that $g_t(0, P) = g_0$, is to let $F(N(x,P)) = x \\cdot N(x,P)$ and $A(x) = g_0$. This gives the following trial solution:" + ] + }, + { + "cell_type": "markdown", + "id": "8c2e8dde", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{trial} \\tag{7}\n", + "g_t(x, P) = g_0 + x \\cdot N(x, P)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5ad2bff5", + "metadata": { + "editable": true + }, + "source": [ + "## Reformulating the problem\n", + "\n", + "We wish that our neural network manages to minimize a given cost function.\n", + "\n", + "A reformulation of out equation, ([6](#solveode)), must therefore be done,\n", + "such that it describes the problem a neural network can solve for.\n", + "\n", + "The neural network must find the set of weights and biases $P$ such that the trial solution in ([7](#trial)) satisfies ([6](#solveode)).\n", + "\n", + "The trial solution" + ] + }, + { + "cell_type": "markdown", + "id": "5f845ba6", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x, P) = g_0 + x \\cdot N(x, P)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2604055d", + "metadata": { + "editable": true + }, + "source": [ + "has been chosen such that it already solves the condition $g(0) = g_0$. What remains, is to find $P$ such that" + ] + }, + { + "cell_type": "markdown", + "id": "b4ba9669", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{nnmin} \\tag{8}\n", + "g_t'(x, P) = - \\gamma g_t(x, P)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "875686e8", + "metadata": { + "editable": true + }, + "source": [ + "is fulfilled as *best as possible*." + ] + }, + { + "cell_type": "markdown", + "id": "ee9f7d57", + "metadata": { + "editable": true + }, + "source": [ + "## More technicalities\n", + "\n", + "The left hand side and right hand side of ([8](#nnmin)) must be computed separately, and then the neural network must choose weights and biases, contained in $P$, such that the sides are equal as best as possible.\n", + "This means that the absolute or squared difference between the sides must be as close to zero, ideally equal to zero.\n", + "In this case, the difference squared shows to be an appropriate measurement of how erroneous the trial solution is with respect to $P$ of the neural network.\n", + "\n", + "This gives the following cost function our neural network must solve for:" + ] + }, + { + "cell_type": "markdown", + "id": "1e370697", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P}\\Big\\{ \\big(g_t'(x, P) - ( -\\gamma g_t(x, P) \\big)^2 \\Big\\}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "833f3b82", + "metadata": { + "editable": true + }, + "source": [ + "(the notation $\\min_{P}\\{ f(x, P) \\}$ means that we desire to find $P$ that yields the minimum of $f(x, P)$)\n", + "\n", + "or, in terms of weights and biases for the hidden and output layer in our network:" + ] + }, + { + "cell_type": "markdown", + "id": "35da5498", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P_{\\text{hidden} }, \\ P_{\\text{output} }}\\Big\\{ \\big(g_t'(x, \\{ P_{\\text{hidden} }, P_{\\text{output} }\\}) - ( -\\gamma g_t(x, \\{ P_{\\text{hidden} }, P_{\\text{output} }\\}) \\big)^2 \\Big\\}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b44a64f2", + "metadata": { + "editable": true + }, + "source": [ + "for an input value $x$." + ] + }, + { + "cell_type": "markdown", + "id": "116b1937", + "metadata": { + "editable": true + }, + "source": [ + "## More details\n", + "\n", + "If the neural network evaluates $g_t(x, P)$ at more values for $x$, say $N$ values $x_i$ for $i = 1, \\dots, N$, then the *total* error to minimize becomes" + ] + }, + { + "cell_type": "markdown", + "id": "9ef6d929", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{min} \\tag{9}\n", + "\\min_{P}\\Big\\{\\frac{1}{N} \\sum_{i=1}^N \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2 \\Big\\}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bd901882", + "metadata": { + "editable": true + }, + "source": [ + "Letting $\\boldsymbol{x}$ be a vector with elements $x_i$ and $C(\\boldsymbol{x}, P) = \\frac{1}{N} \\sum_i \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2$ denote the cost function, the minimization problem that our network must solve, becomes" + ] + }, + { + "cell_type": "markdown", + "id": "31348d62", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P} C(\\boldsymbol{x}, P)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ae4a794d", + "metadata": { + "editable": true + }, + "source": [ + "In terms of $P_{\\text{hidden} }$ and $P_{\\text{output} }$, this could also be expressed as\n", + "\n", + "$$\n", + "\\min_{P_{\\text{hidden} }, \\ P_{\\text{output} }} C(\\boldsymbol{x}, \\{P_{\\text{hidden} }, P_{\\text{output} }\\})\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "a4ca4b65", + "metadata": { + "editable": true + }, + "source": [ + "## A possible implementation of a neural network\n", + "\n", + "For simplicity, it is assumed that the input is an array $\\boldsymbol{x} = (x_1, \\dots, x_N)$ with $N$ elements. It is at these points the neural network should find $P$ such that it fulfills ([9](#min)).\n", + "\n", + "First, the neural network must feed forward the inputs.\n", + "This means that $\\boldsymbol{x}s$ must be passed through an input layer, a hidden layer and a output layer. The input layer in this case, does not need to process the data any further.\n", + "The input layer will consist of $N_{\\text{input} }$ neurons, passing its element to each neuron in the hidden layer. The number of neurons in the hidden layer will be $N_{\\text{hidden} }$." + ] + }, + { + "cell_type": "markdown", + "id": "6cd19213", + "metadata": { + "editable": true + }, + "source": [ + "## Technicalities\n", + "\n", + "For the $i$-th in the hidden layer with weight $w_i^{\\text{hidden} }$ and bias $b_i^{\\text{hidden} }$, the weighting from the $j$-th neuron at the input layer is:" + ] + }, + { + "cell_type": "markdown", + "id": "e6d9fb88", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "z_{i,j}^{\\text{hidden}} &= b_i^{\\text{hidden}} + w_i^{\\text{hidden}}x_j \\\\\n", + "&=\n", + "\\begin{pmatrix}\n", + "b_i^{\\text{hidden}} & w_i^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 \\\\\n", + "x_j\n", + "\\end{pmatrix}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2b7229da", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities I\n", + "\n", + "The result after weighting the inputs at the $i$-th hidden neuron can be written as a vector:" + ] + }, + { + "cell_type": "markdown", + "id": "cd4f193b", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "\\boldsymbol{z}_{i}^{\\text{hidden}} &= \\Big( b_i^{\\text{hidden}} + w_i^{\\text{hidden}}x_1 , \\ b_i^{\\text{hidden}} + w_i^{\\text{hidden}} x_2, \\ \\dots \\, , \\ b_i^{\\text{hidden}} + w_i^{\\text{hidden}} x_N\\Big) \\\\\n", + "&=\n", + "\\begin{pmatrix}\n", + " b_i^{\\text{hidden}} & w_i^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 & 1 & \\dots & 1 \\\\\n", + "x_1 & x_2 & \\dots & x_N\n", + "\\end{pmatrix} \\\\\n", + "&= \\boldsymbol{p}_{i, \\text{hidden}}^T X\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e475f927", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities II\n", + "\n", + "The vector $\\boldsymbol{p}_{i, \\text{hidden}}^T$ constitutes each row in $P_{\\text{hidden} }$, which contains the weights for the neural network to minimize according to ([9](#min)).\n", + "\n", + "After having found $\\boldsymbol{z}_{i}^{\\text{hidden}} $ for every $i$-th neuron within the hidden layer, the vector will be sent to an activation function $a_i(\\boldsymbol{z})$.\n", + "\n", + "In this example, the sigmoid function has been chosen to be the activation function for each hidden neuron:" + ] + }, + { + "cell_type": "markdown", + "id": "95a91bdd", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f(z) = \\frac{1}{1 + \\exp{(-z)}}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "56c75c71", + "metadata": { + "editable": true + }, + "source": [ + "It is possible to use other activations functions for the hidden layer also.\n", + "\n", + "The output $\\boldsymbol{x}_i^{\\text{hidden}}$ from each $i$-th hidden neuron is:\n", + "\n", + "$$\n", + "\\boldsymbol{x}_i^{\\text{hidden} } = f\\big( \\boldsymbol{z}_{i}^{\\text{hidden}} \\big)\n", + "$$\n", + "\n", + "The outputs $\\boldsymbol{x}_i^{\\text{hidden} } $ are then sent to the output layer.\n", + "\n", + "The output layer consists of one neuron in this case, and combines the\n", + "output from each of the neurons in the hidden layers. The output layer\n", + "combines the results from the hidden layer using some weights $w_i^{\\text{output}}$\n", + "and biases $b_i^{\\text{output}}$. In this case,\n", + "it is assumes that the number of neurons in the output layer is one." + ] + }, + { + "cell_type": "markdown", + "id": "0cc6d1a9", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities III\n", + "\n", + "The procedure of weighting the output neuron $j$ in the hidden layer to the $i$-th neuron in the output layer is similar as for the hidden layer described previously." + ] + }, + { + "cell_type": "markdown", + "id": "0175da6a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "z_{1,j}^{\\text{output}} & =\n", + "\\begin{pmatrix}\n", + "b_1^{\\text{output}} & \\boldsymbol{w}_1^{\\text{output}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 \\\\\n", + "\\boldsymbol{x}_j^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5fe7bc0e", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities IV\n", + "\n", + "Expressing $z_{1,j}^{\\text{output}}$ as a vector gives the following way of weighting the inputs from the hidden layer:" + ] + }, + { + "cell_type": "markdown", + "id": "7f0577a4", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\boldsymbol{z}_{1}^{\\text{output}} =\n", + "\\begin{pmatrix}\n", + "b_1^{\\text{output}} & \\boldsymbol{w}_1^{\\text{output}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 & 1 & \\dots & 1 \\\\\n", + "\\boldsymbol{x}_1^{\\text{hidden}} & \\boldsymbol{x}_2^{\\text{hidden}} & \\dots & \\boldsymbol{x}_N^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "11c8c142", + "metadata": { + "editable": true + }, + "source": [ + "In this case we seek a continuous range of values since we are approximating a function. This means that after computing $\\boldsymbol{z}_{1}^{\\text{output}}$ the neural network has finished its feed forward step, and $\\boldsymbol{z}_{1}^{\\text{output}}$ is the final output of the network." + ] + }, + { + "cell_type": "markdown", + "id": "01ca4d08", + "metadata": { + "editable": true + }, + "source": [ + "## Back propagation\n", + "\n", + "The next step is to decide how the parameters should be changed such that they minimize the cost function.\n", + "\n", + "The chosen cost function for this problem is" + ] + }, + { + "cell_type": "markdown", + "id": "f5133d80", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C(\\boldsymbol{x}, P) = \\frac{1}{N} \\sum_i \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c1e40110", + "metadata": { + "editable": true + }, + "source": [ + "In order to minimize the cost function, an optimization method must be chosen.\n", + "\n", + "Here, gradient descent with a constant step size has been chosen." + ] + }, + { + "cell_type": "markdown", + "id": "89f577fa", + "metadata": { + "editable": true + }, + "source": [ + "## Gradient descent\n", + "\n", + "The idea of the gradient descent algorithm is to update parameters in\n", + "a direction where the cost function decreases goes to a minimum.\n", + "\n", + "In general, the update of some parameters $\\boldsymbol{\\omega}$ given a cost\n", + "function defined by some weights $\\boldsymbol{\\omega}$, $C(\\boldsymbol{x},\n", + "\\boldsymbol{\\omega})$, goes as follows:" + ] + }, + { + "cell_type": "markdown", + "id": "73db81fc", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\boldsymbol{\\omega}_{\\text{new} } = \\boldsymbol{\\omega} - \\lambda \\nabla_{\\boldsymbol{\\omega}} C(\\boldsymbol{x}, \\boldsymbol{\\omega})\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "6956b9f1", + "metadata": { + "editable": true + }, + "source": [ + "for a number of iterations or until $ \\big|\\big| \\boldsymbol{\\omega}_{\\text{new} } - \\boldsymbol{\\omega} \\big|\\big|$ becomes smaller than some given tolerance.\n", + "\n", + "The value of $\\lambda$ decides how large steps the algorithm must take\n", + "in the direction of $ \\nabla_{\\boldsymbol{\\omega}} C(\\boldsymbol{x}, \\boldsymbol{\\omega})$.\n", + "The notation $\\nabla_{\\boldsymbol{\\omega}}$ express the gradient with respect\n", + "to the elements in $\\boldsymbol{\\omega}$.\n", + "\n", + "In our case, we have to minimize the cost function $C(\\boldsymbol{x}, P)$ with\n", + "respect to the two sets of weights and biases, that is for the hidden\n", + "layer $P_{\\text{hidden} }$ and for the output layer $P_{\\text{output}\n", + "}$ .\n", + "\n", + "This means that $P_{\\text{hidden} }$ and $P_{\\text{output} }$ is updated by" + ] + }, + { + "cell_type": "markdown", + "id": "13e5d04c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "P_{\\text{hidden},\\text{new}} &= P_{\\text{hidden}} - \\lambda \\nabla_{P_{\\text{hidden}}} C(\\boldsymbol{x}, P) \\\\\n", + "P_{\\text{output},\\text{new}} &= P_{\\text{output}} - \\lambda \\nabla_{P_{\\text{output}}} C(\\boldsymbol{x}, P)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "dd560ef7", + "metadata": { + "editable": true + }, + "source": [ + "## The code for solving the ODE" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "ac42510c", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# Assuming one input, hidden, and output layer\n", + "def neural_network(params, x):\n", + "\n", + " # Find the weights (including and biases) for the hidden and output layer.\n", + " # Assume that params is a list of parameters for each layer.\n", + " # The biases are the first element for each array in params,\n", + " # and the weights are the remaning elements in each array in params.\n", + "\n", + " w_hidden = params[0]\n", + " w_output = params[1]\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " ## Hidden layer:\n", + "\n", + " # Add a row of ones to include bias\n", + " x_input = np.concatenate((np.ones((1,num_values)), x_input ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_input)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " ## Output layer:\n", + "\n", + " # Include bias:\n", + " x_hidden = np.concatenate((np.ones((1,num_values)), x_hidden ), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_hidden)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial(x,params, g0 = 10):\n", + " return g0 + x*neural_network(params,x)\n", + "\n", + "# The right side of the ODE:\n", + "def g(x, g_trial, gamma = 2):\n", + " return -gamma*g_trial\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the neural network\n", + " d_net_out = elementwise_grad(neural_network,1)(P,x)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = g(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# Solve the exponential decay ODE using neural network with one input, hidden, and output layer\n", + "def solve_ode_neural_network(x, num_neurons_hidden, num_iter, lmb):\n", + " ## Set up initial weights and biases\n", + "\n", + " # For the hidden layer\n", + " p0 = npr.randn(num_neurons_hidden, 2 )\n", + "\n", + " # For the output layer\n", + " p1 = npr.randn(1, num_neurons_hidden + 1 ) # +1 since bias is included\n", + "\n", + " P = [p0, p1]\n", + "\n", + " print('Initial cost: %g'%cost_function(P, x))\n", + "\n", + " ## Start finding the optimal weights using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of two arrays;\n", + " # one for the gradient w.r.t P_hidden and\n", + " # one for the gradient w.r.t P_output\n", + " cost_grad = cost_function_grad(P, x)\n", + "\n", + " P[0] = P[0] - lmb * cost_grad[0]\n", + " P[1] = P[1] - lmb * cost_grad[1]\n", + "\n", + " print('Final cost: %g'%cost_function(P, x))\n", + "\n", + " return P\n", + "\n", + "def g_analytic(x, gamma = 2, g0 = 10):\n", + " return g0*np.exp(-gamma*x)\n", + "\n", + "# Solve the given problem\n", + "if __name__ == '__main__':\n", + " # Set seed such that the weight are initialized\n", + " # with same weights and biases for every run.\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " N = 10\n", + " x = np.linspace(0, 1, N)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = 10\n", + " num_iter = 10000\n", + " lmb = 0.001\n", + "\n", + " # Use the network\n", + " P = solve_ode_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " # Print the deviation from the trial solution and true solution\n", + " res = g_trial(x,P)\n", + " res_analytical = g_analytic(x)\n", + "\n", + " print('Max absolute difference: %g'%np.max(np.abs(res - res_analytical)))\n", + "\n", + " # Plot the results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, res_analytical)\n", + " plt.plot(x, res[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "22aed435", + "metadata": { + "editable": true + }, + "source": [ + "## The network with one input layer, specified number of hidden layers, and one output layer\n", + "\n", + "It is also possible to extend the construction of our network into a more general one, allowing the network to contain more than one hidden layers.\n", + "\n", + "The number of neurons within each hidden layer are given as a list of integers in the program below." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "96179484", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# The neural network with one input layer and one output layer,\n", + "# but with number of hidden layers specified by the user.\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial_deep(x,params, g0 = 10):\n", + " return g0 + x*deep_neural_network(params, x)\n", + "\n", + "# The right side of the ODE:\n", + "def g(x, g_trial, gamma = 2):\n", + " return -gamma*g_trial\n", + "\n", + "# The same cost function as before, but calls deep_neural_network instead.\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the neural network\n", + " d_net_out = elementwise_grad(deep_neural_network,1)(P,x)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial_deep,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = g(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# Solve the exponential decay ODE using neural network with one input and one output layer,\n", + "# but with specified number of hidden layers from the user.\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # The number of elements in the list num_hidden_neurons thus represents\n", + " # the number of hidden layers.\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weights and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weights using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "def g_analytic(x, gamma = 2, g0 = 10):\n", + " return g0*np.exp(-gamma*x)\n", + "\n", + "# Solve the given problem\n", + "if __name__ == '__main__':\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " N = 10\n", + " x = np.linspace(0, 1, N)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = np.array([10,10])\n", + " num_iter = 10000\n", + " lmb = 0.001\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " res = g_trial_deep(x,P)\n", + " res_analytical = g_analytic(x)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of a deep neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, res_analytical)\n", + " plt.plot(x, res[0,:])\n", + " plt.legend(['analytical','dnn'])\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "a0ff62a9", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Population growth\n", + "\n", + "A logistic model of population growth assumes that a population converges toward an equilibrium.\n", + "The population growth can be modeled by" + ] + }, + { + "cell_type": "markdown", + "id": "e9112c77", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{log} \\tag{10}\n", + "\tg'(t) = \\alpha g(t)(A - g(t))\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "cf582ad1", + "metadata": { + "editable": true + }, + "source": [ + "where $g(t)$ is the population density at time $t$, $\\alpha > 0$ the growth rate and $A > 0$ is the maximum population number in the environment.\n", + "Also, at $t = 0$ the population has the size $g(0) = g_0$, where $g_0$ is some chosen constant.\n", + "\n", + "In this example, similar network as for the exponential decay using Autograd has been used to solve the equation. However, as the implementation might suffer from e.g numerical instability\n", + "and high execution time (this might be more apparent in the examples solving PDEs),\n", + "using a library like TensorFlow is recommended.\n", + "Here, we stay with a more simple approach and implement for comparison, the simple forward Euler method." + ] + }, + { + "cell_type": "markdown", + "id": "d945a6b3", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the problem\n", + "\n", + "Here, we will model a population $g(t)$ in an environment having carrying capacity $A$.\n", + "The population follows the model" + ] + }, + { + "cell_type": "markdown", + "id": "e98cd638", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solveode_population} \\tag{11}\n", + "g'(t) = \\alpha g(t)(A - g(t))\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "8b5c6044", + "metadata": { + "editable": true + }, + "source": [ + "where $g(0) = g_0$.\n", + "\n", + "In this example, we let $\\alpha = 2$, $A = 1$, and $g_0 = 1.2$." + ] + }, + { + "cell_type": "markdown", + "id": "74c055d2", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "\n", + "We will get a slightly different trial solution, as the boundary conditions are different\n", + "compared to the case for exponential decay.\n", + "\n", + "A possible trial solution satisfying the condition $g(0) = g_0$ could be\n", + "\n", + "$$\n", + "h_1(t) = g_0 + t \\cdot N(t,P)\n", + "$$\n", + "\n", + "with $N(t,P)$ being the output from the neural network with weights and biases for each layer collected in the set $P$.\n", + "\n", + "The analytical solution is\n", + "\n", + "$$\n", + "g(t) = \\frac{Ag_0}{g_0 + (A - g_0)\\exp(-\\alpha A t)}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "a65e3069", + "metadata": { + "editable": true + }, + "source": [ + "## The program using Autograd\n", + "\n", + "The network will be the similar as for the exponential decay example, but with some small modifications for our problem." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "b092c21e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# Function to get the parameters.\n", + "# Done such that one can easily change the paramaters after one's liking.\n", + "def get_parameters():\n", + " alpha = 2\n", + " A = 1\n", + " g0 = 1.2\n", + " return alpha, A, g0\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial_deep,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = f(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# The right side of the ODE:\n", + "def f(x, g_trial):\n", + " alpha,A, g0 = get_parameters()\n", + " return alpha*g_trial*(A - g_trial)\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial_deep(x, params):\n", + " alpha,A, g0 = get_parameters()\n", + " return g0 + x*deep_neural_network(params,x)\n", + "\n", + "# The analytical solution:\n", + "def g_analytic(t):\n", + " alpha,A, g0 = get_parameters()\n", + " return A*g0/(g0 + (A - g0)*np.exp(-alpha*A*t))\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nt = 10\n", + " T = 1\n", + " t = np.linspace(0,T, Nt)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [100, 50, 25]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(t,P)\n", + " g_analytical = g_analytic(t)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " diff_ag = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%diff_ag)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(t, g_analytical)\n", + " plt.plot(t, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "1aa71f38", + "metadata": { + "editable": true + }, + "source": [ + "## Using forward Euler to solve the ODE\n", + "\n", + "A straightforward way of solving an ODE numerically, is to use Euler's method.\n", + "\n", + "Euler's method uses Taylor series to approximate the value at a function $f$ at a step $\\Delta x$ from $x$:\n", + "\n", + "$$\n", + "f(x + \\Delta x) \\approx f(x) + \\Delta x f'(x)\n", + "$$\n", + "\n", + "In our case, using Euler's method to approximate the value of $g$ at a step $\\Delta t$ from $t$ yields" + ] + }, + { + "cell_type": "markdown", + "id": "9d1de21f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + " g(t + \\Delta t) &\\approx g(t) + \\Delta t g'(t) \\\\\n", + " &= g(t) + \\Delta t \\big(\\alpha g(t)(A - g(t))\\big)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "826b08a1", + "metadata": { + "editable": true + }, + "source": [ + "along with the condition that $g(0) = g_0$.\n", + "\n", + "Let $t_i = i \\cdot \\Delta t$ where $\\Delta t = \\frac{T}{N_t-1}$ where $T$ is the final time our solver must solve for and $N_t$ the number of values for $t \\in [0, T]$ for $i = 0, \\dots, N_t-1$.\n", + "\n", + "For $i \\geq 1$, we have that" + ] + }, + { + "cell_type": "markdown", + "id": "c4493848", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "t_i &= i\\Delta t \\\\\n", + "&= (i - 1)\\Delta t + \\Delta t \\\\\n", + "&= t_{i-1} + \\Delta t\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e37b66c6", + "metadata": { + "editable": true + }, + "source": [ + "Now, if $g_i = g(t_i)$ then" + ] + }, + { + "cell_type": "markdown", + "id": "264abdcc", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\begin{aligned}\n", + " g_i &= g(t_i) \\\\\n", + " &= g(t_{i-1} + \\Delta t) \\\\\n", + " &\\approx g(t_{i-1}) + \\Delta t \\big(\\alpha g(t_{i-1})(A - g(t_{i-1}))\\big) \\\\\n", + " &= g_{i-1} + \\Delta t \\big(\\alpha g_{i-1}(A - g_{i-1})\\big)\n", + " \\end{aligned}\n", + "\\end{equation} \\label{odenum} \\tag{12}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "afc2e4cc", + "metadata": { + "editable": true + }, + "source": [ + "for $i \\geq 1$ and $g_0 = g(t_0) = g(0) = g_0$.\n", + "\n", + "Equation ([12](#odenum)) could be implemented in the following way,\n", + "extending the program that uses the network using Autograd:" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "63c572f6", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Assume that all function definitions from the example program using Autograd\n", + "# are located here.\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nt = 10\n", + " T = 1\n", + " t = np.linspace(0,T, Nt)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [100,50,25]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(t,P)\n", + " g_analytical = g_analytic(t)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " diff_ag = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%diff_ag)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(t, g_analytical)\n", + " plt.plot(t, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " ## Find an approximation to the funtion using forward Euler\n", + "\n", + " alpha, A, g0 = get_parameters()\n", + " dt = T/(Nt - 1)\n", + "\n", + " # Perform forward Euler to solve the ODE\n", + " g_euler = np.zeros(Nt)\n", + " g_euler[0] = g0\n", + "\n", + " for i in range(1,Nt):\n", + " g_euler[i] = g_euler[i-1] + dt*(alpha*g_euler[i-1]*(A - g_euler[i-1]))\n", + "\n", + " # Print the errors done by each method\n", + " diff1 = np.max(np.abs(g_euler - g_analytical))\n", + " diff2 = np.max(np.abs(g_dnn_ag[0,:] - g_analytical))\n", + "\n", + " print('Max absolute difference between Euler method and analytical: %g'%diff1)\n", + " print('Max absolute difference between deep neural network and analytical: %g'%diff2)\n", + "\n", + " # Plot results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.plot(t,g_euler)\n", + " plt.plot(t,g_analytical)\n", + " plt.plot(t,g_dnn_ag[0,:])\n", + "\n", + " plt.legend(['euler','analytical','dnn'])\n", + " plt.xlabel('Time t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "6381dfa2", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Solving the one dimensional Poisson equation\n", + "\n", + "The Poisson equation for $g(x)$ in one dimension is" + ] + }, + { + "cell_type": "markdown", + "id": "ddcc006d", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{poisson} \\tag{13}\n", + " -g''(x) = f(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "85639943", + "metadata": { + "editable": true + }, + "source": [ + "where $f(x)$ is a given function for $x \\in (0,1)$.\n", + "\n", + "The conditions that $g(x)$ is chosen to fulfill, are" + ] + }, + { + "cell_type": "markdown", + "id": "f17eea8d", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + " g(0) &= 0 \\\\\n", + " g(1) &= 0\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "1efed335", + "metadata": { + "editable": true + }, + "source": [ + "This equation can be solved numerically using programs where e.g Autograd and TensorFlow are used.\n", + "The results from the networks can then be compared to the analytical solution.\n", + "In addition, it could be interesting to see how a typical method for numerically solving second order ODEs compares to the neural networks." + ] + }, + { + "cell_type": "markdown", + "id": "23e866a2", + "metadata": { + "editable": true + }, + "source": [ + "## The specific equation to solve for\n", + "\n", + "Here, the function $g(x)$ to solve for follows the equation" + ] + }, + { + "cell_type": "markdown", + "id": "2cfcda87", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "-g''(x) = f(x),\\qquad x \\in (0,1)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b2a2d58c", + "metadata": { + "editable": true + }, + "source": [ + "where $f(x)$ is a given function, along with the chosen conditions" + ] + }, + { + "cell_type": "markdown", + "id": "a7c84b58", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{aligned}\n", + "g(0) = g(1) = 0\n", + "\\end{aligned}\\label{cond} \\tag{14}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "9db2324e", + "metadata": { + "editable": true + }, + "source": [ + "In this example, we consider the case when $f(x) = (3x + x^2)\\exp(x)$.\n", + "\n", + "For this case, a possible trial solution satisfying the conditions could be" + ] + }, + { + "cell_type": "markdown", + "id": "f94f8d1a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x) = x \\cdot (1-x) \\cdot N(P,x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e8eaba06", + "metadata": { + "editable": true + }, + "source": [ + "The analytical solution for this problem is" + ] + }, + { + "cell_type": "markdown", + "id": "3c345647", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g(x) = x(1 - x)\\exp(x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0d913be0", + "metadata": { + "editable": true + }, + "source": [ + "## Solving the equation using Autograd" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "96194d94", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "## Set up the cost function specified for this Poisson equation:\n", + "\n", + "# The right side of the ODE\n", + "def f(x):\n", + " return (3*x + x**2)*np.exp(x)\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P)\n", + "\n", + " right_side = f(x)\n", + "\n", + " err_sqr = (-d2_g_t - right_side)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum/np.size(err_sqr)\n", + "\n", + "# The trial solution:\n", + "def g_trial_deep(x,P):\n", + " return x*(1-x)*deep_neural_network(P,x)\n", + "\n", + "# The analytic solution;\n", + "def g_analytic(x):\n", + " return x*(1-x)*np.exp(x)\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10\n", + " x = np.linspace(0,1, Nx)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [200,100]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(x,P)\n", + " g_analytical = g_analytic(x)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " max_diff = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%max_diff)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, g_analytical)\n", + " plt.plot(x, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "780c5c66", + "metadata": { + "editable": true + }, + "source": [ + "## Comparing with a numerical scheme\n", + "\n", + "The Poisson equation is possible to solve using Taylor series to approximate the second derivative.\n", + "\n", + "Using Taylor series, the second derivative can be expressed as\n", + "\n", + "$$\n", + "g''(x) = \\frac{g(x + \\Delta x) - 2g(x) + g(x-\\Delta x)}{\\Delta x^2} + E_{\\Delta x}(x)\n", + "$$\n", + "\n", + "where $\\Delta x$ is a small step size and $E_{\\Delta x}(x)$ being the error term.\n", + "\n", + "Looking away from the error terms gives an approximation to the second derivative:" + ] + }, + { + "cell_type": "markdown", + "id": "b6dfbfdc", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{approx} \\tag{15}\n", + "g''(x) \\approx \\frac{g(x + \\Delta x) - 2g(x) + g(x-\\Delta x)}{\\Delta x^2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "011ba117", + "metadata": { + "editable": true + }, + "source": [ + "If $x_i = i \\Delta x = x_{i-1} + \\Delta x$ and $g_i = g(x_i)$ for $i = 1,\\dots N_x - 2$ with $N_x$ being the number of values for $x$, ([15](#approx)) becomes" + ] + }, + { + "cell_type": "markdown", + "id": "cdf079bc", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "g''(x_i) &\\approx \\frac{g(x_i + \\Delta x) - 2g(x_i) + g(x_i -\\Delta x)}{\\Delta x^2} \\\\\n", + "&= \\frac{g_{i+1} - 2g_i + g_{i-1}}{\\Delta x^2}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bf2fc40c", + "metadata": { + "editable": true + }, + "source": [ + "Since we know from our problem that" + ] + }, + { + "cell_type": "markdown", + "id": "6662f05c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "-g''(x) &= f(x) \\\\\n", + "&= (3x + x^2)\\exp(x)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "fe9a0465", + "metadata": { + "editable": true + }, + "source": [ + "along with the conditions $g(0) = g(1) = 0$,\n", + "the following scheme can be used to find an approximate solution for $g(x)$ numerically:" + ] + }, + { + "cell_type": "markdown", + "id": "7603ea9a", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\begin{aligned}\n", + " -\\Big( \\frac{g_{i+1} - 2g_i + g_{i-1}}{\\Delta x^2} \\Big) &= f(x_i) \\\\\n", + " -g_{i+1} + 2g_i - g_{i-1} &= \\Delta x^2 f(x_i)\n", + " \\end{aligned}\n", + "\\end{equation} \\label{odesys} \\tag{16}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "6744dfef", + "metadata": { + "editable": true + }, + "source": [ + "for $i = 1, \\dots, N_x - 2$ where $g_0 = g_{N_x - 1} = 0$ and $f(x_i) = (3x_i + x_i^2)\\exp(x_i)$, which is given for our specific problem.\n", + "\n", + "The equation can be rewritten into a matrix equation:" + ] + }, + { + "cell_type": "markdown", + "id": "af13fca6", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "\\begin{pmatrix}\n", + "2 & -1 & 0 & \\dots & 0 \\\\\n", + "-1 & 2 & -1 & \\dots & 0 \\\\\n", + "\\vdots & & \\ddots & & \\vdots \\\\\n", + "0 & \\dots & -1 & 2 & -1 \\\\\n", + "0 & \\dots & 0 & -1 & 2\\\\\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "g_1 \\\\\n", + "g_2 \\\\\n", + "\\vdots \\\\\n", + "g_{N_x - 3} \\\\\n", + "g_{N_x - 2}\n", + "\\end{pmatrix}\n", + "&=\n", + "\\Delta x^2\n", + "\\begin{pmatrix}\n", + "f(x_1) \\\\\n", + "f(x_2) \\\\\n", + "\\vdots \\\\\n", + "f(x_{N_x - 3}) \\\\\n", + "f(x_{N_x - 2})\n", + "\\end{pmatrix} \\\\\n", + "\\boldsymbol{A}\\boldsymbol{g} &= \\boldsymbol{f},\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bd1bd149", + "metadata": { + "editable": true + }, + "source": [ + "which makes it possible to solve for the vector $\\boldsymbol{g}$." + ] + }, + { + "cell_type": "markdown", + "id": "43e51ef4", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the code\n", + "\n", + "We can then compare the result from this numerical scheme with the output from our network using Autograd:" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "49c94dd9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "## Set up the cost function specified for this Poisson equation:\n", + "\n", + "# The right side of the ODE\n", + "def f(x):\n", + " return (3*x + x**2)*np.exp(x)\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P)\n", + "\n", + " right_side = f(x)\n", + "\n", + " err_sqr = (-d2_g_t - right_side)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum/np.size(err_sqr)\n", + "\n", + "# The trial solution:\n", + "def g_trial_deep(x,P):\n", + " return x*(1-x)*deep_neural_network(P,x)\n", + "\n", + "# The analytic solution;\n", + "def g_analytic(x):\n", + " return x*(1-x)*np.exp(x)\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10\n", + " x = np.linspace(0,1, Nx)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [200,100]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(x,P)\n", + " g_analytical = g_analytic(x)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, g_analytical)\n", + " plt.plot(x, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + "\n", + " ## Perform the computation using the numerical scheme\n", + "\n", + " dx = 1/(Nx - 1)\n", + "\n", + " # Set up the matrix A\n", + " A = np.zeros((Nx-2,Nx-2))\n", + "\n", + " A[0,0] = 2\n", + " A[0,1] = -1\n", + "\n", + " for i in range(1,Nx-3):\n", + " A[i,i-1] = -1\n", + " A[i,i] = 2\n", + " A[i,i+1] = -1\n", + "\n", + " A[Nx - 3, Nx - 4] = -1\n", + " A[Nx - 3, Nx - 3] = 2\n", + "\n", + " # Set up the vector f\n", + " f_vec = dx**2 * f(x[1:-1])\n", + "\n", + " # Solve the equation\n", + " g_res = np.linalg.solve(A,f_vec)\n", + "\n", + " g_vec = np.zeros(Nx)\n", + " g_vec[1:-1] = g_res\n", + "\n", + " # Print the differences between each method\n", + " max_diff1 = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " max_diff2 = np.max(np.abs(g_vec - g_analytical))\n", + " print(\"The max absolute difference between the analytical solution and DNN Autograd: %g\"%max_diff1)\n", + " print(\"The max absolute difference between the analytical solution and numerical scheme: %g\"%max_diff2)\n", + "\n", + " # Plot the results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.plot(x,g_vec)\n", + " plt.plot(x,g_analytical)\n", + " plt.plot(x,g_dnn_ag[0,:])\n", + "\n", + " plt.legend(['numerical scheme','analytical','dnn'])\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "6d27256f", + "metadata": { + "editable": true + }, + "source": [ + "## Partial Differential Equations\n", + "\n", + "A partial differential equation (PDE) has a solution here the function\n", + "is defined by multiple variables. The equation may involve all kinds\n", + "of combinations of which variables the function is differentiated with\n", + "respect to.\n", + "\n", + "In general, a partial differential equation for a function $g(x_1,\\dots,x_N)$ with $N$ variables may be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "df08a8ac", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{PDE} \\tag{17}\n", + " f\\left(x_1, \\, \\dots \\, , x_N, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1}, \\dots , \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_N}, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(x_1,\\dots,x_N) }{\\partial x_N^n} \\right) = 0\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ec4b9fd4", + "metadata": { + "editable": true + }, + "source": [ + "where $f$ is an expression involving all kinds of possible mixed derivatives of $g(x_1,\\dots,x_N)$ up to an order $n$. In order for the solution to be unique, some additional conditions must also be given." + ] + }, + { + "cell_type": "markdown", + "id": "92f17705", + "metadata": { + "editable": true + }, + "source": [ + "## Type of problem\n", + "\n", + "The problem our network must solve for, is similar to the ODE case.\n", + "We must have a trial solution $g_t$ at hand.\n", + "\n", + "For instance, the trial solution could be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "eec1785d", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + " g_t(x_1,\\dots,x_N) = h_1(x_1,\\dots,x_N) + h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "544c3fce", + "metadata": { + "editable": true + }, + "source": [ + "where $h_1(x_1,\\dots,x_N)$ is a function that ensures $g_t(x_1,\\dots,x_N)$ satisfies some given conditions.\n", + "The neural network $N(x_1,\\dots,x_N,P)$ has weights and biases described by $P$ and $h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))$ is an expression using the output from the neural network in some way.\n", + "\n", + "The role of the function $h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))$, is to ensure that the output of $N(x_1,\\dots,x_N,P)$ is zero when $g_t(x_1,\\dots,x_N)$ is evaluated at the values of $x_1,\\dots,x_N$ where the given conditions must be satisfied. The function $h_1(x_1,\\dots,x_N)$ should alone make $g_t(x_1,\\dots,x_N)$ satisfy the conditions." + ] + }, + { + "cell_type": "markdown", + "id": "74af5618", + "metadata": { + "editable": true + }, + "source": [ + "## Network requirements\n", + "\n", + "The network tries then the minimize the cost function following the\n", + "same ideas as described for the ODE case, but now with more than one\n", + "variables to consider. The concept still remains the same; find a set\n", + "of parameters $P$ such that the expression $f$ in ([17](#PDE)) is as\n", + "close to zero as possible.\n", + "\n", + "As for the ODE case, the cost function is the mean squared error that\n", + "the network must try to minimize. The cost function for the network to\n", + "minimize is" + ] + }, + { + "cell_type": "markdown", + "id": "9a7c5864", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(x_1, \\dots, x_N, P\\right) = \\left( f\\left(x_1, \\, \\dots \\, , x_N, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1}, \\dots , \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_N}, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(x_1,\\dots,x_N) }{\\partial x_N^n} \\right) \\right)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3f2d680d", + "metadata": { + "editable": true + }, + "source": [ + "## More details\n", + "\n", + "If we let $\\boldsymbol{x} = \\big( x_1, \\dots, x_N \\big)$ be an array containing the values for $x_1, \\dots, x_N$ respectively, the cost function can be reformulated into the following:" + ] + }, + { + "cell_type": "markdown", + "id": "118044b0", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(\\boldsymbol{x}, P\\right) = f\\left( \\left( \\boldsymbol{x}, \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_1}, \\dots , \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_N}, \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(\\boldsymbol{x}) }{\\partial x_N^n} \\right) \\right)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e9b82be4", + "metadata": { + "editable": true + }, + "source": [ + "If we also have $M$ different sets of values for $x_1, \\dots, x_N$, that is $\\boldsymbol{x}_i = \\big(x_1^{(i)}, \\dots, x_N^{(i)}\\big)$ for $i = 1,\\dots,M$ being the rows in matrix $X$, the cost function can be generalized into" + ] + }, + { + "cell_type": "markdown", + "id": "d5e6b103", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(X, P \\right) = \\sum_{i=1}^M f\\left( \\left( \\boldsymbol{x}_i, \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_1}, \\dots , \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_N}, \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(\\boldsymbol{x}_i) }{\\partial x_N^n} \\right) \\right)^2.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c9dec199", + "metadata": { + "editable": true + }, + "source": [ + "## Example: The diffusion equation\n", + "\n", + "In one spatial dimension, the equation reads" + ] + }, + { + "cell_type": "markdown", + "id": "118d2522", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial g(x,t)}{\\partial t} = \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "1d13aaff", + "metadata": { + "editable": true + }, + "source": [ + "where a possible choice of conditions are" + ] + }, + { + "cell_type": "markdown", + "id": "4de9c463", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "g(0,t) &= 0 ,\\qquad t \\geq 0 \\\\\n", + "g(1,t) &= 0, \\qquad t \\geq 0 \\\\\n", + "g(x,0) &= u(x),\\qquad x\\in [0,1]\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "65b2ba09", + "metadata": { + "editable": true + }, + "source": [ + "with $u(x)$ being some given function." + ] + }, + { + "cell_type": "markdown", + "id": "843d90aa", + "metadata": { + "editable": true + }, + "source": [ + "## Defining the problem\n", + "\n", + "For this case, we want to find $g(x,t)$ such that" + ] + }, + { + "cell_type": "markdown", + "id": "77447bcd", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\frac{\\partial g(x,t)}{\\partial t} = \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "\\end{equation} \\label{diffonedim} \\tag{18}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c3cf90aa", + "metadata": { + "editable": true + }, + "source": [ + "and" + ] + }, + { + "cell_type": "markdown", + "id": "257d1f48", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "g(0,t) &= 0 ,\\qquad t \\geq 0 \\\\\n", + "g(1,t) &= 0, \\qquad t \\geq 0 \\\\\n", + "g(x,0) &= u(x),\\qquad x\\in [0,1]\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7f4f7d6a", + "metadata": { + "editable": true + }, + "source": [ + "with $u(x) = \\sin(\\pi x)$.\n", + "\n", + "First, let us set up the deep neural network.\n", + "The deep neural network will follow the same structure as discussed in the examples solving the ODEs.\n", + "First, we will look into how Autograd could be used in a network tailored to solve for bivariate functions." + ] + }, + { + "cell_type": "markdown", + "id": "1e0c143a", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd\n", + "\n", + "The only change to do here, is to extend our network such that\n", + "functions of multiple parameters are correctly handled. In this case\n", + "we have two variables in our function to solve for, that is time $t$\n", + "and position $x$. The variables will be represented by a\n", + "one-dimensional array in the program. The program will evaluate the\n", + "network at each possible pair $(x,t)$, given an array for the desired\n", + "$x$-values and $t$-values to approximate the solution at." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "e52c49e9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]" + ] + }, + { + "cell_type": "markdown", + "id": "e6975906", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd; The trial solution\n", + "\n", + "The cost function must then iterate through the given arrays\n", + "containing values for $x$ and $t$, defines a point $(x,t)$ the deep\n", + "neural network and the trial solution is evaluated at, and then finds\n", + "the Jacobian of the trial solution.\n", + "\n", + "A possible trial solution for this PDE is\n", + "\n", + "$$\n", + "g_t(x,t) = h_1(x,t) + x(1-x)tN(x,t,P)\n", + "$$\n", + "\n", + "with $A(x,t)$ being a function ensuring that $g_t(x,t)$ satisfies our given conditions, and $N(x,t,P)$ being the output from the deep neural network using weights and biases for each layer from $P$.\n", + "\n", + "To fulfill the conditions, $A(x,t)$ could be:\n", + "\n", + "$$\n", + "h_1(x,t) = (1-t)\\Big(u(x) - \\big((1-x)u(0) + x u(1)\\big)\\Big) = (1-t)u(x) = (1-t)\\sin(\\pi x)\n", + "$$\n", + "since $(0) = u(1) = 0$ and $u(x) = \\sin(\\pi x)$." + ] + }, + { + "cell_type": "markdown", + "id": "d665f51c", + "metadata": { + "editable": true + }, + "source": [ + "## Why the jacobian?\n", + "\n", + "The Jacobian is used because the program must find the derivative of\n", + "the trial solution with respect to $x$ and $t$.\n", + "\n", + "This gives the necessity of computing the Jacobian matrix, as we want\n", + "to evaluate the gradient with respect to $x$ and $t$ (note that the\n", + "Jacobian of a scalar-valued multivariate function is simply its\n", + "gradient).\n", + "\n", + "In Autograd, the differentiation is by default done with respect to\n", + "the first input argument of your Python function. Since the points is\n", + "an array representing $x$ and $t$, the Jacobian is calculated using\n", + "the values of $x$ and $t$.\n", + "\n", + "To find the second derivative with respect to $x$ and $t$, the\n", + "Jacobian can be found for the second time. The result is a Hessian\n", + "matrix, which is the matrix containing all the possible second order\n", + "mixed derivatives of $g(x,t)$." + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "152c290e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Set up the trial function:\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point)\n", + "\n", + "# The right side of the ODE:\n", + "def f(point):\n", + " return 0.\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_jacobian_func = jacobian(g_trial)\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t = g_trial(point,P)\n", + " g_t_jacobian = g_t_jacobian_func(point,P)\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_dt = g_t_jacobian[1]\n", + " g_t_d2x = g_t_hessian[0][0]\n", + "\n", + " func = f(point)\n", + "\n", + " err_sqr = ( (g_t_dt - g_t_d2x) - func)**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum" + ] + }, + { + "cell_type": "markdown", + "id": "eac82d2c", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd; The full program\n", + "\n", + "Having set up the network, along with the trial solution and cost function, we can now see how the deep neural network performs by comparing the results to the analytical solution.\n", + "\n", + "The analytical solution of our problem is\n", + "\n", + "$$\n", + "g(x,t) = \\exp(-\\pi^2 t)\\sin(\\pi x)\n", + "$$\n", + "\n", + "A possible way to implement a neural network solving the PDE, is given below.\n", + "Be aware, though, that it is fairly slow for the parameters used.\n", + "A better result is possible, but requires more iterations, and thus longer time to complete.\n", + "\n", + "Indeed, the program below is not optimal in its implementation, but rather serves as an example on how to implement and use a neural network to solve a PDE.\n", + "Using TensorFlow results in a much better execution time. Try it!" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "df3d9605", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import jacobian,hessian,grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import cm\n", + "from matplotlib import pyplot as plt\n", + "from mpl_toolkits.mplot3d import axes3d\n", + "\n", + "## Set up the network\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]\n", + "\n", + "## Define the trial solution and cost function\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point)\n", + "\n", + "# The right side of the ODE:\n", + "def f(point):\n", + " return 0.\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_jacobian_func = jacobian(g_trial)\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t = g_trial(point,P)\n", + " g_t_jacobian = g_t_jacobian_func(point,P)\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_dt = g_t_jacobian[1]\n", + " g_t_d2x = g_t_hessian[0][0]\n", + "\n", + " func = f(point)\n", + "\n", + " err_sqr = ( (g_t_dt - g_t_d2x) - func)**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum /( np.size(x)*np.size(t) )\n", + "\n", + "## For comparison, define the analytical solution\n", + "def g_analytic(point):\n", + " x,t = point\n", + " return np.exp(-np.pi**2*t)*np.sin(np.pi*x)\n", + "\n", + "## Set up a function for training the network to solve for the equation\n", + "def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb):\n", + " ## Set up initial weigths and biases\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: ',cost_function(P, x, t))\n", + "\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " cost_grad = cost_function_grad(P, x , t)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_grad[l]\n", + "\n", + " print('Final cost: ',cost_function(P, x, t))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " ### Use the neural network:\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10; Nt = 10\n", + " x = np.linspace(0, 1, Nx)\n", + " t = np.linspace(0,1,Nt)\n", + "\n", + " ## Set up the parameters for the network\n", + " num_hidden_neurons = [100, 25]\n", + " num_iter = 250\n", + " lmb = 0.01\n", + "\n", + " P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " ## Store the results\n", + " g_dnn_ag = np.zeros((Nx, Nt))\n", + " G_analytical = np.zeros((Nx, Nt))\n", + " for i,x_ in enumerate(x):\n", + " for j, t_ in enumerate(t):\n", + " point = np.array([x_, t_])\n", + " g_dnn_ag[i,j] = g_trial(point,P)\n", + "\n", + " G_analytical[i,j] = g_analytic(point)\n", + "\n", + " # Find the map difference between the analytical and the computed solution\n", + " diff_ag = np.abs(g_dnn_ag - G_analytical)\n", + " print('Max absolute difference between the analytical solution and the network: %g'%np.max(diff_ag))\n", + "\n", + " ## Plot the solutions in two dimensions, that being in position and time\n", + "\n", + " T,X = np.meshgrid(t,x)\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons))\n", + " s = ax.plot_surface(T,X,g_dnn_ag,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Analytical solution')\n", + " s = ax.plot_surface(T,X,G_analytical,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Difference')\n", + " s = ax.plot_surface(T,X,diff_ag,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " ## Take some slices of the 3D plots just to see the solutions at particular times\n", + " indx1 = 0\n", + " indx2 = int(Nt/2)\n", + " indx3 = Nt-1\n", + "\n", + " t1 = t[indx1]\n", + " t2 = t[indx2]\n", + " t3 = t[indx3]\n", + "\n", + " # Slice the results from the DNN\n", + " res1 = g_dnn_ag[:,indx1]\n", + " res2 = g_dnn_ag[:,indx2]\n", + " res3 = g_dnn_ag[:,indx3]\n", + "\n", + " # Slice the analytical results\n", + " res_analytical1 = G_analytical[:,indx1]\n", + " res_analytical2 = G_analytical[:,indx2]\n", + " res_analytical3 = G_analytical[:,indx3]\n", + "\n", + " # Plot the slices\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t1)\n", + " plt.plot(x, res1)\n", + " plt.plot(x,res_analytical1)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t2)\n", + " plt.plot(x, res2)\n", + " plt.plot(x,res_analytical2)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t3)\n", + " plt.plot(x, res3)\n", + " plt.plot(x,res_analytical3)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "fec03008", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Solving the wave equation with Neural Networks\n", + "\n", + "The wave equation is" + ] + }, + { + "cell_type": "markdown", + "id": "403f7560", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial^2 g(x,t)}{\\partial t^2} = c^2\\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "dc05badf", + "metadata": { + "editable": true + }, + "source": [ + "with $c$ being the specified wave speed.\n", + "\n", + "Here, the chosen conditions are" + ] + }, + { + "cell_type": "markdown", + "id": "1daf1dd8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "\tg(0,t) &= 0 \\\\\n", + "\tg(1,t) &= 0 \\\\\n", + "\tg(x,0) &= u(x) \\\\\n", + "\t\\frac{\\partial g(x,t)}{\\partial t} \\Big |_{t = 0} &= v(x)\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "4da632df", + "metadata": { + "editable": true + }, + "source": [ + "where $\\frac{\\partial g(x,t)}{\\partial t} \\Big |_{t = 0}$ means the derivative of $g(x,t)$ with respect to $t$ is evaluated at $t = 0$, and $u(x)$ and $v(x)$ being given functions." + ] + }, + { + "cell_type": "markdown", + "id": "851bb943", + "metadata": { + "editable": true + }, + "source": [ + "## The problem to solve for\n", + "\n", + "The wave equation to solve for, is" + ] + }, + { + "cell_type": "markdown", + "id": "760b72fe", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{equation} \\label{wave} \\tag{19}\n", + "\\frac{\\partial^2 g(x,t)}{\\partial t^2} = c^2 \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e3e22598", + "metadata": { + "editable": true + }, + "source": [ + "where $c$ is the given wave speed.\n", + "The chosen conditions for this equation are" + ] + }, + { + "cell_type": "markdown", + "id": "59f39060", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
    \n", + "\n", + "$$\n", + "\\begin{aligned}\n", + "g(0,t) &= 0, &t \\geq 0 \\\\\n", + "g(1,t) &= 0, &t \\geq 0 \\\\\n", + "g(x,0) &= u(x), &x\\in[0,1] \\\\\n", + "\\frac{\\partial g(x,t)}{\\partial t}\\Big |_{t = 0} &= v(x), &x \\in [0,1]\n", + "\\end{aligned} \\label{condwave} \\tag{20}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bf3a2904", + "metadata": { + "editable": true + }, + "source": [ + "In this example, let $c = 1$ and $u(x) = \\sin(\\pi x)$ and $v(x) = -\\pi\\sin(\\pi x)$." + ] + }, + { + "cell_type": "markdown", + "id": "4a633f01", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "Setting up the network is done in similar matter as for the example of solving the diffusion equation.\n", + "The only things we have to change, is the trial solution such that it satisfies the conditions from ([20](#condwave)) and the cost function.\n", + "\n", + "The trial solution becomes slightly different since we have other conditions than in the example of solving the diffusion equation. Here, a possible trial solution $g_t(x,t)$ is\n", + "\n", + "$$\n", + "g_t(x,t) = h_1(x,t) + x(1-x)t^2N(x,t,P)\n", + "$$\n", + "\n", + "where\n", + "\n", + "$$\n", + "h_1(x,t) = (1-t^2)u(x) + tv(x)\n", + "$$\n", + "\n", + "Note that this trial solution satisfies the conditions only if $u(0) = v(0) = u(1) = v(1) = 0$, which is the case in this example." + ] + }, + { + "cell_type": "markdown", + "id": "c09dc6a7", + "metadata": { + "editable": true + }, + "source": [ + "## The analytical solution\n", + "\n", + "The analytical solution for our specific problem, is\n", + "\n", + "$$\n", + "g(x,t) = \\sin(\\pi x)\\cos(\\pi t) - \\sin(\\pi x)\\sin(\\pi t)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "592d4d57", + "metadata": { + "editable": true + }, + "source": [ + "## Solving the wave equation - the full program using Autograd" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "1c25dc4e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import hessian,grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import cm\n", + "from matplotlib import pyplot as plt\n", + "from mpl_toolkits.mplot3d import axes3d\n", + "\n", + "## Set up the trial function:\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def v(x):\n", + " return -np.pi*np.sin(np.pi*x)\n", + "\n", + "def h1(point):\n", + " x,t = point\n", + " return (1 - t**2)*u(x) + t*v(x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return h1(point) + x*(1-x)*t**2*deep_neural_network(P,point)\n", + "\n", + "## Define the cost function\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_d2x = g_t_hessian[0][0]\n", + " g_t_d2t = g_t_hessian[1][1]\n", + "\n", + " err_sqr = ( (g_t_d2t - g_t_d2x) )**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum / (np.size(t) * np.size(x))\n", + "\n", + "## The neural network\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]\n", + "\n", + "## The analytical solution\n", + "def g_analytic(point):\n", + " x,t = point\n", + " return np.sin(np.pi*x)*np.cos(np.pi*t) - np.sin(np.pi*x)*np.sin(np.pi*t)\n", + "\n", + "def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb):\n", + " ## Set up initial weigths and biases\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: ',cost_function(P, x, t))\n", + "\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " cost_grad = cost_function_grad(P, x , t)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_grad[l]\n", + "\n", + "\n", + " print('Final cost: ',cost_function(P, x, t))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " ### Use the neural network:\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10; Nt = 10\n", + " x = np.linspace(0, 1, Nx)\n", + " t = np.linspace(0,1,Nt)\n", + "\n", + " ## Set up the parameters for the network\n", + " num_hidden_neurons = [50,20]\n", + " num_iter = 1000\n", + " lmb = 0.01\n", + "\n", + " P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " ## Store the results\n", + " res = np.zeros((Nx, Nt))\n", + " res_analytical = np.zeros((Nx, Nt))\n", + " for i,x_ in enumerate(x):\n", + " for j, t_ in enumerate(t):\n", + " point = np.array([x_, t_])\n", + " res[i,j] = g_trial(point,P)\n", + "\n", + " res_analytical[i,j] = g_analytic(point)\n", + "\n", + " diff = np.abs(res - res_analytical)\n", + " print(\"Max difference between analytical and solution from nn: %g\"%np.max(diff))\n", + "\n", + " ## Plot the solutions in two dimensions, that being in position and time\n", + "\n", + " T,X = np.meshgrid(t,x)\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons))\n", + " s = ax.plot_surface(T,X,res,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Analytical solution')\n", + " s = ax.plot_surface(T,X,res_analytical,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Difference')\n", + " s = ax.plot_surface(T,X,diff,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " ## Take some slices of the 3D plots just to see the solutions at particular times\n", + " indx1 = 0\n", + " indx2 = int(Nt/2)\n", + " indx3 = Nt-1\n", + "\n", + " t1 = t[indx1]\n", + " t2 = t[indx2]\n", + " t3 = t[indx3]\n", + "\n", + " # Slice the results from the DNN\n", + " res1 = res[:,indx1]\n", + " res2 = res[:,indx2]\n", + " res3 = res[:,indx3]\n", + "\n", + " # Slice the analytical results\n", + " res_analytical1 = res_analytical[:,indx1]\n", + " res_analytical2 = res_analytical[:,indx2]\n", + " res_analytical3 = res_analytical[:,indx3]\n", + "\n", + " # Plot the slices\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t1)\n", + " plt.plot(x, res1)\n", + " plt.plot(x,res_analytical1)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t2)\n", + " plt.plot(x, res2)\n", + " plt.plot(x,res_analytical2)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t3)\n", + " plt.plot(x, res3)\n", + " plt.plot(x,res_analytical3)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "5072a8bd", + "metadata": { + "editable": true + }, + "source": [ + "## Resources on differential equations and deep learning\n", + "\n", + "1. [Artificial neural networks for solving ordinary and partial differential equations by I.E. Lagaris et al](https://pdfs.semanticscholar.org/d061/df393e0e8fbfd0ea24976458b7d42419040d.pdf)\n", + "\n", + "2. [Neural networks for solving differential equations by A. Honchar](https://becominghuman.ai/neural-networks-for-solving-differential-equations-fa230ac5e04c)\n", + "\n", + "3. [Solving differential equations using neural networks by M.M Chiaramonte and M. Kiener](http://cs229.stanford.edu/proj2013/ChiaramonteKiener-SolvingDifferentialEquationsUsingNeuralNetworks.pdf)\n", + "\n", + "4. [Introduction to Partial Differential Equations by A. Tveito, R. Winther](https://www.springer.com/us/book/9783540225515)" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} From 034d9552c8057ab6b673972349e8c8d064dcef67 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 07:59:28 +0200 Subject: [PATCH 05/14] correcting typos --- doc/pub/week43/html/week43-bs.html | 2 +- doc/pub/week43/html/week43-reveal.html | 2 +- doc/pub/week43/html/week43-solarized.html | 2 +- doc/pub/week43/html/week43.html | 2 +- doc/pub/week43/ipynb/ipynb-week43-src.tar.gz | Bin 192 -> 192 bytes doc/pub/week43/ipynb/week43.ipynb | 490 +++++++++---------- doc/src/week43/week43.do.txt | 2 +- 7 files changed, 250 insertions(+), 250 deletions(-) diff --git a/doc/pub/week43/html/week43-bs.html b/doc/pub/week43/html/week43-bs.html index 4b7cb355e..52b4cc052 100644 --- a/doc/pub/week43/html/week43-bs.html +++ b/doc/pub/week43/html/week43-bs.html @@ -397,7 +397,7 @@ MathJax.Hub.Config({
      -
    1. Reminder from last week, see lalso ecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
    2. +
    3. Reminder from last week, see also lecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
    4. Building our own Feed-forward Neural Network.
    5. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13..
    6. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. diff --git a/doc/pub/week43/html/week43-reveal.html b/doc/pub/week43/html/week43-reveal.html index 3db80b689..04d2f9675 100644 --- a/doc/pub/week43/html/week43-reveal.html +++ b/doc/pub/week43/html/week43-reveal.html @@ -198,7 +198,7 @@ MathJax.Hub.Config({ Material for the lecture on Monday October 20, 2025

        -

      1. Reminder from last week, see lalso ecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
      2. +

      3. Reminder from last week, see also lecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
      4. Building our own Feed-forward Neural Network.
      5. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13..
      6. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. diff --git a/doc/pub/week43/html/week43-solarized.html b/doc/pub/week43/html/week43-solarized.html index 27c79506b..7efee0800 100644 --- a/doc/pub/week43/html/week43-solarized.html +++ b/doc/pub/week43/html/week43-solarized.html @@ -318,7 +318,7 @@ MathJax.Hub.Config({ Material for the lecture on Monday October 20, 2025

          -
        1. Reminder from last week, see lalso ecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
        2. +
        3. Reminder from last week, see also lecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
        4. Building our own Feed-forward Neural Network.
        5. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13..
        6. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. diff --git a/doc/pub/week43/html/week43.html b/doc/pub/week43/html/week43.html index 6c0b7933d..901ed5b9b 100644 --- a/doc/pub/week43/html/week43.html +++ b/doc/pub/week43/html/week43.html @@ -395,7 +395,7 @@ MathJax.Hub.Config({ Material for the lecture on Monday October 20, 2025

            -
          1. Reminder from last week, see lalso ecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
          2. +
          3. Reminder from last week, see also lecture notes from week 42 at https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html as well as those from week 41, see see https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html.
          4. Building our own Feed-forward Neural Network.
          5. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13..
          6. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. diff --git a/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz b/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz index 0ff6ebee5ce4f589a382d7983b817b65259181d0..408b306858d512dedb6906d353b2395539db3ec3 100644 GIT binary patch delta 170 zcmV;b09F6M0l)zzABzY8vCs8r00ZsM%?iRW3gilFUb3LJy1LY*;F-wz#0--TyGyt;PNiUss!VIT0)ftsV^=@t$E6Wdi z=2zgEf8tn43)_9~Dy=|ihq=}@+z@LPN3!iz4uwWLw!q-ElLkSk9z;<{C$$onur>N* YL}R1y*UxyK=Xqay0DWIV@&E_`0DqH8dH?_b delta 170 zcmV;b09F6M0l)zzABzY8!p!w(00ZsM%?iRW3N* Ycw?jR*UxyK=Xqay0QRomT>uCG03o4HKmY&$ diff --git a/doc/pub/week43/ipynb/week43.ipynb b/doc/pub/week43/ipynb/week43.ipynb index 3e86d5cdb..8d5235416 100644 --- a/doc/pub/week43/ipynb/week43.ipynb +++ b/doc/pub/week43/ipynb/week43.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8c52cd3b", + "id": "b10156d4", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "846eee41", + "id": "f85baa2f", "metadata": { "editable": true }, @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "ff057bd5", + "id": "543fad4a", "metadata": { "editable": true }, @@ -36,7 +36,7 @@ "\n", "**Material for the lecture on Monday October 20, 2025.**\n", "\n", - "1. Reminder from last week, see lalso ecture notes from week 42 at as well as those from week 41, see see . \n", + "1. Reminder from last week, see also lecture notes from week 42 at as well as those from week 41, see see . \n", "\n", "2. Building our own Feed-forward Neural Network.\n", "\n", @@ -49,7 +49,7 @@ }, { "cell_type": "markdown", - "id": "8d1fd0b3", + "id": "72acb4e9", "metadata": { "editable": true }, @@ -64,7 +64,7 @@ }, { "cell_type": "markdown", - "id": "4990faa2", + "id": "361768dc", "metadata": { "editable": true }, @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "76cb0250", + "id": "3e058671", "metadata": { "editable": true }, @@ -94,7 +94,7 @@ }, { "cell_type": "markdown", - "id": "5bdfe8a0", + "id": "8cbbf2bf", "metadata": { "editable": true }, @@ -104,7 +104,7 @@ }, { "cell_type": "markdown", - "id": "b78c27be", + "id": "78e2de21", "metadata": { "editable": true }, @@ -131,7 +131,7 @@ }, { "cell_type": "markdown", - "id": "db515eac", + "id": "41a3dc23", "metadata": { "editable": true }, @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "0d9e2c6d", + "id": "0e4ac2c0", "metadata": { "editable": true }, @@ -166,7 +166,7 @@ }, { "cell_type": "markdown", - "id": "c54ddbb9", + "id": "e9fd2f83", "metadata": { "editable": true }, @@ -178,7 +178,7 @@ }, { "cell_type": "markdown", - "id": "0a074eb8", + "id": "16e2b900", "metadata": { "editable": true }, @@ -188,7 +188,7 @@ }, { "cell_type": "markdown", - "id": "2916e7ad", + "id": "f9f4b9d8", "metadata": { "editable": true }, @@ -200,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "fc87090a", + "id": "01be6441", "metadata": { "editable": true }, @@ -214,7 +214,7 @@ }, { "cell_type": "markdown", - "id": "0fab3976", + "id": "ce898b85", "metadata": { "editable": true }, @@ -226,7 +226,7 @@ }, { "cell_type": "markdown", - "id": "506b036e", + "id": "4e2e7314", "metadata": { "editable": true }, @@ -238,7 +238,7 @@ }, { "cell_type": "markdown", - "id": "7230ebb2", + "id": "b7114295", "metadata": { "editable": true }, @@ -248,7 +248,7 @@ }, { "cell_type": "markdown", - "id": "24dcabf8", + "id": "69dfa048", "metadata": { "editable": true }, @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "769b4b46", + "id": "6efa469c", "metadata": { "editable": true }, @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "0eb6e407", + "id": "076e4937", "metadata": { "editable": true }, @@ -282,7 +282,7 @@ }, { "cell_type": "markdown", - "id": "dd2caf09", + "id": "1072f5a1", "metadata": { "editable": true }, @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "3ca5122d", + "id": "f77a7074", "metadata": { "editable": true }, @@ -306,7 +306,7 @@ }, { "cell_type": "markdown", - "id": "0297fbd7", + "id": "f12effab", "metadata": { "editable": true }, @@ -329,7 +329,7 @@ }, { "cell_type": "markdown", - "id": "093209ef", + "id": "31eb54b1", "metadata": { "editable": true }, @@ -341,7 +341,7 @@ }, { "cell_type": "markdown", - "id": "52cacfbe", + "id": "7a549168", "metadata": { "editable": true }, @@ -353,7 +353,7 @@ }, { "cell_type": "markdown", - "id": "3ac82bdf", + "id": "ce35ae73", "metadata": { "editable": true }, @@ -363,7 +363,7 @@ }, { "cell_type": "markdown", - "id": "e3f9be3c", + "id": "d6cdfc89", "metadata": { "editable": true }, @@ -375,7 +375,7 @@ }, { "cell_type": "markdown", - "id": "fdb953a2", + "id": "ddd59bb0", "metadata": { "editable": true }, @@ -396,7 +396,7 @@ }, { "cell_type": "markdown", - "id": "0d8677dd", + "id": "f2a78e55", "metadata": { "editable": true }, @@ -410,7 +410,7 @@ }, { "cell_type": "markdown", - "id": "6d2d4dcc", + "id": "cde73faf", "metadata": { "editable": true }, @@ -422,7 +422,7 @@ }, { "cell_type": "markdown", - "id": "e17fbd6e", + "id": "08048672", "metadata": { "editable": true }, @@ -444,7 +444,7 @@ }, { "cell_type": "markdown", - "id": "4464d159", + "id": "a7085280", "metadata": { "editable": true }, @@ -466,7 +466,7 @@ }, { "cell_type": "markdown", - "id": "d7dacac8", + "id": "291e4fb2", "metadata": { "editable": true }, @@ -484,7 +484,7 @@ }, { "cell_type": "markdown", - "id": "cb79f5a6", + "id": "a8c5f4c2", "metadata": { "editable": true }, @@ -519,7 +519,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "44cf829e", + "id": "9a0aac03", "metadata": { "collapsed": false, "editable": true @@ -531,7 +531,7 @@ }, { "cell_type": "markdown", - "id": "bdf6f4be", + "id": "ca0c7865", "metadata": { "editable": true }, @@ -543,7 +543,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "784ed3b7", + "id": "d0c581f7", "metadata": { "collapsed": false, "editable": true @@ -556,7 +556,7 @@ }, { "cell_type": "markdown", - "id": "30a63e04", + "id": "fe086bc9", "metadata": { "editable": true }, @@ -567,7 +567,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "5ecbf45a", + "id": "f551fad9", "metadata": { "collapsed": false, "editable": true @@ -580,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "4a0568e9", + "id": "58152cef", "metadata": { "editable": true }, @@ -595,7 +595,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "9982df74", + "id": "579b6a4a", "metadata": { "collapsed": false, "editable": true @@ -607,7 +607,7 @@ }, { "cell_type": "markdown", - "id": "b81f34fd", + "id": "5da15206", "metadata": { "editable": true }, @@ -619,7 +619,7 @@ }, { "cell_type": "markdown", - "id": "cf68391d", + "id": "cc970d32", "metadata": { "editable": true }, @@ -632,7 +632,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "2594d47b", + "id": "a4f2c8a8", "metadata": { "collapsed": false, "editable": true @@ -689,7 +689,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "060f0b22", + "id": "d0c06f34", "metadata": { "collapsed": false, "editable": true @@ -718,7 +718,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "5491ac4f", + "id": "8272ca95", "metadata": { "collapsed": false, "editable": true @@ -748,7 +748,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "905a1d27", + "id": "616613a7", "metadata": { "collapsed": false, "editable": true @@ -775,7 +775,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "491849b6", + "id": "f57a7b70", "metadata": { "collapsed": false, "editable": true @@ -817,7 +817,7 @@ }, { "cell_type": "markdown", - "id": "25bfc059", + "id": "a61b50a8", "metadata": { "editable": true }, @@ -828,7 +828,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "29c660b4", + "id": "d220a7ad", "metadata": { "collapsed": false, "editable": true @@ -915,7 +915,7 @@ }, { "cell_type": "markdown", - "id": "50468253", + "id": "d87d7514", "metadata": { "editable": true }, @@ -926,7 +926,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "1e430607", + "id": "c6df6115", "metadata": { "collapsed": false, "editable": true @@ -986,7 +986,7 @@ }, { "cell_type": "markdown", - "id": "44c02ba1", + "id": "5fd4d319", "metadata": { "editable": true }, @@ -1005,7 +1005,7 @@ }, { "cell_type": "markdown", - "id": "87c53214", + "id": "64134feb", "metadata": { "editable": true }, @@ -1027,7 +1027,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "b36b4c64", + "id": "643f7a82", "metadata": { "collapsed": false, "editable": true @@ -1168,7 +1168,7 @@ }, { "cell_type": "markdown", - "id": "166220ac", + "id": "dfa32b7e", "metadata": { "editable": true }, @@ -1184,7 +1184,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "6e3221f8", + "id": "4b88b24e", "metadata": { "collapsed": false, "editable": true @@ -1197,7 +1197,7 @@ }, { "cell_type": "markdown", - "id": "44e094bb", + "id": "2eea0e52", "metadata": { "editable": true }, @@ -1209,7 +1209,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "e8e938bd", + "id": "090bee3c", "metadata": { "collapsed": false, "editable": true @@ -1231,7 +1231,7 @@ }, { "cell_type": "markdown", - "id": "7546f778", + "id": "e0eee286", "metadata": { "editable": true }, @@ -1247,7 +1247,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "55250ea2", + "id": "191224bb", "metadata": { "collapsed": false, "editable": true @@ -1285,7 +1285,7 @@ }, { "cell_type": "markdown", - "id": "6651b1cc", + "id": "7f4a0238", "metadata": { "editable": true }, @@ -1298,7 +1298,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "48d70de6", + "id": "d822b656", "metadata": { "collapsed": false, "editable": true @@ -1319,7 +1319,7 @@ }, { "cell_type": "markdown", - "id": "1763139f", + "id": "7ff32a3b", "metadata": { "editable": true }, @@ -1335,7 +1335,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "2cf6bda9", + "id": "90045474", "metadata": { "collapsed": false, "editable": true @@ -1393,7 +1393,7 @@ }, { "cell_type": "markdown", - "id": "9e48a5a2", + "id": "eec681dc", "metadata": { "editable": true }, @@ -1408,7 +1408,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "12995853", + "id": "a36d4506", "metadata": { "collapsed": false, "editable": true @@ -1429,7 +1429,7 @@ }, { "cell_type": "markdown", - "id": "63d3c5bd", + "id": "d2358581", "metadata": { "editable": true }, @@ -1453,7 +1453,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "7e0107d8", + "id": "9dd0b112", "metadata": { "collapsed": false, "editable": true @@ -1925,7 +1925,7 @@ }, { "cell_type": "markdown", - "id": "2bd145b9", + "id": "b5aaa66b", "metadata": { "editable": true }, @@ -1937,7 +1937,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "c7f3d7ad", + "id": "35f13536", "metadata": { "collapsed": false, "editable": true @@ -1981,7 +1981,7 @@ }, { "cell_type": "markdown", - "id": "312deebb", + "id": "12780998", "metadata": { "editable": true }, @@ -1997,7 +1997,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "9c4f1717", + "id": "3de4263c", "metadata": { "collapsed": false, "editable": true @@ -2012,7 +2012,7 @@ }, { "cell_type": "markdown", - "id": "825279d3", + "id": "e3ca1fb5", "metadata": { "editable": true }, @@ -2023,7 +2023,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "e6133768", + "id": "714229a9", "metadata": { "collapsed": false, "editable": true @@ -2038,7 +2038,7 @@ }, { "cell_type": "markdown", - "id": "d561f849", + "id": "2240c6b8", "metadata": { "editable": true }, @@ -2054,7 +2054,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "22a52980", + "id": "96f9f1ab", "metadata": { "collapsed": false, "editable": true @@ -2068,7 +2068,7 @@ }, { "cell_type": "markdown", - "id": "e0dba967", + "id": "21af3f64", "metadata": { "editable": true }, @@ -2083,7 +2083,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "d05f8035", + "id": "98f0055d", "metadata": { "collapsed": false, "editable": true @@ -2109,7 +2109,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "dc7b7fec", + "id": "fbd2675f", "metadata": { "collapsed": false, "editable": true @@ -2124,7 +2124,7 @@ }, { "cell_type": "markdown", - "id": "7bfd050a", + "id": "64ed3461", "metadata": { "editable": true }, @@ -2135,7 +2135,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "02b08ed6", + "id": "1cdc9d23", "metadata": { "collapsed": false, "editable": true @@ -2150,7 +2150,7 @@ }, { "cell_type": "markdown", - "id": "59b85b1b", + "id": "13e2f881", "metadata": { "editable": true }, @@ -2161,7 +2161,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "eebfa498", + "id": "c28f2181", "metadata": { "collapsed": false, "editable": true @@ -2181,7 +2181,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "cabc2b09", + "id": "3150b724", "metadata": { "collapsed": false, "editable": true @@ -2196,7 +2196,7 @@ }, { "cell_type": "markdown", - "id": "37d5b7bb", + "id": "17aebab2", "metadata": { "editable": true }, @@ -2211,7 +2211,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "ffc6fca1", + "id": "997c5001", "metadata": { "collapsed": false, "editable": true @@ -2248,7 +2248,7 @@ }, { "cell_type": "markdown", - "id": "cc530309", + "id": "43d805bc", "metadata": { "editable": true }, @@ -2261,7 +2261,7 @@ { "cell_type": "code", "execution_count": 30, - "id": "0d61131c", + "id": "4bbaf697", "metadata": { "collapsed": false, "editable": true @@ -2284,7 +2284,7 @@ }, { "cell_type": "markdown", - "id": "ce4ce787", + "id": "31e852a7", "metadata": { "editable": true }, @@ -2294,7 +2294,7 @@ }, { "cell_type": "markdown", - "id": "e5d7a6ab", + "id": "9792c0c3", "metadata": { "editable": true }, @@ -2321,7 +2321,7 @@ }, { "cell_type": "markdown", - "id": "56b23083", + "id": "9214a407", "metadata": { "editable": true }, @@ -2335,7 +2335,7 @@ }, { "cell_type": "markdown", - "id": "3f9d87d4", + "id": "40a78c33", "metadata": { "editable": true }, @@ -2352,7 +2352,7 @@ }, { "cell_type": "markdown", - "id": "ff7d3133", + "id": "42dae561", "metadata": { "editable": true }, @@ -2368,7 +2368,7 @@ }, { "cell_type": "markdown", - "id": "f387989d", + "id": "b4bf5f2e", "metadata": { "editable": true }, @@ -2380,7 +2380,7 @@ }, { "cell_type": "markdown", - "id": "d15b7ed8", + "id": "1f4f3eba", "metadata": { "editable": true }, @@ -2398,7 +2398,7 @@ }, { "cell_type": "markdown", - "id": "8b0ad0fb", + "id": "d799a47c", "metadata": { "editable": true }, @@ -2419,7 +2419,7 @@ }, { "cell_type": "markdown", - "id": "c33b7fca", + "id": "abb02959", "metadata": { "editable": true }, @@ -2436,7 +2436,7 @@ }, { "cell_type": "markdown", - "id": "d88cb1c8", + "id": "6468ecf8", "metadata": { "editable": true }, @@ -2448,7 +2448,7 @@ }, { "cell_type": "markdown", - "id": "13593649", + "id": "e7441b12", "metadata": { "editable": true }, @@ -2459,7 +2459,7 @@ }, { "cell_type": "markdown", - "id": "a5e615d0", + "id": "0ffd1c29", "metadata": { "editable": true }, @@ -2476,7 +2476,7 @@ }, { "cell_type": "markdown", - "id": "952778b9", + "id": "e55c8d3e", "metadata": { "editable": true }, @@ -2487,7 +2487,7 @@ }, { "cell_type": "markdown", - "id": "63c41a29", + "id": "8a940e88", "metadata": { "editable": true }, @@ -2503,7 +2503,7 @@ }, { "cell_type": "markdown", - "id": "95ebdbc4", + "id": "547613c0", "metadata": { "editable": true }, @@ -2515,7 +2515,7 @@ }, { "cell_type": "markdown", - "id": "48862a28", + "id": "826651d6", "metadata": { "editable": true }, @@ -2532,7 +2532,7 @@ }, { "cell_type": "markdown", - "id": "98174490", + "id": "870b960b", "metadata": { "editable": true }, @@ -2544,7 +2544,7 @@ }, { "cell_type": "markdown", - "id": "f3d8ced5", + "id": "5a8fd1e3", "metadata": { "editable": true }, @@ -2562,7 +2562,7 @@ }, { "cell_type": "markdown", - "id": "0cdbddeb", + "id": "55b4f286", "metadata": { "editable": true }, @@ -2572,7 +2572,7 @@ }, { "cell_type": "markdown", - "id": "8afed5da", + "id": "7e4f689b", "metadata": { "editable": true }, @@ -2584,7 +2584,7 @@ }, { "cell_type": "markdown", - "id": "b6cdd16d", + "id": "01e8e999", "metadata": { "editable": true }, @@ -2601,7 +2601,7 @@ }, { "cell_type": "markdown", - "id": "9423bac1", + "id": "7ccea9f1", "metadata": { "editable": true }, @@ -2613,7 +2613,7 @@ }, { "cell_type": "markdown", - "id": "e3ddd331", + "id": "47fde776", "metadata": { "editable": true }, @@ -2624,7 +2624,7 @@ }, { "cell_type": "markdown", - "id": "41278f19", + "id": "f7a8f626", "metadata": { "editable": true }, @@ -2636,7 +2636,7 @@ }, { "cell_type": "markdown", - "id": "8d0ce198", + "id": "66551df0", "metadata": { "editable": true }, @@ -2646,7 +2646,7 @@ }, { "cell_type": "markdown", - "id": "dc70817c", + "id": "c354ef4e", "metadata": { "editable": true }, @@ -2666,7 +2666,7 @@ }, { "cell_type": "markdown", - "id": "8c2e8dde", + "id": "a574c0b7", "metadata": { "editable": true }, @@ -2683,7 +2683,7 @@ }, { "cell_type": "markdown", - "id": "5ad2bff5", + "id": "22f440c8", "metadata": { "editable": true }, @@ -2702,7 +2702,7 @@ }, { "cell_type": "markdown", - "id": "5f845ba6", + "id": "0ff80a83", "metadata": { "editable": true }, @@ -2714,7 +2714,7 @@ }, { "cell_type": "markdown", - "id": "2604055d", + "id": "6829edab", "metadata": { "editable": true }, @@ -2724,7 +2724,7 @@ }, { "cell_type": "markdown", - "id": "b4ba9669", + "id": "381c61e2", "metadata": { "editable": true }, @@ -2741,7 +2741,7 @@ }, { "cell_type": "markdown", - "id": "875686e8", + "id": "ac36a03d", "metadata": { "editable": true }, @@ -2751,7 +2751,7 @@ }, { "cell_type": "markdown", - "id": "ee9f7d57", + "id": "2899becc", "metadata": { "editable": true }, @@ -2767,7 +2767,7 @@ }, { "cell_type": "markdown", - "id": "1e370697", + "id": "d52c8124", "metadata": { "editable": true }, @@ -2779,7 +2779,7 @@ }, { "cell_type": "markdown", - "id": "833f3b82", + "id": "3f8f684e", "metadata": { "editable": true }, @@ -2791,7 +2791,7 @@ }, { "cell_type": "markdown", - "id": "35da5498", + "id": "92cc16c9", "metadata": { "editable": true }, @@ -2803,7 +2803,7 @@ }, { "cell_type": "markdown", - "id": "b44a64f2", + "id": "628e0dfc", "metadata": { "editable": true }, @@ -2813,7 +2813,7 @@ }, { "cell_type": "markdown", - "id": "116b1937", + "id": "e54b4c6e", "metadata": { "editable": true }, @@ -2825,7 +2825,7 @@ }, { "cell_type": "markdown", - "id": "9ef6d929", + "id": "80dc48dd", "metadata": { "editable": true }, @@ -2842,7 +2842,7 @@ }, { "cell_type": "markdown", - "id": "bd901882", + "id": "e57a1d70", "metadata": { "editable": true }, @@ -2852,7 +2852,7 @@ }, { "cell_type": "markdown", - "id": "31348d62", + "id": "8ad67e57", "metadata": { "editable": true }, @@ -2864,7 +2864,7 @@ }, { "cell_type": "markdown", - "id": "ae4a794d", + "id": "4eed66ce", "metadata": { "editable": true }, @@ -2878,7 +2878,7 @@ }, { "cell_type": "markdown", - "id": "a4ca4b65", + "id": "9d652c56", "metadata": { "editable": true }, @@ -2894,7 +2894,7 @@ }, { "cell_type": "markdown", - "id": "6cd19213", + "id": "9a5a1ad7", "metadata": { "editable": true }, @@ -2906,7 +2906,7 @@ }, { "cell_type": "markdown", - "id": "e6d9fb88", + "id": "ed15e067", "metadata": { "editable": true }, @@ -2928,7 +2928,7 @@ }, { "cell_type": "markdown", - "id": "2b7229da", + "id": "827ac223", "metadata": { "editable": true }, @@ -2940,7 +2940,7 @@ }, { "cell_type": "markdown", - "id": "cd4f193b", + "id": "a0a7b13f", "metadata": { "editable": true }, @@ -2963,7 +2963,7 @@ }, { "cell_type": "markdown", - "id": "e475f927", + "id": "0879010a", "metadata": { "editable": true }, @@ -2979,7 +2979,7 @@ }, { "cell_type": "markdown", - "id": "95a91bdd", + "id": "66ac91b3", "metadata": { "editable": true }, @@ -2991,7 +2991,7 @@ }, { "cell_type": "markdown", - "id": "56c75c71", + "id": "470c74b5", "metadata": { "editable": true }, @@ -3015,7 +3015,7 @@ }, { "cell_type": "markdown", - "id": "0cc6d1a9", + "id": "bf5e6967", "metadata": { "editable": true }, @@ -3027,7 +3027,7 @@ }, { "cell_type": "markdown", - "id": "0175da6a", + "id": "766b88f8", "metadata": { "editable": true }, @@ -3048,7 +3048,7 @@ }, { "cell_type": "markdown", - "id": "5fe7bc0e", + "id": "5c114139", "metadata": { "editable": true }, @@ -3060,7 +3060,7 @@ }, { "cell_type": "markdown", - "id": "7f0577a4", + "id": "45596281", "metadata": { "editable": true }, @@ -3079,7 +3079,7 @@ }, { "cell_type": "markdown", - "id": "11c8c142", + "id": "2c1378fb", "metadata": { "editable": true }, @@ -3089,7 +3089,7 @@ }, { "cell_type": "markdown", - "id": "01ca4d08", + "id": "66a732e1", "metadata": { "editable": true }, @@ -3103,7 +3103,7 @@ }, { "cell_type": "markdown", - "id": "f5133d80", + "id": "fdf81225", "metadata": { "editable": true }, @@ -3115,7 +3115,7 @@ }, { "cell_type": "markdown", - "id": "c1e40110", + "id": "9bb52111", "metadata": { "editable": true }, @@ -3127,7 +3127,7 @@ }, { "cell_type": "markdown", - "id": "89f577fa", + "id": "f3e495b4", "metadata": { "editable": true }, @@ -3144,7 +3144,7 @@ }, { "cell_type": "markdown", - "id": "73db81fc", + "id": "adc904df", "metadata": { "editable": true }, @@ -3156,7 +3156,7 @@ }, { "cell_type": "markdown", - "id": "6956b9f1", + "id": "2d01b1b5", "metadata": { "editable": true }, @@ -3178,7 +3178,7 @@ }, { "cell_type": "markdown", - "id": "13e5d04c", + "id": "5077f4f7", "metadata": { "editable": true }, @@ -3193,7 +3193,7 @@ }, { "cell_type": "markdown", - "id": "dd560ef7", + "id": "fb01e943", "metadata": { "editable": true }, @@ -3204,7 +3204,7 @@ { "cell_type": "code", "execution_count": 31, - "id": "ac42510c", + "id": "6347e101", "metadata": { "collapsed": false, "editable": true @@ -3359,7 +3359,7 @@ }, { "cell_type": "markdown", - "id": "22aed435", + "id": "59e5acda", "metadata": { "editable": true }, @@ -3374,7 +3374,7 @@ { "cell_type": "code", "execution_count": 32, - "id": "96179484", + "id": "f1a60516", "metadata": { "collapsed": false, "editable": true @@ -3543,7 +3543,7 @@ }, { "cell_type": "markdown", - "id": "a0ff62a9", + "id": "807a375c", "metadata": { "editable": true }, @@ -3556,7 +3556,7 @@ }, { "cell_type": "markdown", - "id": "e9112c77", + "id": "d35839bb", "metadata": { "editable": true }, @@ -3573,7 +3573,7 @@ }, { "cell_type": "markdown", - "id": "cf582ad1", + "id": "2991d1fe", "metadata": { "editable": true }, @@ -3589,7 +3589,7 @@ }, { "cell_type": "markdown", - "id": "d945a6b3", + "id": "ee668a71", "metadata": { "editable": true }, @@ -3602,7 +3602,7 @@ }, { "cell_type": "markdown", - "id": "e98cd638", + "id": "febf10cc", "metadata": { "editable": true }, @@ -3619,7 +3619,7 @@ }, { "cell_type": "markdown", - "id": "8b5c6044", + "id": "494194e3", "metadata": { "editable": true }, @@ -3631,7 +3631,7 @@ }, { "cell_type": "markdown", - "id": "74c055d2", + "id": "5efa7b11", "metadata": { "editable": true }, @@ -3658,7 +3658,7 @@ }, { "cell_type": "markdown", - "id": "a65e3069", + "id": "568131dc", "metadata": { "editable": true }, @@ -3671,7 +3671,7 @@ { "cell_type": "code", "execution_count": 33, - "id": "b092c21e", + "id": "8737e028", "metadata": { "collapsed": false, "editable": true @@ -3850,7 +3850,7 @@ }, { "cell_type": "markdown", - "id": "1aa71f38", + "id": "0904f64d", "metadata": { "editable": true }, @@ -3870,7 +3870,7 @@ }, { "cell_type": "markdown", - "id": "9d1de21f", + "id": "6f3577a8", "metadata": { "editable": true }, @@ -3885,7 +3885,7 @@ }, { "cell_type": "markdown", - "id": "826b08a1", + "id": "56d4410b", "metadata": { "editable": true }, @@ -3899,7 +3899,7 @@ }, { "cell_type": "markdown", - "id": "c4493848", + "id": "48d2707e", "metadata": { "editable": true }, @@ -3915,7 +3915,7 @@ }, { "cell_type": "markdown", - "id": "e37b66c6", + "id": "66d99f85", "metadata": { "editable": true }, @@ -3925,7 +3925,7 @@ }, { "cell_type": "markdown", - "id": "264abdcc", + "id": "3c9447d9", "metadata": { "editable": true }, @@ -3947,7 +3947,7 @@ }, { "cell_type": "markdown", - "id": "afc2e4cc", + "id": "724b97f1", "metadata": { "editable": true }, @@ -3961,7 +3961,7 @@ { "cell_type": "code", "execution_count": 34, - "id": "63c572f6", + "id": "58b0da70", "metadata": { "collapsed": false, "editable": true @@ -4037,7 +4037,7 @@ }, { "cell_type": "markdown", - "id": "6381dfa2", + "id": "f1230dee", "metadata": { "editable": true }, @@ -4049,7 +4049,7 @@ }, { "cell_type": "markdown", - "id": "ddcc006d", + "id": "ba2c6d0a", "metadata": { "editable": true }, @@ -4066,7 +4066,7 @@ }, { "cell_type": "markdown", - "id": "85639943", + "id": "bab1c7d3", "metadata": { "editable": true }, @@ -4078,7 +4078,7 @@ }, { "cell_type": "markdown", - "id": "f17eea8d", + "id": "42bfde23", "metadata": { "editable": true }, @@ -4093,7 +4093,7 @@ }, { "cell_type": "markdown", - "id": "1efed335", + "id": "7b3a2504", "metadata": { "editable": true }, @@ -4105,7 +4105,7 @@ }, { "cell_type": "markdown", - "id": "23e866a2", + "id": "a419909c", "metadata": { "editable": true }, @@ -4117,7 +4117,7 @@ }, { "cell_type": "markdown", - "id": "2cfcda87", + "id": "125f8197", "metadata": { "editable": true }, @@ -4129,7 +4129,7 @@ }, { "cell_type": "markdown", - "id": "b2a2d58c", + "id": "16376b60", "metadata": { "editable": true }, @@ -4139,7 +4139,7 @@ }, { "cell_type": "markdown", - "id": "a7c84b58", + "id": "044c76ec", "metadata": { "editable": true }, @@ -4156,7 +4156,7 @@ }, { "cell_type": "markdown", - "id": "9db2324e", + "id": "0ec4860b", "metadata": { "editable": true }, @@ -4168,7 +4168,7 @@ }, { "cell_type": "markdown", - "id": "f94f8d1a", + "id": "03e27ec0", "metadata": { "editable": true }, @@ -4180,7 +4180,7 @@ }, { "cell_type": "markdown", - "id": "e8eaba06", + "id": "82fdb51f", "metadata": { "editable": true }, @@ -4190,7 +4190,7 @@ }, { "cell_type": "markdown", - "id": "3c345647", + "id": "82e39d0e", "metadata": { "editable": true }, @@ -4202,7 +4202,7 @@ }, { "cell_type": "markdown", - "id": "0d913be0", + "id": "bf029e6c", "metadata": { "editable": true }, @@ -4213,7 +4213,7 @@ { "cell_type": "code", "execution_count": 35, - "id": "96194d94", + "id": "e10d7641", "metadata": { "collapsed": false, "editable": true @@ -4378,7 +4378,7 @@ }, { "cell_type": "markdown", - "id": "780c5c66", + "id": "82891392", "metadata": { "editable": true }, @@ -4400,7 +4400,7 @@ }, { "cell_type": "markdown", - "id": "b6dfbfdc", + "id": "ad4ef510", "metadata": { "editable": true }, @@ -4417,7 +4417,7 @@ }, { "cell_type": "markdown", - "id": "011ba117", + "id": "eb8ab804", "metadata": { "editable": true }, @@ -4427,7 +4427,7 @@ }, { "cell_type": "markdown", - "id": "cdf079bc", + "id": "f9b7b2a0", "metadata": { "editable": true }, @@ -4442,7 +4442,7 @@ }, { "cell_type": "markdown", - "id": "bf2fc40c", + "id": "6a71c7bb", "metadata": { "editable": true }, @@ -4452,7 +4452,7 @@ }, { "cell_type": "markdown", - "id": "6662f05c", + "id": "d19780a8", "metadata": { "editable": true }, @@ -4467,7 +4467,7 @@ }, { "cell_type": "markdown", - "id": "fe9a0465", + "id": "00fedc6e", "metadata": { "editable": true }, @@ -4478,7 +4478,7 @@ }, { "cell_type": "markdown", - "id": "7603ea9a", + "id": "28005c86", "metadata": { "editable": true }, @@ -4498,7 +4498,7 @@ }, { "cell_type": "markdown", - "id": "6744dfef", + "id": "d562bb0c", "metadata": { "editable": true }, @@ -4510,7 +4510,7 @@ }, { "cell_type": "markdown", - "id": "af13fca6", + "id": "bdee81e4", "metadata": { "editable": true }, @@ -4547,7 +4547,7 @@ }, { "cell_type": "markdown", - "id": "bd1bd149", + "id": "ddf436f5", "metadata": { "editable": true }, @@ -4557,7 +4557,7 @@ }, { "cell_type": "markdown", - "id": "43e51ef4", + "id": "66ae2d44", "metadata": { "editable": true }, @@ -4570,7 +4570,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "49c94dd9", + "id": "17f02a24", "metadata": { "collapsed": false, "editable": true @@ -4775,7 +4775,7 @@ }, { "cell_type": "markdown", - "id": "6d27256f", + "id": "51ee4433", "metadata": { "editable": true }, @@ -4792,7 +4792,7 @@ }, { "cell_type": "markdown", - "id": "df08a8ac", + "id": "1ec16aab", "metadata": { "editable": true }, @@ -4809,7 +4809,7 @@ }, { "cell_type": "markdown", - "id": "ec4b9fd4", + "id": "64fd215d", "metadata": { "editable": true }, @@ -4819,7 +4819,7 @@ }, { "cell_type": "markdown", - "id": "92f17705", + "id": "3efab799", "metadata": { "editable": true }, @@ -4834,7 +4834,7 @@ }, { "cell_type": "markdown", - "id": "eec1785d", + "id": "80e6d77c", "metadata": { "editable": true }, @@ -4848,7 +4848,7 @@ }, { "cell_type": "markdown", - "id": "544c3fce", + "id": "f08a42bd", "metadata": { "editable": true }, @@ -4861,7 +4861,7 @@ }, { "cell_type": "markdown", - "id": "74af5618", + "id": "af035b50", "metadata": { "editable": true }, @@ -4881,7 +4881,7 @@ }, { "cell_type": "markdown", - "id": "9a7c5864", + "id": "ee147dfb", "metadata": { "editable": true }, @@ -4893,7 +4893,7 @@ }, { "cell_type": "markdown", - "id": "3f2d680d", + "id": "850e95ed", "metadata": { "editable": true }, @@ -4905,7 +4905,7 @@ }, { "cell_type": "markdown", - "id": "118044b0", + "id": "96f9cca4", "metadata": { "editable": true }, @@ -4917,7 +4917,7 @@ }, { "cell_type": "markdown", - "id": "e9b82be4", + "id": "70394cae", "metadata": { "editable": true }, @@ -4927,7 +4927,7 @@ }, { "cell_type": "markdown", - "id": "d5e6b103", + "id": "d06e6c30", "metadata": { "editable": true }, @@ -4939,7 +4939,7 @@ }, { "cell_type": "markdown", - "id": "c9dec199", + "id": "b4972f88", "metadata": { "editable": true }, @@ -4951,7 +4951,7 @@ }, { "cell_type": "markdown", - "id": "118d2522", + "id": "3d35cbd3", "metadata": { "editable": true }, @@ -4963,7 +4963,7 @@ }, { "cell_type": "markdown", - "id": "1d13aaff", + "id": "984bf645", "metadata": { "editable": true }, @@ -4973,7 +4973,7 @@ }, { "cell_type": "markdown", - "id": "4de9c463", + "id": "9d58d0ec", "metadata": { "editable": true }, @@ -4989,7 +4989,7 @@ }, { "cell_type": "markdown", - "id": "65b2ba09", + "id": "99cf8f47", "metadata": { "editable": true }, @@ -4999,7 +4999,7 @@ }, { "cell_type": "markdown", - "id": "843d90aa", + "id": "777ad3a8", "metadata": { "editable": true }, @@ -5011,7 +5011,7 @@ }, { "cell_type": "markdown", - "id": "77447bcd", + "id": "7182b747", "metadata": { "editable": true }, @@ -5028,7 +5028,7 @@ }, { "cell_type": "markdown", - "id": "c3cf90aa", + "id": "3c40d528", "metadata": { "editable": true }, @@ -5038,7 +5038,7 @@ }, { "cell_type": "markdown", - "id": "257d1f48", + "id": "7cb1e15a", "metadata": { "editable": true }, @@ -5054,7 +5054,7 @@ }, { "cell_type": "markdown", - "id": "7f4f7d6a", + "id": "5c4bcdb5", "metadata": { "editable": true }, @@ -5068,7 +5068,7 @@ }, { "cell_type": "markdown", - "id": "1e0c143a", + "id": "c84ff432", "metadata": { "editable": true }, @@ -5087,7 +5087,7 @@ { "cell_type": "code", "execution_count": 37, - "id": "e52c49e9", + "id": "ba62ab4c", "metadata": { "collapsed": false, "editable": true @@ -5142,7 +5142,7 @@ }, { "cell_type": "markdown", - "id": "e6975906", + "id": "7fd9e6dc", "metadata": { "editable": true }, @@ -5172,7 +5172,7 @@ }, { "cell_type": "markdown", - "id": "d665f51c", + "id": "6c63c928", "metadata": { "editable": true }, @@ -5201,7 +5201,7 @@ { "cell_type": "code", "execution_count": 38, - "id": "152c290e", + "id": "4192bf3d", "metadata": { "collapsed": false, "editable": true @@ -5248,7 +5248,7 @@ }, { "cell_type": "markdown", - "id": "eac82d2c", + "id": "87f8417d", "metadata": { "editable": true }, @@ -5274,7 +5274,7 @@ { "cell_type": "code", "execution_count": 39, - "id": "df3d9605", + "id": "1572e93b", "metadata": { "collapsed": false, "editable": true @@ -5508,7 +5508,7 @@ }, { "cell_type": "markdown", - "id": "fec03008", + "id": "bf7afd74", "metadata": { "editable": true }, @@ -5520,7 +5520,7 @@ }, { "cell_type": "markdown", - "id": "403f7560", + "id": "fdef78b2", "metadata": { "editable": true }, @@ -5532,7 +5532,7 @@ }, { "cell_type": "markdown", - "id": "dc05badf", + "id": "be570613", "metadata": { "editable": true }, @@ -5544,7 +5544,7 @@ }, { "cell_type": "markdown", - "id": "1daf1dd8", + "id": "9f81e04f", "metadata": { "editable": true }, @@ -5561,7 +5561,7 @@ }, { "cell_type": "markdown", - "id": "4da632df", + "id": "91171d8b", "metadata": { "editable": true }, @@ -5571,7 +5571,7 @@ }, { "cell_type": "markdown", - "id": "851bb943", + "id": "dbbbb8a5", "metadata": { "editable": true }, @@ -5583,7 +5583,7 @@ }, { "cell_type": "markdown", - "id": "760b72fe", + "id": "3f1be58e", "metadata": { "editable": true }, @@ -5600,7 +5600,7 @@ }, { "cell_type": "markdown", - "id": "e3e22598", + "id": "d54c4188", "metadata": { "editable": true }, @@ -5611,7 +5611,7 @@ }, { "cell_type": "markdown", - "id": "59f39060", + "id": "952c58e8", "metadata": { "editable": true }, @@ -5631,7 +5631,7 @@ }, { "cell_type": "markdown", - "id": "bf3a2904", + "id": "a650bae2", "metadata": { "editable": true }, @@ -5641,7 +5641,7 @@ }, { "cell_type": "markdown", - "id": "4a633f01", + "id": "9e0b8996", "metadata": { "editable": true }, @@ -5667,7 +5667,7 @@ }, { "cell_type": "markdown", - "id": "c09dc6a7", + "id": "0f3f1985", "metadata": { "editable": true }, @@ -5683,7 +5683,7 @@ }, { "cell_type": "markdown", - "id": "592d4d57", + "id": "fbd35329", "metadata": { "editable": true }, @@ -5694,7 +5694,7 @@ { "cell_type": "code", "execution_count": 40, - "id": "1c25dc4e", + "id": "6ccf9344", "metadata": { "collapsed": false, "editable": true @@ -5925,7 +5925,7 @@ }, { "cell_type": "markdown", - "id": "5072a8bd", + "id": "988e09cf", "metadata": { "editable": true }, diff --git a/doc/src/week43/week43.do.txt b/doc/src/week43/week43.do.txt index 1fccfd4e0..529cd1bdc 100644 --- a/doc/src/week43/week43.do.txt +++ b/doc/src/week43/week43.do.txt @@ -6,7 +6,7 @@ DATE: October 20, 2025 ===== Plans for week 43 ===== !bblock Material for the lecture on Monday October 20, 2025 -o Reminder from last week, see lalso ecture notes from week 42 at URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html" as well as those from week 41, see see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". +o Reminder from last week, see also lecture notes from week 42 at URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week42.html" as well as those from week 41, see see URL:"https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/week41.html". o Building our own Feed-forward Neural Network. o Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13.. o Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well. From 237605984dc77828f1724807025ea2ef6eb62faf Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 08:00:17 +0200 Subject: [PATCH 06/14] updating links --- .../_build/.doctrees/environment.pickle | Bin 473882 -> 473882 bytes doc/LectureNotes/week43.ipynb | 490 +++++++++--------- 2 files changed, 245 insertions(+), 245 deletions(-) diff --git a/doc/LectureNotes/_build/.doctrees/environment.pickle b/doc/LectureNotes/_build/.doctrees/environment.pickle index 9fcf28611fd201a8eb3dca60a22e130702ac2cc9..b80b16b8fad4022a6802bdde5e4e5696786513fa 100644 GIT binary patch delta 17786 zcmZ8pd082eI1 zQA??%mZFPVYiU*6Px;O{Gw+f9Gxv9vnLBgNnKN_eWwP|okfncyY~9$iWZwRR6NjfI zjf}3Aota1B+S!@b*rcQ()oa+3dKWEL;~i0ScBZ#RbT)6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W9L41dnH1<)!RWSBygyx)imyobq~d+)l2p7m-H?j+ zpzBfbK6E!Kz9e0YiZ|$1RD5x|5(U-qJ`~9CG9hTT_;e*i%#&sTTZ~lD^Ac8UT=!`qq|MNf zQIB;KNnwr%g%;BL*1wd12VOXY2i`V>2VOOV2i`M;2VOFS2i`D*2VO6P2i`4&2QDOd z;6j22E+ly1LV^e0C4>iFB!mYpBzWLLf(I=mc;f9rc;MARc;G^U2QDOdVCcdF7ZN;h zA;AL|5AgXd%H9?*YOC?^MI1 z6<<@=5l5DBQHF7mU0h@q7g@zcMsbl%Tx1d#S;R#KagjY-WDXZu!$rn$ku6+giVU)Z ziwxnSdz3D+f{Toh;cSl!$VE1AkqI)$0xmLui{|g5>1WXFT{QU&ntKLK-9D5MfV?FG-nr0*+o|#T@#1L#J@9f_!PYE7`5UZ@u;4okg=xxMuelc1O1hg)z*A6 syd6)k@9=~_Y%i$q=wTdQ0hcAe6Tj4Ve8W7?GaxQvaY1Zr=x`eU55_)zHvj+t diff --git a/doc/LectureNotes/week43.ipynb b/doc/LectureNotes/week43.ipynb index 3e86d5cdb..8d5235416 100644 --- a/doc/LectureNotes/week43.ipynb +++ b/doc/LectureNotes/week43.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "8c52cd3b", + "id": "b10156d4", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "846eee41", + "id": "f85baa2f", "metadata": { "editable": true }, @@ -27,7 +27,7 @@ }, { "cell_type": "markdown", - "id": "ff057bd5", + "id": "543fad4a", "metadata": { "editable": true }, @@ -36,7 +36,7 @@ "\n", "**Material for the lecture on Monday October 20, 2025.**\n", "\n", - "1. Reminder from last week, see lalso ecture notes from week 42 at as well as those from week 41, see see . \n", + "1. Reminder from last week, see also lecture notes from week 42 at as well as those from week 41, see see . \n", "\n", "2. Building our own Feed-forward Neural Network.\n", "\n", @@ -49,7 +49,7 @@ }, { "cell_type": "markdown", - "id": "8d1fd0b3", + "id": "72acb4e9", "metadata": { "editable": true }, @@ -64,7 +64,7 @@ }, { "cell_type": "markdown", - "id": "4990faa2", + "id": "361768dc", "metadata": { "editable": true }, @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "76cb0250", + "id": "3e058671", "metadata": { "editable": true }, @@ -94,7 +94,7 @@ }, { "cell_type": "markdown", - "id": "5bdfe8a0", + "id": "8cbbf2bf", "metadata": { "editable": true }, @@ -104,7 +104,7 @@ }, { "cell_type": "markdown", - "id": "b78c27be", + "id": "78e2de21", "metadata": { "editable": true }, @@ -131,7 +131,7 @@ }, { "cell_type": "markdown", - "id": "db515eac", + "id": "41a3dc23", "metadata": { "editable": true }, @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "0d9e2c6d", + "id": "0e4ac2c0", "metadata": { "editable": true }, @@ -166,7 +166,7 @@ }, { "cell_type": "markdown", - "id": "c54ddbb9", + "id": "e9fd2f83", "metadata": { "editable": true }, @@ -178,7 +178,7 @@ }, { "cell_type": "markdown", - "id": "0a074eb8", + "id": "16e2b900", "metadata": { "editable": true }, @@ -188,7 +188,7 @@ }, { "cell_type": "markdown", - "id": "2916e7ad", + "id": "f9f4b9d8", "metadata": { "editable": true }, @@ -200,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "fc87090a", + "id": "01be6441", "metadata": { "editable": true }, @@ -214,7 +214,7 @@ }, { "cell_type": "markdown", - "id": "0fab3976", + "id": "ce898b85", "metadata": { "editable": true }, @@ -226,7 +226,7 @@ }, { "cell_type": "markdown", - "id": "506b036e", + "id": "4e2e7314", "metadata": { "editable": true }, @@ -238,7 +238,7 @@ }, { "cell_type": "markdown", - "id": "7230ebb2", + "id": "b7114295", "metadata": { "editable": true }, @@ -248,7 +248,7 @@ }, { "cell_type": "markdown", - "id": "24dcabf8", + "id": "69dfa048", "metadata": { "editable": true }, @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "769b4b46", + "id": "6efa469c", "metadata": { "editable": true }, @@ -272,7 +272,7 @@ }, { "cell_type": "markdown", - "id": "0eb6e407", + "id": "076e4937", "metadata": { "editable": true }, @@ -282,7 +282,7 @@ }, { "cell_type": "markdown", - "id": "dd2caf09", + "id": "1072f5a1", "metadata": { "editable": true }, @@ -294,7 +294,7 @@ }, { "cell_type": "markdown", - "id": "3ca5122d", + "id": "f77a7074", "metadata": { "editable": true }, @@ -306,7 +306,7 @@ }, { "cell_type": "markdown", - "id": "0297fbd7", + "id": "f12effab", "metadata": { "editable": true }, @@ -329,7 +329,7 @@ }, { "cell_type": "markdown", - "id": "093209ef", + "id": "31eb54b1", "metadata": { "editable": true }, @@ -341,7 +341,7 @@ }, { "cell_type": "markdown", - "id": "52cacfbe", + "id": "7a549168", "metadata": { "editable": true }, @@ -353,7 +353,7 @@ }, { "cell_type": "markdown", - "id": "3ac82bdf", + "id": "ce35ae73", "metadata": { "editable": true }, @@ -363,7 +363,7 @@ }, { "cell_type": "markdown", - "id": "e3f9be3c", + "id": "d6cdfc89", "metadata": { "editable": true }, @@ -375,7 +375,7 @@ }, { "cell_type": "markdown", - "id": "fdb953a2", + "id": "ddd59bb0", "metadata": { "editable": true }, @@ -396,7 +396,7 @@ }, { "cell_type": "markdown", - "id": "0d8677dd", + "id": "f2a78e55", "metadata": { "editable": true }, @@ -410,7 +410,7 @@ }, { "cell_type": "markdown", - "id": "6d2d4dcc", + "id": "cde73faf", "metadata": { "editable": true }, @@ -422,7 +422,7 @@ }, { "cell_type": "markdown", - "id": "e17fbd6e", + "id": "08048672", "metadata": { "editable": true }, @@ -444,7 +444,7 @@ }, { "cell_type": "markdown", - "id": "4464d159", + "id": "a7085280", "metadata": { "editable": true }, @@ -466,7 +466,7 @@ }, { "cell_type": "markdown", - "id": "d7dacac8", + "id": "291e4fb2", "metadata": { "editable": true }, @@ -484,7 +484,7 @@ }, { "cell_type": "markdown", - "id": "cb79f5a6", + "id": "a8c5f4c2", "metadata": { "editable": true }, @@ -519,7 +519,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "44cf829e", + "id": "9a0aac03", "metadata": { "collapsed": false, "editable": true @@ -531,7 +531,7 @@ }, { "cell_type": "markdown", - "id": "bdf6f4be", + "id": "ca0c7865", "metadata": { "editable": true }, @@ -543,7 +543,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "784ed3b7", + "id": "d0c581f7", "metadata": { "collapsed": false, "editable": true @@ -556,7 +556,7 @@ }, { "cell_type": "markdown", - "id": "30a63e04", + "id": "fe086bc9", "metadata": { "editable": true }, @@ -567,7 +567,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "5ecbf45a", + "id": "f551fad9", "metadata": { "collapsed": false, "editable": true @@ -580,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "4a0568e9", + "id": "58152cef", "metadata": { "editable": true }, @@ -595,7 +595,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "9982df74", + "id": "579b6a4a", "metadata": { "collapsed": false, "editable": true @@ -607,7 +607,7 @@ }, { "cell_type": "markdown", - "id": "b81f34fd", + "id": "5da15206", "metadata": { "editable": true }, @@ -619,7 +619,7 @@ }, { "cell_type": "markdown", - "id": "cf68391d", + "id": "cc970d32", "metadata": { "editable": true }, @@ -632,7 +632,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "2594d47b", + "id": "a4f2c8a8", "metadata": { "collapsed": false, "editable": true @@ -689,7 +689,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "060f0b22", + "id": "d0c06f34", "metadata": { "collapsed": false, "editable": true @@ -718,7 +718,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "5491ac4f", + "id": "8272ca95", "metadata": { "collapsed": false, "editable": true @@ -748,7 +748,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "905a1d27", + "id": "616613a7", "metadata": { "collapsed": false, "editable": true @@ -775,7 +775,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "491849b6", + "id": "f57a7b70", "metadata": { "collapsed": false, "editable": true @@ -817,7 +817,7 @@ }, { "cell_type": "markdown", - "id": "25bfc059", + "id": "a61b50a8", "metadata": { "editable": true }, @@ -828,7 +828,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "29c660b4", + "id": "d220a7ad", "metadata": { "collapsed": false, "editable": true @@ -915,7 +915,7 @@ }, { "cell_type": "markdown", - "id": "50468253", + "id": "d87d7514", "metadata": { "editable": true }, @@ -926,7 +926,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "1e430607", + "id": "c6df6115", "metadata": { "collapsed": false, "editable": true @@ -986,7 +986,7 @@ }, { "cell_type": "markdown", - "id": "44c02ba1", + "id": "5fd4d319", "metadata": { "editable": true }, @@ -1005,7 +1005,7 @@ }, { "cell_type": "markdown", - "id": "87c53214", + "id": "64134feb", "metadata": { "editable": true }, @@ -1027,7 +1027,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "b36b4c64", + "id": "643f7a82", "metadata": { "collapsed": false, "editable": true @@ -1168,7 +1168,7 @@ }, { "cell_type": "markdown", - "id": "166220ac", + "id": "dfa32b7e", "metadata": { "editable": true }, @@ -1184,7 +1184,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "6e3221f8", + "id": "4b88b24e", "metadata": { "collapsed": false, "editable": true @@ -1197,7 +1197,7 @@ }, { "cell_type": "markdown", - "id": "44e094bb", + "id": "2eea0e52", "metadata": { "editable": true }, @@ -1209,7 +1209,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "e8e938bd", + "id": "090bee3c", "metadata": { "collapsed": false, "editable": true @@ -1231,7 +1231,7 @@ }, { "cell_type": "markdown", - "id": "7546f778", + "id": "e0eee286", "metadata": { "editable": true }, @@ -1247,7 +1247,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "55250ea2", + "id": "191224bb", "metadata": { "collapsed": false, "editable": true @@ -1285,7 +1285,7 @@ }, { "cell_type": "markdown", - "id": "6651b1cc", + "id": "7f4a0238", "metadata": { "editable": true }, @@ -1298,7 +1298,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "48d70de6", + "id": "d822b656", "metadata": { "collapsed": false, "editable": true @@ -1319,7 +1319,7 @@ }, { "cell_type": "markdown", - "id": "1763139f", + "id": "7ff32a3b", "metadata": { "editable": true }, @@ -1335,7 +1335,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "2cf6bda9", + "id": "90045474", "metadata": { "collapsed": false, "editable": true @@ -1393,7 +1393,7 @@ }, { "cell_type": "markdown", - "id": "9e48a5a2", + "id": "eec681dc", "metadata": { "editable": true }, @@ -1408,7 +1408,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "12995853", + "id": "a36d4506", "metadata": { "collapsed": false, "editable": true @@ -1429,7 +1429,7 @@ }, { "cell_type": "markdown", - "id": "63d3c5bd", + "id": "d2358581", "metadata": { "editable": true }, @@ -1453,7 +1453,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "7e0107d8", + "id": "9dd0b112", "metadata": { "collapsed": false, "editable": true @@ -1925,7 +1925,7 @@ }, { "cell_type": "markdown", - "id": "2bd145b9", + "id": "b5aaa66b", "metadata": { "editable": true }, @@ -1937,7 +1937,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "c7f3d7ad", + "id": "35f13536", "metadata": { "collapsed": false, "editable": true @@ -1981,7 +1981,7 @@ }, { "cell_type": "markdown", - "id": "312deebb", + "id": "12780998", "metadata": { "editable": true }, @@ -1997,7 +1997,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "9c4f1717", + "id": "3de4263c", "metadata": { "collapsed": false, "editable": true @@ -2012,7 +2012,7 @@ }, { "cell_type": "markdown", - "id": "825279d3", + "id": "e3ca1fb5", "metadata": { "editable": true }, @@ -2023,7 +2023,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "e6133768", + "id": "714229a9", "metadata": { "collapsed": false, "editable": true @@ -2038,7 +2038,7 @@ }, { "cell_type": "markdown", - "id": "d561f849", + "id": "2240c6b8", "metadata": { "editable": true }, @@ -2054,7 +2054,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "22a52980", + "id": "96f9f1ab", "metadata": { "collapsed": false, "editable": true @@ -2068,7 +2068,7 @@ }, { "cell_type": "markdown", - "id": "e0dba967", + "id": "21af3f64", "metadata": { "editable": true }, @@ -2083,7 +2083,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "d05f8035", + "id": "98f0055d", "metadata": { "collapsed": false, "editable": true @@ -2109,7 +2109,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "dc7b7fec", + "id": "fbd2675f", "metadata": { "collapsed": false, "editable": true @@ -2124,7 +2124,7 @@ }, { "cell_type": "markdown", - "id": "7bfd050a", + "id": "64ed3461", "metadata": { "editable": true }, @@ -2135,7 +2135,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "02b08ed6", + "id": "1cdc9d23", "metadata": { "collapsed": false, "editable": true @@ -2150,7 +2150,7 @@ }, { "cell_type": "markdown", - "id": "59b85b1b", + "id": "13e2f881", "metadata": { "editable": true }, @@ -2161,7 +2161,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "eebfa498", + "id": "c28f2181", "metadata": { "collapsed": false, "editable": true @@ -2181,7 +2181,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "cabc2b09", + "id": "3150b724", "metadata": { "collapsed": false, "editable": true @@ -2196,7 +2196,7 @@ }, { "cell_type": "markdown", - "id": "37d5b7bb", + "id": "17aebab2", "metadata": { "editable": true }, @@ -2211,7 +2211,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "ffc6fca1", + "id": "997c5001", "metadata": { "collapsed": false, "editable": true @@ -2248,7 +2248,7 @@ }, { "cell_type": "markdown", - "id": "cc530309", + "id": "43d805bc", "metadata": { "editable": true }, @@ -2261,7 +2261,7 @@ { "cell_type": "code", "execution_count": 30, - "id": "0d61131c", + "id": "4bbaf697", "metadata": { "collapsed": false, "editable": true @@ -2284,7 +2284,7 @@ }, { "cell_type": "markdown", - "id": "ce4ce787", + "id": "31e852a7", "metadata": { "editable": true }, @@ -2294,7 +2294,7 @@ }, { "cell_type": "markdown", - "id": "e5d7a6ab", + "id": "9792c0c3", "metadata": { "editable": true }, @@ -2321,7 +2321,7 @@ }, { "cell_type": "markdown", - "id": "56b23083", + "id": "9214a407", "metadata": { "editable": true }, @@ -2335,7 +2335,7 @@ }, { "cell_type": "markdown", - "id": "3f9d87d4", + "id": "40a78c33", "metadata": { "editable": true }, @@ -2352,7 +2352,7 @@ }, { "cell_type": "markdown", - "id": "ff7d3133", + "id": "42dae561", "metadata": { "editable": true }, @@ -2368,7 +2368,7 @@ }, { "cell_type": "markdown", - "id": "f387989d", + "id": "b4bf5f2e", "metadata": { "editable": true }, @@ -2380,7 +2380,7 @@ }, { "cell_type": "markdown", - "id": "d15b7ed8", + "id": "1f4f3eba", "metadata": { "editable": true }, @@ -2398,7 +2398,7 @@ }, { "cell_type": "markdown", - "id": "8b0ad0fb", + "id": "d799a47c", "metadata": { "editable": true }, @@ -2419,7 +2419,7 @@ }, { "cell_type": "markdown", - "id": "c33b7fca", + "id": "abb02959", "metadata": { "editable": true }, @@ -2436,7 +2436,7 @@ }, { "cell_type": "markdown", - "id": "d88cb1c8", + "id": "6468ecf8", "metadata": { "editable": true }, @@ -2448,7 +2448,7 @@ }, { "cell_type": "markdown", - "id": "13593649", + "id": "e7441b12", "metadata": { "editable": true }, @@ -2459,7 +2459,7 @@ }, { "cell_type": "markdown", - "id": "a5e615d0", + "id": "0ffd1c29", "metadata": { "editable": true }, @@ -2476,7 +2476,7 @@ }, { "cell_type": "markdown", - "id": "952778b9", + "id": "e55c8d3e", "metadata": { "editable": true }, @@ -2487,7 +2487,7 @@ }, { "cell_type": "markdown", - "id": "63c41a29", + "id": "8a940e88", "metadata": { "editable": true }, @@ -2503,7 +2503,7 @@ }, { "cell_type": "markdown", - "id": "95ebdbc4", + "id": "547613c0", "metadata": { "editable": true }, @@ -2515,7 +2515,7 @@ }, { "cell_type": "markdown", - "id": "48862a28", + "id": "826651d6", "metadata": { "editable": true }, @@ -2532,7 +2532,7 @@ }, { "cell_type": "markdown", - "id": "98174490", + "id": "870b960b", "metadata": { "editable": true }, @@ -2544,7 +2544,7 @@ }, { "cell_type": "markdown", - "id": "f3d8ced5", + "id": "5a8fd1e3", "metadata": { "editable": true }, @@ -2562,7 +2562,7 @@ }, { "cell_type": "markdown", - "id": "0cdbddeb", + "id": "55b4f286", "metadata": { "editable": true }, @@ -2572,7 +2572,7 @@ }, { "cell_type": "markdown", - "id": "8afed5da", + "id": "7e4f689b", "metadata": { "editable": true }, @@ -2584,7 +2584,7 @@ }, { "cell_type": "markdown", - "id": "b6cdd16d", + "id": "01e8e999", "metadata": { "editable": true }, @@ -2601,7 +2601,7 @@ }, { "cell_type": "markdown", - "id": "9423bac1", + "id": "7ccea9f1", "metadata": { "editable": true }, @@ -2613,7 +2613,7 @@ }, { "cell_type": "markdown", - "id": "e3ddd331", + "id": "47fde776", "metadata": { "editable": true }, @@ -2624,7 +2624,7 @@ }, { "cell_type": "markdown", - "id": "41278f19", + "id": "f7a8f626", "metadata": { "editable": true }, @@ -2636,7 +2636,7 @@ }, { "cell_type": "markdown", - "id": "8d0ce198", + "id": "66551df0", "metadata": { "editable": true }, @@ -2646,7 +2646,7 @@ }, { "cell_type": "markdown", - "id": "dc70817c", + "id": "c354ef4e", "metadata": { "editable": true }, @@ -2666,7 +2666,7 @@ }, { "cell_type": "markdown", - "id": "8c2e8dde", + "id": "a574c0b7", "metadata": { "editable": true }, @@ -2683,7 +2683,7 @@ }, { "cell_type": "markdown", - "id": "5ad2bff5", + "id": "22f440c8", "metadata": { "editable": true }, @@ -2702,7 +2702,7 @@ }, { "cell_type": "markdown", - "id": "5f845ba6", + "id": "0ff80a83", "metadata": { "editable": true }, @@ -2714,7 +2714,7 @@ }, { "cell_type": "markdown", - "id": "2604055d", + "id": "6829edab", "metadata": { "editable": true }, @@ -2724,7 +2724,7 @@ }, { "cell_type": "markdown", - "id": "b4ba9669", + "id": "381c61e2", "metadata": { "editable": true }, @@ -2741,7 +2741,7 @@ }, { "cell_type": "markdown", - "id": "875686e8", + "id": "ac36a03d", "metadata": { "editable": true }, @@ -2751,7 +2751,7 @@ }, { "cell_type": "markdown", - "id": "ee9f7d57", + "id": "2899becc", "metadata": { "editable": true }, @@ -2767,7 +2767,7 @@ }, { "cell_type": "markdown", - "id": "1e370697", + "id": "d52c8124", "metadata": { "editable": true }, @@ -2779,7 +2779,7 @@ }, { "cell_type": "markdown", - "id": "833f3b82", + "id": "3f8f684e", "metadata": { "editable": true }, @@ -2791,7 +2791,7 @@ }, { "cell_type": "markdown", - "id": "35da5498", + "id": "92cc16c9", "metadata": { "editable": true }, @@ -2803,7 +2803,7 @@ }, { "cell_type": "markdown", - "id": "b44a64f2", + "id": "628e0dfc", "metadata": { "editable": true }, @@ -2813,7 +2813,7 @@ }, { "cell_type": "markdown", - "id": "116b1937", + "id": "e54b4c6e", "metadata": { "editable": true }, @@ -2825,7 +2825,7 @@ }, { "cell_type": "markdown", - "id": "9ef6d929", + "id": "80dc48dd", "metadata": { "editable": true }, @@ -2842,7 +2842,7 @@ }, { "cell_type": "markdown", - "id": "bd901882", + "id": "e57a1d70", "metadata": { "editable": true }, @@ -2852,7 +2852,7 @@ }, { "cell_type": "markdown", - "id": "31348d62", + "id": "8ad67e57", "metadata": { "editable": true }, @@ -2864,7 +2864,7 @@ }, { "cell_type": "markdown", - "id": "ae4a794d", + "id": "4eed66ce", "metadata": { "editable": true }, @@ -2878,7 +2878,7 @@ }, { "cell_type": "markdown", - "id": "a4ca4b65", + "id": "9d652c56", "metadata": { "editable": true }, @@ -2894,7 +2894,7 @@ }, { "cell_type": "markdown", - "id": "6cd19213", + "id": "9a5a1ad7", "metadata": { "editable": true }, @@ -2906,7 +2906,7 @@ }, { "cell_type": "markdown", - "id": "e6d9fb88", + "id": "ed15e067", "metadata": { "editable": true }, @@ -2928,7 +2928,7 @@ }, { "cell_type": "markdown", - "id": "2b7229da", + "id": "827ac223", "metadata": { "editable": true }, @@ -2940,7 +2940,7 @@ }, { "cell_type": "markdown", - "id": "cd4f193b", + "id": "a0a7b13f", "metadata": { "editable": true }, @@ -2963,7 +2963,7 @@ }, { "cell_type": "markdown", - "id": "e475f927", + "id": "0879010a", "metadata": { "editable": true }, @@ -2979,7 +2979,7 @@ }, { "cell_type": "markdown", - "id": "95a91bdd", + "id": "66ac91b3", "metadata": { "editable": true }, @@ -2991,7 +2991,7 @@ }, { "cell_type": "markdown", - "id": "56c75c71", + "id": "470c74b5", "metadata": { "editable": true }, @@ -3015,7 +3015,7 @@ }, { "cell_type": "markdown", - "id": "0cc6d1a9", + "id": "bf5e6967", "metadata": { "editable": true }, @@ -3027,7 +3027,7 @@ }, { "cell_type": "markdown", - "id": "0175da6a", + "id": "766b88f8", "metadata": { "editable": true }, @@ -3048,7 +3048,7 @@ }, { "cell_type": "markdown", - "id": "5fe7bc0e", + "id": "5c114139", "metadata": { "editable": true }, @@ -3060,7 +3060,7 @@ }, { "cell_type": "markdown", - "id": "7f0577a4", + "id": "45596281", "metadata": { "editable": true }, @@ -3079,7 +3079,7 @@ }, { "cell_type": "markdown", - "id": "11c8c142", + "id": "2c1378fb", "metadata": { "editable": true }, @@ -3089,7 +3089,7 @@ }, { "cell_type": "markdown", - "id": "01ca4d08", + "id": "66a732e1", "metadata": { "editable": true }, @@ -3103,7 +3103,7 @@ }, { "cell_type": "markdown", - "id": "f5133d80", + "id": "fdf81225", "metadata": { "editable": true }, @@ -3115,7 +3115,7 @@ }, { "cell_type": "markdown", - "id": "c1e40110", + "id": "9bb52111", "metadata": { "editable": true }, @@ -3127,7 +3127,7 @@ }, { "cell_type": "markdown", - "id": "89f577fa", + "id": "f3e495b4", "metadata": { "editable": true }, @@ -3144,7 +3144,7 @@ }, { "cell_type": "markdown", - "id": "73db81fc", + "id": "adc904df", "metadata": { "editable": true }, @@ -3156,7 +3156,7 @@ }, { "cell_type": "markdown", - "id": "6956b9f1", + "id": "2d01b1b5", "metadata": { "editable": true }, @@ -3178,7 +3178,7 @@ }, { "cell_type": "markdown", - "id": "13e5d04c", + "id": "5077f4f7", "metadata": { "editable": true }, @@ -3193,7 +3193,7 @@ }, { "cell_type": "markdown", - "id": "dd560ef7", + "id": "fb01e943", "metadata": { "editable": true }, @@ -3204,7 +3204,7 @@ { "cell_type": "code", "execution_count": 31, - "id": "ac42510c", + "id": "6347e101", "metadata": { "collapsed": false, "editable": true @@ -3359,7 +3359,7 @@ }, { "cell_type": "markdown", - "id": "22aed435", + "id": "59e5acda", "metadata": { "editable": true }, @@ -3374,7 +3374,7 @@ { "cell_type": "code", "execution_count": 32, - "id": "96179484", + "id": "f1a60516", "metadata": { "collapsed": false, "editable": true @@ -3543,7 +3543,7 @@ }, { "cell_type": "markdown", - "id": "a0ff62a9", + "id": "807a375c", "metadata": { "editable": true }, @@ -3556,7 +3556,7 @@ }, { "cell_type": "markdown", - "id": "e9112c77", + "id": "d35839bb", "metadata": { "editable": true }, @@ -3573,7 +3573,7 @@ }, { "cell_type": "markdown", - "id": "cf582ad1", + "id": "2991d1fe", "metadata": { "editable": true }, @@ -3589,7 +3589,7 @@ }, { "cell_type": "markdown", - "id": "d945a6b3", + "id": "ee668a71", "metadata": { "editable": true }, @@ -3602,7 +3602,7 @@ }, { "cell_type": "markdown", - "id": "e98cd638", + "id": "febf10cc", "metadata": { "editable": true }, @@ -3619,7 +3619,7 @@ }, { "cell_type": "markdown", - "id": "8b5c6044", + "id": "494194e3", "metadata": { "editable": true }, @@ -3631,7 +3631,7 @@ }, { "cell_type": "markdown", - "id": "74c055d2", + "id": "5efa7b11", "metadata": { "editable": true }, @@ -3658,7 +3658,7 @@ }, { "cell_type": "markdown", - "id": "a65e3069", + "id": "568131dc", "metadata": { "editable": true }, @@ -3671,7 +3671,7 @@ { "cell_type": "code", "execution_count": 33, - "id": "b092c21e", + "id": "8737e028", "metadata": { "collapsed": false, "editable": true @@ -3850,7 +3850,7 @@ }, { "cell_type": "markdown", - "id": "1aa71f38", + "id": "0904f64d", "metadata": { "editable": true }, @@ -3870,7 +3870,7 @@ }, { "cell_type": "markdown", - "id": "9d1de21f", + "id": "6f3577a8", "metadata": { "editable": true }, @@ -3885,7 +3885,7 @@ }, { "cell_type": "markdown", - "id": "826b08a1", + "id": "56d4410b", "metadata": { "editable": true }, @@ -3899,7 +3899,7 @@ }, { "cell_type": "markdown", - "id": "c4493848", + "id": "48d2707e", "metadata": { "editable": true }, @@ -3915,7 +3915,7 @@ }, { "cell_type": "markdown", - "id": "e37b66c6", + "id": "66d99f85", "metadata": { "editable": true }, @@ -3925,7 +3925,7 @@ }, { "cell_type": "markdown", - "id": "264abdcc", + "id": "3c9447d9", "metadata": { "editable": true }, @@ -3947,7 +3947,7 @@ }, { "cell_type": "markdown", - "id": "afc2e4cc", + "id": "724b97f1", "metadata": { "editable": true }, @@ -3961,7 +3961,7 @@ { "cell_type": "code", "execution_count": 34, - "id": "63c572f6", + "id": "58b0da70", "metadata": { "collapsed": false, "editable": true @@ -4037,7 +4037,7 @@ }, { "cell_type": "markdown", - "id": "6381dfa2", + "id": "f1230dee", "metadata": { "editable": true }, @@ -4049,7 +4049,7 @@ }, { "cell_type": "markdown", - "id": "ddcc006d", + "id": "ba2c6d0a", "metadata": { "editable": true }, @@ -4066,7 +4066,7 @@ }, { "cell_type": "markdown", - "id": "85639943", + "id": "bab1c7d3", "metadata": { "editable": true }, @@ -4078,7 +4078,7 @@ }, { "cell_type": "markdown", - "id": "f17eea8d", + "id": "42bfde23", "metadata": { "editable": true }, @@ -4093,7 +4093,7 @@ }, { "cell_type": "markdown", - "id": "1efed335", + "id": "7b3a2504", "metadata": { "editable": true }, @@ -4105,7 +4105,7 @@ }, { "cell_type": "markdown", - "id": "23e866a2", + "id": "a419909c", "metadata": { "editable": true }, @@ -4117,7 +4117,7 @@ }, { "cell_type": "markdown", - "id": "2cfcda87", + "id": "125f8197", "metadata": { "editable": true }, @@ -4129,7 +4129,7 @@ }, { "cell_type": "markdown", - "id": "b2a2d58c", + "id": "16376b60", "metadata": { "editable": true }, @@ -4139,7 +4139,7 @@ }, { "cell_type": "markdown", - "id": "a7c84b58", + "id": "044c76ec", "metadata": { "editable": true }, @@ -4156,7 +4156,7 @@ }, { "cell_type": "markdown", - "id": "9db2324e", + "id": "0ec4860b", "metadata": { "editable": true }, @@ -4168,7 +4168,7 @@ }, { "cell_type": "markdown", - "id": "f94f8d1a", + "id": "03e27ec0", "metadata": { "editable": true }, @@ -4180,7 +4180,7 @@ }, { "cell_type": "markdown", - "id": "e8eaba06", + "id": "82fdb51f", "metadata": { "editable": true }, @@ -4190,7 +4190,7 @@ }, { "cell_type": "markdown", - "id": "3c345647", + "id": "82e39d0e", "metadata": { "editable": true }, @@ -4202,7 +4202,7 @@ }, { "cell_type": "markdown", - "id": "0d913be0", + "id": "bf029e6c", "metadata": { "editable": true }, @@ -4213,7 +4213,7 @@ { "cell_type": "code", "execution_count": 35, - "id": "96194d94", + "id": "e10d7641", "metadata": { "collapsed": false, "editable": true @@ -4378,7 +4378,7 @@ }, { "cell_type": "markdown", - "id": "780c5c66", + "id": "82891392", "metadata": { "editable": true }, @@ -4400,7 +4400,7 @@ }, { "cell_type": "markdown", - "id": "b6dfbfdc", + "id": "ad4ef510", "metadata": { "editable": true }, @@ -4417,7 +4417,7 @@ }, { "cell_type": "markdown", - "id": "011ba117", + "id": "eb8ab804", "metadata": { "editable": true }, @@ -4427,7 +4427,7 @@ }, { "cell_type": "markdown", - "id": "cdf079bc", + "id": "f9b7b2a0", "metadata": { "editable": true }, @@ -4442,7 +4442,7 @@ }, { "cell_type": "markdown", - "id": "bf2fc40c", + "id": "6a71c7bb", "metadata": { "editable": true }, @@ -4452,7 +4452,7 @@ }, { "cell_type": "markdown", - "id": "6662f05c", + "id": "d19780a8", "metadata": { "editable": true }, @@ -4467,7 +4467,7 @@ }, { "cell_type": "markdown", - "id": "fe9a0465", + "id": "00fedc6e", "metadata": { "editable": true }, @@ -4478,7 +4478,7 @@ }, { "cell_type": "markdown", - "id": "7603ea9a", + "id": "28005c86", "metadata": { "editable": true }, @@ -4498,7 +4498,7 @@ }, { "cell_type": "markdown", - "id": "6744dfef", + "id": "d562bb0c", "metadata": { "editable": true }, @@ -4510,7 +4510,7 @@ }, { "cell_type": "markdown", - "id": "af13fca6", + "id": "bdee81e4", "metadata": { "editable": true }, @@ -4547,7 +4547,7 @@ }, { "cell_type": "markdown", - "id": "bd1bd149", + "id": "ddf436f5", "metadata": { "editable": true }, @@ -4557,7 +4557,7 @@ }, { "cell_type": "markdown", - "id": "43e51ef4", + "id": "66ae2d44", "metadata": { "editable": true }, @@ -4570,7 +4570,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "49c94dd9", + "id": "17f02a24", "metadata": { "collapsed": false, "editable": true @@ -4775,7 +4775,7 @@ }, { "cell_type": "markdown", - "id": "6d27256f", + "id": "51ee4433", "metadata": { "editable": true }, @@ -4792,7 +4792,7 @@ }, { "cell_type": "markdown", - "id": "df08a8ac", + "id": "1ec16aab", "metadata": { "editable": true }, @@ -4809,7 +4809,7 @@ }, { "cell_type": "markdown", - "id": "ec4b9fd4", + "id": "64fd215d", "metadata": { "editable": true }, @@ -4819,7 +4819,7 @@ }, { "cell_type": "markdown", - "id": "92f17705", + "id": "3efab799", "metadata": { "editable": true }, @@ -4834,7 +4834,7 @@ }, { "cell_type": "markdown", - "id": "eec1785d", + "id": "80e6d77c", "metadata": { "editable": true }, @@ -4848,7 +4848,7 @@ }, { "cell_type": "markdown", - "id": "544c3fce", + "id": "f08a42bd", "metadata": { "editable": true }, @@ -4861,7 +4861,7 @@ }, { "cell_type": "markdown", - "id": "74af5618", + "id": "af035b50", "metadata": { "editable": true }, @@ -4881,7 +4881,7 @@ }, { "cell_type": "markdown", - "id": "9a7c5864", + "id": "ee147dfb", "metadata": { "editable": true }, @@ -4893,7 +4893,7 @@ }, { "cell_type": "markdown", - "id": "3f2d680d", + "id": "850e95ed", "metadata": { "editable": true }, @@ -4905,7 +4905,7 @@ }, { "cell_type": "markdown", - "id": "118044b0", + "id": "96f9cca4", "metadata": { "editable": true }, @@ -4917,7 +4917,7 @@ }, { "cell_type": "markdown", - "id": "e9b82be4", + "id": "70394cae", "metadata": { "editable": true }, @@ -4927,7 +4927,7 @@ }, { "cell_type": "markdown", - "id": "d5e6b103", + "id": "d06e6c30", "metadata": { "editable": true }, @@ -4939,7 +4939,7 @@ }, { "cell_type": "markdown", - "id": "c9dec199", + "id": "b4972f88", "metadata": { "editable": true }, @@ -4951,7 +4951,7 @@ }, { "cell_type": "markdown", - "id": "118d2522", + "id": "3d35cbd3", "metadata": { "editable": true }, @@ -4963,7 +4963,7 @@ }, { "cell_type": "markdown", - "id": "1d13aaff", + "id": "984bf645", "metadata": { "editable": true }, @@ -4973,7 +4973,7 @@ }, { "cell_type": "markdown", - "id": "4de9c463", + "id": "9d58d0ec", "metadata": { "editable": true }, @@ -4989,7 +4989,7 @@ }, { "cell_type": "markdown", - "id": "65b2ba09", + "id": "99cf8f47", "metadata": { "editable": true }, @@ -4999,7 +4999,7 @@ }, { "cell_type": "markdown", - "id": "843d90aa", + "id": "777ad3a8", "metadata": { "editable": true }, @@ -5011,7 +5011,7 @@ }, { "cell_type": "markdown", - "id": "77447bcd", + "id": "7182b747", "metadata": { "editable": true }, @@ -5028,7 +5028,7 @@ }, { "cell_type": "markdown", - "id": "c3cf90aa", + "id": "3c40d528", "metadata": { "editable": true }, @@ -5038,7 +5038,7 @@ }, { "cell_type": "markdown", - "id": "257d1f48", + "id": "7cb1e15a", "metadata": { "editable": true }, @@ -5054,7 +5054,7 @@ }, { "cell_type": "markdown", - "id": "7f4f7d6a", + "id": "5c4bcdb5", "metadata": { "editable": true }, @@ -5068,7 +5068,7 @@ }, { "cell_type": "markdown", - "id": "1e0c143a", + "id": "c84ff432", "metadata": { "editable": true }, @@ -5087,7 +5087,7 @@ { "cell_type": "code", "execution_count": 37, - "id": "e52c49e9", + "id": "ba62ab4c", "metadata": { "collapsed": false, "editable": true @@ -5142,7 +5142,7 @@ }, { "cell_type": "markdown", - "id": "e6975906", + "id": "7fd9e6dc", "metadata": { "editable": true }, @@ -5172,7 +5172,7 @@ }, { "cell_type": "markdown", - "id": "d665f51c", + "id": "6c63c928", "metadata": { "editable": true }, @@ -5201,7 +5201,7 @@ { "cell_type": "code", "execution_count": 38, - "id": "152c290e", + "id": "4192bf3d", "metadata": { "collapsed": false, "editable": true @@ -5248,7 +5248,7 @@ }, { "cell_type": "markdown", - "id": "eac82d2c", + "id": "87f8417d", "metadata": { "editable": true }, @@ -5274,7 +5274,7 @@ { "cell_type": "code", "execution_count": 39, - "id": "df3d9605", + "id": "1572e93b", "metadata": { "collapsed": false, "editable": true @@ -5508,7 +5508,7 @@ }, { "cell_type": "markdown", - "id": "fec03008", + "id": "bf7afd74", "metadata": { "editable": true }, @@ -5520,7 +5520,7 @@ }, { "cell_type": "markdown", - "id": "403f7560", + "id": "fdef78b2", "metadata": { "editable": true }, @@ -5532,7 +5532,7 @@ }, { "cell_type": "markdown", - "id": "dc05badf", + "id": "be570613", "metadata": { "editable": true }, @@ -5544,7 +5544,7 @@ }, { "cell_type": "markdown", - "id": "1daf1dd8", + "id": "9f81e04f", "metadata": { "editable": true }, @@ -5561,7 +5561,7 @@ }, { "cell_type": "markdown", - "id": "4da632df", + "id": "91171d8b", "metadata": { "editable": true }, @@ -5571,7 +5571,7 @@ }, { "cell_type": "markdown", - "id": "851bb943", + "id": "dbbbb8a5", "metadata": { "editable": true }, @@ -5583,7 +5583,7 @@ }, { "cell_type": "markdown", - "id": "760b72fe", + "id": "3f1be58e", "metadata": { "editable": true }, @@ -5600,7 +5600,7 @@ }, { "cell_type": "markdown", - "id": "e3e22598", + "id": "d54c4188", "metadata": { "editable": true }, @@ -5611,7 +5611,7 @@ }, { "cell_type": "markdown", - "id": "59f39060", + "id": "952c58e8", "metadata": { "editable": true }, @@ -5631,7 +5631,7 @@ }, { "cell_type": "markdown", - "id": "bf3a2904", + "id": "a650bae2", "metadata": { "editable": true }, @@ -5641,7 +5641,7 @@ }, { "cell_type": "markdown", - "id": "4a633f01", + "id": "9e0b8996", "metadata": { "editable": true }, @@ -5667,7 +5667,7 @@ }, { "cell_type": "markdown", - "id": "c09dc6a7", + "id": "0f3f1985", "metadata": { "editable": true }, @@ -5683,7 +5683,7 @@ }, { "cell_type": "markdown", - "id": "592d4d57", + "id": "fbd35329", "metadata": { "editable": true }, @@ -5694,7 +5694,7 @@ { "cell_type": "code", "execution_count": 40, - "id": "1c25dc4e", + "id": "6ccf9344", "metadata": { "collapsed": false, "editable": true @@ -5925,7 +5925,7 @@ }, { "cell_type": "markdown", - "id": "5072a8bd", + "id": "988e09cf", "metadata": { "editable": true }, From 4cc9254440f20ae9e140167f793ac9c0376437fd Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 09:40:58 +0200 Subject: [PATCH 07/14] update --- doc/LectureNotes/_toc.yml | 2 + doc/LectureNotes/exercisesweek43.ipynb | 617 ++++++++++ doc/src/week43/exercisesweek43.do.txt | 1471 ++++-------------------- 3 files changed, 854 insertions(+), 1236 deletions(-) create mode 100644 doc/LectureNotes/exercisesweek43.ipynb diff --git a/doc/LectureNotes/_toc.yml b/doc/LectureNotes/_toc.yml index 989e67705..71447c0af 100644 --- a/doc/LectureNotes/_toc.yml +++ b/doc/LectureNotes/_toc.yml @@ -58,6 +58,8 @@ parts: - file: exercisesweek41.ipynb - file: week42.ipynb - file: exercisesweek42.ipynb + - file: week43.ipynb + - file: exercisesweek43.ipynb - caption: Projects numbered: false chapters: diff --git a/doc/LectureNotes/exercisesweek43.ipynb b/doc/LectureNotes/exercisesweek43.ipynb new file mode 100644 index 000000000..737d0d60c --- /dev/null +++ b/doc/LectureNotes/exercisesweek43.ipynb @@ -0,0 +1,617 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "860d70d8", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "119c0988", + "metadata": { + "editable": true + }, + "source": [ + "# Exercises week 43 \n", + "**October 20-24, 2025**\n", + "\n", + "Date: **Deadline Friday October 24 at midnight**" + ] + }, + { + "cell_type": "markdown", + "id": "909887eb", + "metadata": { + "editable": true + }, + "source": [ + "# Overarching aims of the exercises weeks 43 and 44\n", + "\n", + "The aim of the exercises this week is to gain some confidence with\n", + "ways to visualize the results of a classification problem. We will\n", + "target three ways of setting up the analysis. The first and simplest\n", + "one is the\n", + "1. so-called confusion matrix, and the next is the\n", + "\n", + "2. ROC curve and finally the\n", + "\n", + "3. Cumulative gain curve.\n", + "\n", + "We will use Logistic Regression as method for the classification in\n", + "this exercise. You can compare these results with those obtained with\n", + "your neural network code from project 2 without a hidden layer.\n", + "\n", + "In these exercises we will use binary and multi-class data sets\n", + "(the Iris data set from week 41).\n", + "\n", + "The underlying mathematics is described here." + ] + }, + { + "cell_type": "markdown", + "id": "1e1cb4fb", + "metadata": { + "editable": true + }, + "source": [ + "### Confusion Matrix\n", + "\n", + "A **confusion matrix** summarizes a classifier’s performance by\n", + "tabulating predictions versus true labels. For binary classification,\n", + "it is a $2\\times2$ table whose entries are counts of outcomes:" + ] + }, + { + "cell_type": "markdown", + "id": "7b090385", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{array}{l|cc} & \\text{Predicted Positive} & \\text{Predicted Negative} \\\\ \\hline \\text{Actual Positive} & TP & FN \\\\ \\text{Actual Negative} & FP & TN \\end{array}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "1e14904b", + "metadata": { + "editable": true + }, + "source": [ + "Here TP (true positives) is the number of cases correctly predicted as\n", + "positive, FP (false positives) is the number incorrectly predicted as\n", + "positive, TN (true negatives) is correctly predicted negative, and FN\n", + "(false negatives) is incorrectly predicted negative . In other words,\n", + "“positive” means class 1 and “negative” means class 0; for example, TP\n", + "occurs when the prediction and actual are both positive. Formally:" + ] + }, + { + "cell_type": "markdown", + "id": "e93ea290", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{TPR} = \\frac{\\text{TP}}{\\text{TP} + \\text{FN}}, \\quad \\text{FPR} = \\frac{\\text{FP}}{\\text{FP} + \\text{TN}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c80bea5b", + "metadata": { + "editable": true + }, + "source": [ + "where TPR and FPR are the true and false positive rates defined below.\n", + "\n", + "In multiclass classification with $K$ classes, the confusion matrix\n", + "generalizes to a $K\\times K$ table. Entry $N_{ij}$ in the table is\n", + "the count of instances whose true class is $i$ and whose predicted\n", + "class is $j$. For example, a three-class confusion matrix can be written\n", + "as:" + ] + }, + { + "cell_type": "markdown", + "id": "a0f68f5f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{array}{c|ccc} & \\text{Pred Class 1} & \\text{Pred Class 2} & \\text{Pred Class 3} \\\\ \\hline \\text{Act Class 1} & N_{11} & N_{12} & N_{13} \\\\ \\text{Act Class 2} & N_{21} & N_{22} & N_{23} \\\\ \\text{Act Class 3} & N_{31} & N_{32} & N_{33} \\end{array}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "869669b2", + "metadata": { + "editable": true + }, + "source": [ + "Here the diagonal entries $N_{ii}$ are the true positives for each\n", + "class, and off-diagonal entries are misclassifications. This matrix\n", + "allows computation of per-class metrics: e.g. for class $i$,\n", + "$\\mathrm{TP}_i=N_{ii}$, $\\mathrm{FN}_i=\\sum_{j\\neq i}N_{ij}$,\n", + "$\\mathrm{FP}_i=\\sum_{j\\neq i}N_{ji}$, and $\\mathrm{TN}_i$ is the sum of\n", + "all remaining entries.\n", + "\n", + "As defined above, TPR and FPR come from the binary case. In binary\n", + "terms with $P$ actual positives and $N$ actual negatives, one has" + ] + }, + { + "cell_type": "markdown", + "id": "2abd82a7", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{TPR} = \\frac{TP}{P} = \\frac{TP}{TP+FN}, \\quad \\text{FPR} =\n", + "\\frac{FP}{N} = \\frac{FP}{FP+TN},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2f79325c", + "metadata": { + "editable": true + }, + "source": [ + "as used in standard confusion-matrix\n", + "formulations. These rates will be used in constructing ROC curves." + ] + }, + { + "cell_type": "markdown", + "id": "0ce65a47", + "metadata": { + "editable": true + }, + "source": [ + "### ROC Curve\n", + "\n", + "The Receiver Operating Characteristic (ROC) curve plots the trade-off\n", + "between true positives and false positives as a discrimination\n", + "threshold varies. Specifically, for a binary classifier that outputs\n", + "a score or probability, one varies the threshold $t$ for declaring\n", + "**positive**, and computes at each $t$ the true positive rate\n", + "$\\mathrm{TPR}(t)$ and false positive rate $\\mathrm{FPR}(t)$ using the\n", + "confusion matrix at that threshold. The ROC curve is then the graph\n", + "of TPR versus FPR. By definition," + ] + }, + { + "cell_type": "markdown", + "id": "d750fdff", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{TPR} = \\frac{TP}{TP+FN}, \\qquad \\mathrm{FPR} = \\frac{FP}{FP+TN},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "561bfb2c", + "metadata": { + "editable": true + }, + "source": [ + "where $TP,FP,TN,FN$ are counts determined by threshold $t$. A perfect\n", + "classifier would reach the point (FPR=0, TPR=1) at some threshold.\n", + "\n", + "Formally, the ROC curve is obtained by plotting\n", + "$(\\mathrm{FPR}(t),\\mathrm{TPR}(t))$ for all $t\\in[0,1]$ (or as $t$\n", + "sweeps through the sorted scores). The Area Under the ROC Curve (AUC)\n", + "quantifies the average performance over all thresholds. It can be\n", + "interpreted probabilistically: $\\mathrm{AUC} =\n", + "\\Pr\\bigl(s(X^+)>s(X^-)\\bigr)$, the probability that a random positive\n", + "instance $X^+$ receives a higher score $s$ than a random negative\n", + "instance $X^-$ . Equivalently, the AUC is the integral under the ROC\n", + "curve:" + ] + }, + { + "cell_type": "markdown", + "id": "5ca722fe", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{AUC} \\;=\\; \\int_{0}^{1} \\mathrm{TPR}(f)\\,df,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "30080a86", + "metadata": { + "editable": true + }, + "source": [ + "where $f$ ranges over FPR (or fraction of negatives). A model that guesses at random yields a diagonal ROC (AUC=0.5), whereas a perfect model yields AUC=1.0." + ] + }, + { + "cell_type": "markdown", + "id": "9e627156", + "metadata": { + "editable": true + }, + "source": [ + "### Cumulative Gain\n", + "\n", + "The cumulative gain curve (or gains chart) evaluates how many\n", + "positives are captured as one targets an increasing fraction of the\n", + "population, sorted by model confidence. To construct it, sort all\n", + "instances by decreasing predicted probability of the positive class.\n", + "Then, for the top $\\alpha$ fraction of instances, compute the fraction\n", + "of all actual positives that fall in this subset. In formula form, if\n", + "$P$ is the total number of positive instances and $P(\\alpha)$ is the\n", + "number of positives among the top $\\alpha$ of the data, the cumulative\n", + "gain at level $\\alpha$ is" + ] + }, + { + "cell_type": "markdown", + "id": "3e9132ef", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{Gain}(\\alpha) \\;=\\; \\frac{P(\\alpha)}{P}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "75be6f5c", + "metadata": { + "editable": true + }, + "source": [ + "For example, cutting off at the top 10% of predictions yields a gain\n", + "equal to (positives in top 10%) divided by (total positives) .\n", + "Plotting $\\mathrm{Gain}(\\alpha)$ versus $\\alpha$ (often in percent)\n", + "gives the gain curve. The baseline (random) curve is the diagonal\n", + "$\\mathrm{Gain}(\\alpha)=\\alpha$, while an ideal model has a steep climb\n", + "toward 1.\n", + "\n", + "A related measure is the {\\em lift}, often called the gain ratio. It is the ratio of the model’s capture rate to that of random selection. Equivalently," + ] + }, + { + "cell_type": "markdown", + "id": "e5525570", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{Lift}(\\alpha) \\;=\\; \\frac{\\mathrm{Gain}(\\alpha)}{\\alpha}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "18ff8dc2", + "metadata": { + "editable": true + }, + "source": [ + "A lift $>1$ indicates better-than-random targeting. In practice, gain\n", + "and lift charts (used e.g.\\ in marketing or imbalanced classification)\n", + "show how many positives can be “gained” by focusing on a fraction of\n", + "the population ." + ] + }, + { + "cell_type": "markdown", + "id": "c3d3fde8", + "metadata": { + "editable": true + }, + "source": [ + "### Other measures: Precision, Recall, and the F$_1$ Measure\n", + "\n", + "Precision and recall (sensitivity) quantify binary classification\n", + "accuracy in terms of positive predictions. They are defined from the\n", + "confusion matrix as:" + ] + }, + { + "cell_type": "markdown", + "id": "f1f14c8e", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{Precision} = \\frac{TP}{TP + FP}, \\qquad \\text{Recall} = \\frac{TP}{TP + FN}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "422cc743", + "metadata": { + "editable": true + }, + "source": [ + "Precision is the fraction of predicted positives that are correct, and\n", + "recall is the fraction of actual positives that are correctly\n", + "identified . A high-precision classifier makes few false-positive\n", + "errors, while a high-recall classifier makes few false-negative\n", + "errors.\n", + "\n", + "The F$_1$ score (balanced F-measure) combines precision and recall into a single metric via their harmonic mean. The usual formula is:" + ] + }, + { + "cell_type": "markdown", + "id": "621a2e8b", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "F_1 =2\\frac{\\text{Precision}\\times\\text{Recall}}{\\text{Precision} + \\text{Recall}}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "62eee54a", + "metadata": { + "editable": true + }, + "source": [ + "This can be shown to equal" + ] + }, + { + "cell_type": "markdown", + "id": "7a6a2e7a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{2\\,TP}{2\\,TP + FP + FN}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b96c9ff4", + "metadata": { + "editable": true + }, + "source": [ + "The F$_1$ score ranges from 0 (worst) to 1 (best), and balances the\n", + "trade-off between precision and recall.\n", + "\n", + "For multi-class classification, one computes per-class\n", + "precision/recall/F$_1$ (treating each class as “positive” in a\n", + "one-vs-rest manner) and then averages. Common averaging methods are:\n", + "\n", + "Micro-averaging: Sum all true positives, false positives, and false negatives across classes, then compute precision/recall/F$_1$ from these totals.\n", + "Macro-averaging: Compute the F$1$ score $F{1,i}$ for each class $i$ separately, then take the unweighted mean: $F_{1,\\mathrm{macro}} = \\frac{1}{K}\\sum_{i=1}^K F_{1,i}$ . This treats all classes equally regardless of size.\n", + "Weighted-averaging: Like macro-average, but weight each class’s $F_{1,i}$ by its support $n_i$ (true count): $F_{1,\\mathrm{weighted}} = \\frac{1}{N}\\sum_{i=1}^K n_i F_{1,i}$, where $N=\\sum_i n_i$. This accounts for class imbalance by giving more weight to larger classes .\n", + "\n", + "Each of these averages has different use-cases. Micro-average is\n", + "dominated by common classes, macro-average highlights performance on\n", + "rare classes, and weighted-average is a compromise. These formulas\n", + "and concepts allow rigorous evaluation of classifier performance in\n", + "both binary and multi-class settings." + ] + }, + { + "cell_type": "markdown", + "id": "9274bf3f", + "metadata": { + "editable": true + }, + "source": [ + "## Exercises\n", + "\n", + "Here is a simple code example which uses the Logistic regression machinery from **scikit-learn**.\n", + "At the end it sets up the confusion matrix and the ROC and cumulative gain curves.\n", + "Feel free to use these functionalities (we don't expect you to write your own code for say the confusion matrix)." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "be9ff0b9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from sklearn.model_selection import train_test_split \n", + "# from sklearn.datasets import fill in the data set\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "# Load the data, fill inn\n", + "mydata.data = ?\n", + "\n", + "X_train, X_test, y_train, y_test = train_test_split(mydata.data,cancer.target,random_state=0)\n", + "print(X_train.shape)\n", + "print(X_test.shape)\n", + "# Logistic Regression\n", + "# define which type of problem, binary or multiclass\n", + "logreg = LogisticRegression(solver='lbfgs')\n", + "logreg.fit(X_train, y_train)\n", + "\n", + "from sklearn.preprocessing import LabelEncoder\n", + "from sklearn.model_selection import cross_validate\n", + "#Cross validation\n", + "accuracy = cross_validate(logreg,X_test,y_test,cv=10)['test_score']\n", + "print(accuracy)\n", + "print(\"Test set accuracy with Logistic Regression: {:.2f}\".format(logreg.score(X_test,y_test)))\n", + "\n", + "import scikitplot as skplt\n", + "y_pred = logreg.predict(X_test)\n", + "skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n", + "plt.show()\n", + "y_probas = logreg.predict_proba(X_test)\n", + "skplt.metrics.plot_roc(y_test, y_probas)\n", + "plt.show()\n", + "skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "51760b3e", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise a)\n", + "\n", + "Convince yourself about the mathematics for the confusion matrix, the ROC and the cumlative gain curves for both a binary and a multiclass classification problem." + ] + }, + { + "cell_type": "markdown", + "id": "c1d42f5f", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise b)\n", + "\n", + "Use a binary classification data available from **scikit-learn**. As an example you can use\n", + "the MNIST data set and just specialize to two numbers. To do so you can use the following code lines" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d20bb8be", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_digits\n", + "digits = load_digits(n_class=2) # Load only two classes, e.g., 0 and 1\n", + "X, y = digits.data, digits.target" + ] + }, + { + "cell_type": "markdown", + "id": "828ea1cd", + "metadata": { + "editable": true + }, + "source": [ + "Alternatively, you can use the _make$\\_$classification_\n", + "functionality. This function generates a random $n$-class classification\n", + "dataset, which can be configured for binary classification by setting\n", + "n_classes=2. You can also control the number of samples, features,\n", + "informative features, redundant features, and more." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d271f0ba", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import make_classification\n", + "X, y = make_classification(n_samples=1000, n_features=20, n_informative=10, n_redundant=5, n_classes=2, random_state=42)" + ] + }, + { + "cell_type": "markdown", + "id": "0068b032", + "metadata": { + "editable": true + }, + "source": [ + "You can use this option for the multiclass case as well, see the next exercise.\n", + "If you prefer to study other binary classification datasets, feel free\n", + "to replace the above suggestions with your own dataset.\n", + "\n", + "Make plots of the confusion matrix, the ROC curve and the cumulative gain curve." + ] + }, + { + "cell_type": "markdown", + "id": "c45f5b41", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise c) week 43\n", + "\n", + "As a multiclass problem, we will use the Iris data set discussed in\n", + "the exercises from weeks 41 and 42. This is a three-class data set and\n", + "you can set it up using **scikit-learn**," + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3b045d56", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_iris\n", + "iris = load_iris()\n", + "X = iris.data # Features\n", + "y = iris.target # Target labels" + ] + }, + { + "cell_type": "markdown", + "id": "14cc859c", + "metadata": { + "editable": true + }, + "source": [ + "Make plots of the confusion matrix, the ROC curve and the cumulative\n", + "gain curve for this (or other) multiclass data set." + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/src/week43/exercisesweek43.do.txt b/doc/src/week43/exercisesweek43.do.txt index 105d59dd8..a82a92316 100644 --- a/doc/src/week43/exercisesweek43.do.txt +++ b/doc/src/week43/exercisesweek43.do.txt @@ -1,1284 +1,283 @@ -TITLE: Exercises weeks 43 and 44 -AUTHOR: October 23-27, 2023 -DATE: Deadline is Sunday November 5 at midnight +TITLE: Exercises week 43 +AUTHOR: October 20-24, 2025 +DATE: Deadline Friday October 24 at midnight -You can hand in the exercises from week 43 and week 44 as one exercise and get a total score of two additional points. ======= Overarching aims of the exercises weeks 43 and 44 ======= -The aim of the exercises this week and next week is to get started with writing a neural network code -of relevance for project 2. +The aim of the exercises this week is to gain some confidence with +ways to visualize the results of a classification problem. We will +target three ways of setting up the analysis. The first and simplest +one is the +o so-called confusion matrix, and the next is the +o ROC curve and finally the +o Cumulative gain curve. +We will use Logistic Regression as method for the classification in +this exercise. You can compare these results with those obtained with +your neural network code from project 2 without a hidden layer. -During week 41 we discussed three different types of gates, the -so-called XOR, the OR and the AND gates. In order to develop a code -for neural networks, it can be useful to set up a simpler system with -only two inputs and one output. This can make it easier to debug and -study the feed forward pass and the back propagation part. In the -exercise this and next week, we propose to study this system with just -one hidden layer and two hidden nodes. There is only one output node -and we can choose to use either a simple regression case (fitting a -line) or just a binary classification case with the cross-entropy as -cost function. +In these exercises we will use binary and multi-class data sets +(the Iris data set from week 41). +The underlying mathematics is described here. -Their inputs and outputs can be -summarized using the following tables, first for the OR gate with -inputs $x_1$ and $x_2$ and outputs $y$: - -|---------------------| -| $x_1$ | $x_2$ | $y$ | -|---------------------| -| 0 | 0 | 0 | -| 0 | 1 | 1 | -| 1 | 0 | 1 | -| 1 | 1 | 1 | -|---------------------| - -!split -===== The AND and XOR Gates ===== - -The AND gate is defined as - -|---------------------| -| $x_1$ | $x_2$ | $y$ | -|---------------------| -| 0 | 0 | 0 | -| 0 | 1 | 0 | -| 1 | 0 | 0 | -| 1 | 1 | 1 | -|---------------------| - -And finally we have the XOR gate - -|---------------------| -| $x_1$ | $x_2$ | $y$ | -|---------------------| -| 0 | 0 | 0 | -| 0 | 1 | 1 | -| 1 | 0 | 1 | -| 1 | 1 | 0 | -|---------------------| - -!split -===== Representing the Data Sets ===== - -Our design matrix is defined by the input values $x_1$ and $x_2$. Since we have four possible outputs, our design matrix reads +=== Confusion Matrix === +A _confusion matrix_ summarizes a classifier’s performance by +tabulating predictions versus true labels. For binary classification, +it is a $2\times2$ table whose entries are counts of outcomes: !bt -\bm{X}=\begin{bmatrix} 0 & 0 \\ - 0 & 1 \\ - 1 & 0 \\ - 1 & 1 \end{bmatrix}, +\[ +\begin{array}{l|cc} & \text{Predicted Positive} & \text{Predicted Negative} \\ \hline \text{Actual Positive} & TP & FN \\ \text{Actual Negative} & FP & TN \end{array}. +\] !et -while the vector of outputs is $\bm{y}^T=[0,1,1,0]$ for the XOR gate, $\bm{y}^T=[0,0,0,1]$ for the AND gate and $\bm{y}^T=[0,1,1,1]$ for the OR gate. - - - -Your tasks here are - -o Set up the design matrix with the inputs as discussed above and a vector containing the output, the so-called targets. Note that the design matrix is the same for all gates. You need just to define different outputs. -o Construct a neural network with only one hidden layer and two hidden nodes using the Sigmoid function as activation function. -o Set up the output layer with only one output node and use again the Sigmoid function as activation function for the output. -o Initialize the weights and biases and perform a feed forward pass and compare the outputs with the targets. -o Set up the cost function (cross entropy for classification of binary cases). -o Calculate the gradients needed for the back propagation part. -o Use the gradients to train the network in the back propagation part. Think of using automatic differentiation. -o Train the network and study your results and compare with results obtained either with _scikit-learn_ or _TensorFlow_. - -Everything you develop here can be used directly into the code for the project. - - -!split -===== Setting up dimensionalities by hand ===== - -It can be useful to test the dimensionalities for the network. Let us assume we have performed an optimization for XOR gate and found that the weights for the hidden layer are given by -!bt -\bm{W_h}=\begin{bmatrix} 1 & 1 \\ - 1 & 1 \end{bmatrix}, -!et - -Multiplying $\bm{X}$ and $\bm{W}$ gives +Here TP (true positives) is the number of cases correctly predicted as +positive, FP (false positives) is the number incorrectly predicted as +positive, TN (true negatives) is correctly predicted negative, and FN +(false negatives) is incorrectly predicted negative . In other words, +“positive” means class 1 and “negative” means class 0; for example, TP +occurs when the prediction and actual are both positive. Formally: !bt -\bm{X}{W}_h=\begin{bmatrix} 0 & 0 \\ - 1 & 1 \\ - 1 & 1 \\ - 2 & 2 \end{bmatrix}, +\[ +\text{TPR} = \frac{\text{TP}}{\text{TP} + \text{FN}}, \quad \text{FPR} = \frac{\text{FP}}{\text{FP} + \text{TN}}, +\] !et -Assume also that the bias vector for the hidden layer is +where TPR and FPR are the true and false positive rates defined below. + +In multiclass classification with $K$ classes, the confusion matrix +generalizes to a $K\times K$ table. Entry $N_{ij}$ in the table is +the count of instances whose true class is $i$ and whose predicted +class is $j$. For example, a three-class confusion matrix can be written +as: + !bt -\bm{b}_h=\begin{bmatrix} 0 \\ - -1\end{bmatrix}, +\[ +\begin{array}{c|ccc} & \text{Pred Class 1} & \text{Pred Class 2} & \text{Pred Class 3} \\ \hline \text{Act Class 1} & N_{11} & N_{12} & N_{13} \\ \text{Act Class 2} & N_{21} & N_{22} & N_{23} \\ \text{Act Class 3} & N_{31} & N_{32} & N_{33} \end{array}. +\] !et -Adding it gives us the input to the activation function of the hidden layer + +Here the diagonal entries $N_{ii}$ are the true positives for each +class, and off-diagonal entries are misclassifications. This matrix +allows computation of per-class metrics: e.g. for class $i$, +$\mathrm{TP}_i=N_{ii}$, $\mathrm{FN}_i=\sum_{j\neq i}N_{ij}$, +$\mathrm{FP}_i=\sum_{j\neq i}N_{ji}$, and $\mathrm{TN}_i$ is the sum of +all remaining entries. + +As defined above, TPR and FPR come from the binary case. In binary +terms with $P$ actual positives and $N$ actual negatives, one has !bt -\bm{z}_h=\bm{X}\bm{W}_h+\bm{b}_h=\begin{bmatrix} 0 & -1 \\ - 1 & 0 \\ - 1 & 0 \\ - 2 & 1 \end{bmatrix}, +\[ +\text{TPR} = \frac{TP}{P} = \frac{TP}{TP+FN}, \quad \text{FPR} = +\frac{FP}{N} = \frac{FP}{FP+TN}, +\] !et +as used in standard confusion-matrix +formulations. These rates will be used in constructing ROC curves. -Let us then assume that our activation function is the RELU function, which simply means that we take the max of $0$ and the elements of the input argument $\bm{z}_h$, that is we have +=== ROC Curve === + +The Receiver Operating Characteristic (ROC) curve plots the trade-off +between true positives and false positives as a discrimination +threshold varies. Specifically, for a binary classifier that outputs +a score or probability, one varies the threshold $t$ for declaring +_positive_, and computes at each $t$ the true positive rate +$\mathrm{TPR}(t)$ and false positive rate $\mathrm{FPR}(t)$ using the +confusion matrix at that threshold. The ROC curve is then the graph +of TPR versus FPR. By definition, !bt -\bm{a}_h=\mathrm{RELU}(\bm{z}_h=\bm{X}\bm{W}_h+\bm{b}_h)=\begin{bmatrix} 0 & 0 \\ - 1 & 0 \\ - 1 & 0 \\ - 2 & 1 \end{bmatrix}, +\[ +\mathrm{TPR} = \frac{TP}{TP+FN}, \qquad \mathrm{FPR} = \frac{FP}{FP+TN}, +\] !et -Assume also that the bias of the output layer is zero and that the weights of the output layer are + +where $TP,FP,TN,FN$ are counts determined by threshold $t$. A perfect +classifier would reach the point (FPR=0, TPR=1) at some threshold. + +Formally, the ROC curve is obtained by plotting +$(\mathrm{FPR}(t),\mathrm{TPR}(t))$ for all $t\in[0,1]$ (or as $t$ +sweeps through the sorted scores). The Area Under the ROC Curve (AUC) +quantifies the average performance over all thresholds. It can be +interpreted probabilistically: $\mathrm{AUC} = +\Pr\bigl(s(X^+)>s(X^-)\bigr)$, the probability that a random positive +instance $X^+$ receives a higher score $s$ than a random negative +instance $X^-$ . Equivalently, the AUC is the integral under the ROC +curve: + !bt -\bm{w}_o=\begin{bmatrix} 1 \\ - -2\end{bmatrix}, +\[ +\mathrm{AUC} \;=\; \int_{0}^{1} \mathrm{TPR}(f)\,df, +\] !et -and multiplying with $\bm{a}_h$ gives the output +where $f$ ranges over FPR (or fraction of negatives). A model that guesses at random yields a diagonal ROC (AUC=0.5), whereas a perfect model yields AUC=1.0. + +=== Cumulative Gain === + +The cumulative gain curve (or gains chart) evaluates how many +positives are captured as one targets an increasing fraction of the +population, sorted by model confidence. To construct it, sort all +instances by decreasing predicted probability of the positive class. +Then, for the top $\alpha$ fraction of instances, compute the fraction +of all actual positives that fall in this subset. In formula form, if +$P$ is the total number of positive instances and $P(\alpha)$ is the +number of positives among the top $\alpha$ of the data, the cumulative +gain at level $\alpha$ is !bt -\bm{a}_o=\begin{bmatrix} 0 & 0 \\ - 1 & 0 \\ - 1 & 0 \\ - 2 & 1 \end{bmatrix}\begin{bmatrix} 1 \\ - -2\end{bmatrix}=\begin{bmatrix} 0 \\ 1 \\ 1 \\0\end{bmatrix}, +\[ +\mathrm{Gain}(\alpha) \;=\; \frac{P(\alpha)}{P}. +\] !et -the wanted result. Pay attention to the dimensionalities as well. + +For example, cutting off at the top 10% of predictions yields a gain +equal to (positives in top 10%) divided by (total positives) . +Plotting $\mathrm{Gain}(\alpha)$ versus $\alpha$ (often in percent) +gives the gain curve. The baseline (random) curve is the diagonal +$\mathrm{Gain}(\alpha)=\alpha$, while an ideal model has a steep climb +toward 1. + +A related measure is the {\em lift}, often called the gain ratio. It is the ratio of the model’s capture rate to that of random selection. Equivalently, +!bt +\[ +\mathrm{Lift}(\alpha) \;=\; \frac{\mathrm{Gain}(\alpha)}{\alpha}. +\] +!et + +A lift $>1$ indicates better-than-random targeting. In practice, gain +and lift charts (used e.g.\ in marketing or imbalanced classification) +show how many positives can be “gained” by focusing on a fraction of +the population . + +=== Other measures: Precision, Recall, and the F$_1$ Measure === + +Precision and recall (sensitivity) quantify binary classification +accuracy in terms of positive predictions. They are defined from the +confusion matrix as: +!bt +\[ +\text{Precision} = \frac{TP}{TP + FP}, \qquad \text{Recall} = \frac{TP}{TP + FN}. +\] +!et + +Precision is the fraction of predicted positives that are correct, and +recall is the fraction of actual positives that are correctly +identified . A high-precision classifier makes few false-positive +errors, while a high-recall classifier makes few false-negative +errors. + +The F$_1$ score (balanced F-measure) combines precision and recall into a single metric via their harmonic mean. The usual formula is: +!bt +\[ +F_1 =2\frac{\text{Precision}\times\text{Recall}}{\text{Precision} + \text{Recall}}. +\] +!et +This can be shown to equal +!bt +\[ +\frac{2\,TP}{2\,TP + FP + FN}. +\] +!et + +The F$_1$ score ranges from 0 (worst) to 1 (best), and balances the +trade-off between precision and recall. + +For multi-class classification, one computes per-class +precision/recall/F$_1$ (treating each class as “positive” in a +one-vs-rest manner) and then averages. Common averaging methods are: + +Micro-averaging: Sum all true positives, false positives, and false negatives across classes, then compute precision/recall/F$_1$ from these totals. +Macro-averaging: Compute the F$1$ score $F{1,i}$ for each class $i$ separately, then take the unweighted mean: $F_{1,\mathrm{macro}} = \frac{1}{K}\sum_{i=1}^K F_{1,i}$ . This treats all classes equally regardless of size. +Weighted-averaging: Like macro-average, but weight each class’s $F_{1,i}$ by its support $n_i$ (true count): $F_{1,\mathrm{weighted}} = \frac{1}{N}\sum_{i=1}^K n_i F_{1,i}$, where $N=\sum_i n_i$. This accounts for class imbalance by giving more weight to larger classes . -!split -===== Setting up the Neural Network ===== +Each of these averages has different use-cases. Micro-average is +dominated by common classes, macro-average highlights performance on +rare classes, and weighted-average is a compromise. These formulas +and concepts allow rigorous evaluation of classifier performance in +both binary and multi-class settings. -We define first our design matrix and the various output vectors for the different gates. +===== Exercises ===== -!bc pycod -""" -Simple code that tests XOR, OR and AND gates with linear regression -""" -# import necessary packages -import numpy as np +Here is a simple code example which uses the Logistic regression machinery from _scikit-learn_. +At the end it sets up the confusion matrix and the ROC and cumulative gain curves. +Feel free to use these functionalities (we don't expect you to write your own code for say the confusion matrix). +!bc pycod import matplotlib.pyplot as plt -from sklearn import datasets - -def sigmoid(x): - return 1/(1 + np.exp(-x)) - -def feed_forward(X): - # weighted sum of inputs to the hidden layer - z_h = np.matmul(X, hidden_weights) + hidden_bias - # activation in the hidden layer - a_h = sigmoid(z_h) - - # weighted sum of inputs to the output layer - z_o = np.matmul(a_h, output_weights) + output_bias - # softmax output - # axis 0 holds each input and axis 1 the probabilities of each category - probabilities = sigmoid(z_o) - return probabilities - - -# ensure the same random numbers appear every time -np.random.seed(0) - -# Design matrix -X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) - -# The XOR gate -yXOR = np.array( [ 0, 1 ,1, 0]) -# The OR gate -yOR = np.array( [ 0, 1 ,1, 1]) -# The AND gate -yAND = np.array( [ 0, 0 ,0, 1]) - -# Defining the neural network -n_inputs, n_features = X.shape -n_hidden_neurons = 2 -n_categories = 1 -n_features = 2 - -# we make the weights normally distributed using numpy.random.randn - -# weights and bias in the hidden layer -hidden_weights = np.random.randn(n_features, n_hidden_neurons) -hidden_bias = np.zeros(n_hidden_neurons) + 0.01 - -# weights and bias in the output layer -output_weights = np.random.randn(n_hidden_neurons, n_categories) -output_bias = np.zeros(n_categories) + 0.01 - -probabilities = feed_forward(X) -print(probabilities) - -!ec - -Not an impressive result, but this was our first forward pass with randomly assigned weights. Let us now add the full network with the back-propagation algorithm discussed above. - -!split -===== The Code using Scikit-Learn ===== - -!bc pycod -# import necessary packages import numpy as np -import matplotlib.pyplot as plt -from sklearn.neural_network import MLPClassifier -from sklearn.metrics import accuracy_score -import seaborn as sns +from sklearn.model_selection import train_test_split +# from sklearn.datasets import fill in the data set +from sklearn.linear_model import LogisticRegression -# ensure the same random numbers appear every time -np.random.seed(0) +# Load the data, fill inn +mydata.data = ? -# Design matrix -X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) +X_train, X_test, y_train, y_test = train_test_split(mydata.data,cancer.target,random_state=0) +print(X_train.shape) +print(X_test.shape) +# Logistic Regression +# define which type of problem, binary or multiclass +logreg = LogisticRegression(solver='lbfgs') +logreg.fit(X_train, y_train) -# The XOR gate -yXOR = np.array( [ 0, 1 ,1, 0]) -# The OR gate -yOR = np.array( [ 0, 1 ,1, 1]) -# The AND gate -yAND = np.array( [ 0, 0 ,0, 1]) +from sklearn.preprocessing import LabelEncoder +from sklearn.model_selection import cross_validate +#Cross validation +accuracy = cross_validate(logreg,X_test,y_test,cv=10)['test_score'] +print(accuracy) +print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test))) -# Defining the neural network -n_hidden_neurons = 2 - -eta_vals = np.logspace(-5, 1, 7) -lmbd_vals = np.logspace(-5, 1, 7) -# store models for later use -DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object) -epochs = 100 - -for i, eta in enumerate(eta_vals): - for j, lmbd in enumerate(lmbd_vals): - dnn = MLPClassifier(hidden_layer_sizes=(n_hidden_neurons), activation='logistic', - alpha=lmbd, learning_rate_init=eta, max_iter=epochs) - dnn.fit(X, yXOR) - DNN_scikit[i][j] = dnn - print("Learning rate = ", eta) - print("Lambda = ", lmbd) - print("Accuracy score on data set: ", dnn.score(X, yXOR)) - print() - -sns.set() -test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals))) -for i in range(len(eta_vals)): - for j in range(len(lmbd_vals)): - dnn = DNN_scikit[i][j] - test_pred = dnn.predict(X) - test_accuracy[i][j] = accuracy_score(yXOR, test_pred) - -fig, ax = plt.subplots(figsize = (10, 10)) -sns.heatmap(test_accuracy, annot=True, ax=ax, cmap="viridis") -ax.set_title("Test Accuracy") -ax.set_ylabel("$\eta$") -ax.set_xlabel("$\lambda$") +import scikitplot as skplt +y_pred = logreg.predict(X_test) +skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True) +plt.show() +y_probas = logreg.predict_proba(X_test) +skplt.metrics.plot_roc(y_test, y_probas) +plt.show() +skplt.metrics.plot_cumulative_gain(y_test, y_probas) plt.show() !ec -!split -===== Building a neural network code ===== - -Here we present a flexible object oriented codebase -for a feed forward neural network, along with a demonstration of how -to use it. Before we get into the details of the neural network, we -will first present some implementations of various schedulers, cost -functions and activation functions that can be used together with the -neural network. - -The codes here were developed by Eric Reber and Gregor Kajda during spring 2023. - -=== Learning rate methods === - -The code below shows object oriented implementations of the Constant, -Momentum, Adagrad, AdagradMomentum, RMS prop and Adam schedulers. All -of the classes belong to the shared abstract Scheduler class, and -share the update_change() and reset() methods allowing for any of the -schedulers to be seamlessly used during the training stage, as will -later be shown in the fit() method of the neural -network. Update_change() only has one parameter, the gradient -($δ^l_ja^{l−1}_k$), and returns the change which will be subtracted -from the weights. The reset() function takes no parameters, and resets -the desired variables. For Constant and Momentum, reset does nothing. - - -!bc pycod -import autograd.numpy as np - -class Scheduler: - """ - Abstract class for Schedulers - """ - - def __init__(self, eta): - self.eta = eta - - # should be overwritten - def update_change(self, gradient): - raise NotImplementedError - - # overwritten if needed - def reset(self): - pass - - -class Constant(Scheduler): - def __init__(self, eta): - super().__init__(eta) - - def update_change(self, gradient): - return self.eta * gradient - - def reset(self): - pass - - -class Momentum(Scheduler): - def __init__(self, eta: float, momentum: float): - super().__init__(eta) - self.momentum = momentum - self.change = 0 - - def update_change(self, gradient): - self.change = self.momentum * self.change + self.eta * gradient - return self.change - - def reset(self): - pass - - -class Adagrad(Scheduler): - def __init__(self, eta): - super().__init__(eta) - self.G_t = None - - def update_change(self, gradient): - delta = 1e-8 # avoid division ny zero - - if self.G_t is None: - self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) - - self.G_t += gradient @ gradient.T - - G_t_inverse = 1 / ( - delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) - ) - return self.eta * gradient * G_t_inverse - - def reset(self): - self.G_t = None - - -class AdagradMomentum(Scheduler): - def __init__(self, eta, momentum): - super().__init__(eta) - self.G_t = None - self.momentum = momentum - self.change = 0 - - def update_change(self, gradient): - delta = 1e-8 # avoid division ny zero - - if self.G_t is None: - self.G_t = np.zeros((gradient.shape[0], gradient.shape[0])) - - self.G_t += gradient @ gradient.T - - G_t_inverse = 1 / ( - delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1))) - ) - self.change = self.change * self.momentum + self.eta * gradient * G_t_inverse - return self.change - - def reset(self): - self.G_t = None - - -class RMS_prop(Scheduler): - def __init__(self, eta, rho): - super().__init__(eta) - self.rho = rho - self.second = 0.0 - - def update_change(self, gradient): - delta = 1e-8 # avoid division ny zero - self.second = self.rho * self.second + (1 - self.rho) * gradient * gradient - return self.eta * gradient / (np.sqrt(self.second + delta)) - - def reset(self): - self.second = 0.0 - - -class Adam(Scheduler): - def __init__(self, eta, rho, rho2): - super().__init__(eta) - self.rho = rho - self.rho2 = rho2 - self.moment = 0 - self.second = 0 - self.n_epochs = 1 - - def update_change(self, gradient): - delta = 1e-8 # avoid division ny zero - - self.moment = self.rho * self.moment + (1 - self.rho) * gradient - self.second = self.rho2 * self.second + (1 - self.rho2) * gradient * gradient - - moment_corrected = self.moment / (1 - self.rho**self.n_epochs) - second_corrected = self.second / (1 - self.rho2**self.n_epochs) - - return self.eta * moment_corrected / (np.sqrt(second_corrected + delta)) - - def reset(self): - self.n_epochs += 1 - self.moment = 0 - self.second = 0 - -!ec - -=== Usage of the above learning rate schedulers === - -To initalize a scheduler, simply create the object and pass in the -necessary parameters such as the learning rate and the momentum as -shown below. As the Scheduler class is an abstract class it should not -called directly, and will raise an error upon usage. - -!bc pycod -momentum_scheduler = Momentum(eta=1e-3, momentum=0.9) -adam_scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) -!ec - -Here is a small example for how a segment of code using schedulers -could look. Switching out the schedulers is simple. - -!bc pycod -weights = np.ones((3,3)) -print(f"Before scheduler:\n{weights=}") - -epochs = 10 -for e in range(epochs): - gradient = np.random.rand(3, 3) - change = adam_scheduler.update_change(gradient) - weights = weights - change - adam_scheduler.reset() - -print(f"\nAfter scheduler:\n{weights=}") -!ec - - -=== Cost functions === - -Here we discuss cost functions that can be used when creating the -neural network. Every cost function takes the target vector as its -parameter, and returns a function valued only at $x$ such that it may -easily be differentiated. - - -!bc pycod -import autograd.numpy as np - -def CostOLS(target): - - def func(X): - return (1.0 / target.shape[0]) * np.sum((target - X) ** 2) - - return func - - -def CostLogReg(target): - - def func(X): - - return -(1.0 / target.shape[0]) * np.sum( - (target * np.log(X + 10e-10)) + ((1 - target) * np.log(1 - X + 10e-10)) - ) - - return func - - -def CostCrossEntropy(target): - - def func(X): - return -(1.0 / target.size) * np.sum(target * np.log(X + 10e-10)) - - return func -!ec - - -Below we give a short example of how these cost function may be used -to obtain results if you wish to test them out on your own using -AutoGrad's automatics differentiation. - -!bc pycod -from autograd import grad - -target = np.array([[1, 2, 3]]).T -a = np.array([[4, 5, 6]]).T - -cost_func = CostCrossEntropy -cost_func_derivative = grad(cost_func(target)) - -valued_at_a = cost_func_derivative(a) -print(f"Derivative of cost function {cost_func.__name__} valued at a:\n{valued_at_a}") -!ec - - -=== Activation functions === - -Finally, before we look at the neural network, we will look at the -activation functions which can be specified between the hidden layers -and as the output function. Each function can be valued for any given -vector or matrix X, and can be differentiated via derivate(). - -!bc pycod -import autograd.numpy as np -from autograd import elementwise_grad - -def identity(X): - return X - - -def sigmoid(X): - try: - return 1.0 / (1 + np.exp(-X)) - except FloatingPointError: - return np.where(X > np.zeros(X.shape), np.ones(X.shape), np.zeros(X.shape)) - - -def softmax(X): - X = X - np.max(X, axis=-1, keepdims=True) - delta = 10e-10 - return np.exp(X) / (np.sum(np.exp(X), axis=-1, keepdims=True) + delta) - - -def RELU(X): - return np.where(X > np.zeros(X.shape), X, np.zeros(X.shape)) - - -def LRELU(X): - delta = 10e-4 - return np.where(X > np.zeros(X.shape), X, delta * X) - - -def derivate(func): - if func.__name__ == "RELU": - - def func(X): - return np.where(X > 0, 1, 0) - - return func - - elif func.__name__ == "LRELU": - - def func(X): - delta = 10e-4 - return np.where(X > 0, 1, delta) - - return func - - else: - return elementwise_grad(func) -!ec - -Below follows a short demonstration of how to use an activation -function. The derivative of the activation function will be important -when calculating the output delta term during backpropagation. Note -that derivate() can also be used for cost functions for a more -generalized approach. - -!bc pycod -z = np.array([[4, 5, 6]]).T -print(f"Input to activation function:\n{z}") - -act_func = sigmoid -a = act_func(z) -print(f"\nOutput from {act_func.__name__} activation function:\n{a}") - -act_func_derivative = derivate(act_func) -valued_at_z = act_func_derivative(a) -print(f"\nDerivative of {act_func.__name__} activation function valued at z:\n{valued_at_z}") -!ec - -=== The Neural Network === - -Now that we have gotten a good understanding of the implementation of -some important components, we can take a look at an object oriented -implementation of a feed forward neural network. The feed forward -neural network has been implemented as a class named FFNN, which can -be initiated as a regressor or classifier dependant on the choice of -cost function. The FFNN can have any number of input nodes, hidden -layers with any amount of hidden nodes, and any amount of output nodes -meaning it can perform multiclass classification as well as binary -classification and regression problems. Although there is a lot of -code present, it makes for an easy to use and generalizeable interface -for creating many types of neural networks as will be demonstrated -below. - -!bc pycod -import math -import autograd.numpy as np -import sys -import warnings -from autograd import grad, elementwise_grad -from random import random, seed -from copy import deepcopy, copy -from typing import Tuple, Callable -from sklearn.utils import resample - -warnings.simplefilter("error") - - -class FFNN: - """ - Description: - ------------ - Feed Forward Neural Network with interface enabling flexible design of a - nerual networks architecture and the specification of activation function - in the hidden layers and output layer respectively. This model can be used - for both regression and classification problems, depending on the output function. - - Attributes: - ------------ - I dimensions (tuple[int]): A list of positive integers, which specifies the - number of nodes in each of the networks layers. The first integer in the array - defines the number of nodes in the input layer, the second integer defines number - of nodes in the first hidden layer and so on until the last number, which - specifies the number of nodes in the output layer. - II hidden_func (Callable): The activation function for the hidden layers - III output_func (Callable): The activation function for the output layer - IV cost_func (Callable): Our cost function - V seed (int): Sets random seed, makes results reproducible - """ - - def __init__( - self, - dimensions: tuple[int], - hidden_func: Callable = sigmoid, - output_func: Callable = lambda x: x, - cost_func: Callable = CostOLS, - seed: int = None, - ): - self.dimensions = dimensions - self.hidden_func = hidden_func - self.output_func = output_func - self.cost_func = cost_func - self.seed = seed - self.weights = list() - self.schedulers_weight = list() - self.schedulers_bias = list() - self.a_matrices = list() - self.z_matrices = list() - self.classification = None - - self.reset_weights() - self._set_classification() - - def fit( - self, - X: np.ndarray, - t: np.ndarray, - scheduler: Scheduler, - batches: int = 1, - epochs: int = 100, - lam: float = 0, - X_val: np.ndarray = None, - t_val: np.ndarray = None, - ): - """ - Description: - ------------ - This function performs the training the neural network by performing the feedforward and backpropagation - algorithm to update the networks weights. - - Parameters: - ------------ - I X (np.ndarray) : training data - II t (np.ndarray) : target data - III scheduler (Scheduler) : specified scheduler (algorithm for optimization of gradient descent) - IV scheduler_args (list[int]) : list of all arguments necessary for scheduler - - Optional Parameters: - ------------ - V batches (int) : number of batches the datasets are split into, default equal to 1 - VI epochs (int) : number of iterations used to train the network, default equal to 100 - VII lam (float) : regularization hyperparameter lambda - VIII X_val (np.ndarray) : validation set - IX t_val (np.ndarray) : validation target set - - Returns: - ------------ - I scores (dict) : A dictionary containing the performance metrics of the model. - The number of the metrics depends on the parameters passed to the fit-function. - - """ - - # setup - if self.seed is not None: - np.random.seed(self.seed) - - val_set = False - if X_val is not None and t_val is not None: - val_set = True - - # creating arrays for score metrics - train_errors = np.empty(epochs) - train_errors.fill(np.nan) - val_errors = np.empty(epochs) - val_errors.fill(np.nan) - - train_accs = np.empty(epochs) - train_accs.fill(np.nan) - val_accs = np.empty(epochs) - val_accs.fill(np.nan) - - self.schedulers_weight = list() - self.schedulers_bias = list() - - batch_size = X.shape[0] // batches - - X, t = resample(X, t) - - # this function returns a function valued only at X - cost_function_train = self.cost_func(t) - if val_set: - cost_function_val = self.cost_func(t_val) - - # create schedulers for each weight matrix - for i in range(len(self.weights)): - self.schedulers_weight.append(copy(scheduler)) - self.schedulers_bias.append(copy(scheduler)) - - print(f"{scheduler.__class__.__name__}: Eta={scheduler.eta}, Lambda={lam}") - - try: - for e in range(epochs): - for i in range(batches): - # allows for minibatch gradient descent - if i == batches - 1: - # If the for loop has reached the last batch, take all thats left - X_batch = X[i * batch_size :, :] - t_batch = t[i * batch_size :, :] - else: - X_batch = X[i * batch_size : (i + 1) * batch_size, :] - t_batch = t[i * batch_size : (i + 1) * batch_size, :] - - self._feedforward(X_batch) - self._backpropagate(X_batch, t_batch, lam) - - # reset schedulers for each epoch (some schedulers pass in this call) - for scheduler in self.schedulers_weight: - scheduler.reset() - - for scheduler in self.schedulers_bias: - scheduler.reset() - - # computing performance metrics - pred_train = self.predict(X) - train_error = cost_function_train(pred_train) - - train_errors[e] = train_error - if val_set: - - pred_val = self.predict(X_val) - val_error = cost_function_val(pred_val) - val_errors[e] = val_error - - if self.classification: - train_acc = self._accuracy(self.predict(X), t) - train_accs[e] = train_acc - if val_set: - val_acc = self._accuracy(pred_val, t_val) - val_accs[e] = val_acc - - # printing progress bar - progression = e / epochs - print_length = self._progress_bar( - progression, - train_error=train_errors[e], - train_acc=train_accs[e], - val_error=val_errors[e], - val_acc=val_accs[e], - ) - except KeyboardInterrupt: - # allows for stopping training at any point and seeing the result - pass - - # visualization of training progression (similiar to tensorflow progression bar) - sys.stdout.write("\r" + " " * print_length) - sys.stdout.flush() - self._progress_bar( - 1, - train_error=train_errors[e], - train_acc=train_accs[e], - val_error=val_errors[e], - val_acc=val_accs[e], - ) - sys.stdout.write("") - - # return performance metrics for the entire run - scores = dict() - - scores["train_errors"] = train_errors - - if val_set: - scores["val_errors"] = val_errors - - if self.classification: - scores["train_accs"] = train_accs - - if val_set: - scores["val_accs"] = val_accs - - return scores - - def predict(self, X: np.ndarray, *, threshold=0.5): - """ - Description: - ------------ - Performs prediction after training of the network has been finished. - - Parameters: - ------------ - I X (np.ndarray): The design matrix, with n rows of p features each - - Optional Parameters: - ------------ - II threshold (float) : sets minimal value for a prediction to be predicted as the positive class - in classification problems - - Returns: - ------------ - I z (np.ndarray): A prediction vector (row) for each row in our design matrix - This vector is thresholded if regression=False, meaning that classification results - in a vector of 1s and 0s, while regressions in an array of decimal numbers - - """ - - predict = self._feedforward(X) - - if self.classification: - return np.where(predict > threshold, 1, 0) - else: - return predict - - def reset_weights(self): - """ - Description: - ------------ - Resets/Reinitializes the weights in order to train the network for a new problem. - - """ - if self.seed is not None: - np.random.seed(self.seed) - - self.weights = list() - for i in range(len(self.dimensions) - 1): - weight_array = np.random.randn( - self.dimensions[i] + 1, self.dimensions[i + 1] - ) - weight_array[0, :] = np.random.randn(self.dimensions[i + 1]) * 0.01 - - self.weights.append(weight_array) - - def _feedforward(self, X: np.ndarray): - """ - Description: - ------------ - Calculates the activation of each layer starting at the input and ending at the output. - Each following activation is calculated from a weighted sum of each of the preceeding - activations (except in the case of the input layer). - - Parameters: - ------------ - I X (np.ndarray): The design matrix, with n rows of p features each - - Returns: - ------------ - I z (np.ndarray): A prediction vector (row) for each row in our design matrix - """ - - # reset matrices - self.a_matrices = list() - self.z_matrices = list() - - # if X is just a vector, make it into a matrix - if len(X.shape) == 1: - X = X.reshape((1, X.shape[0])) - - # Add a coloumn of zeros as the first coloumn of the design matrix, in order - # to add bias to our data - bias = np.ones((X.shape[0], 1)) * 0.01 - X = np.hstack([bias, X]) - - # a^0, the nodes in the input layer (one a^0 for each row in X - where the - # exponent indicates layer number). - a = X - self.a_matrices.append(a) - self.z_matrices.append(a) - - # The feed forward algorithm - for i in range(len(self.weights)): - if i < len(self.weights) - 1: - z = a @ self.weights[i] - self.z_matrices.append(z) - a = self.hidden_func(z) - # bias column again added to the data here - bias = np.ones((a.shape[0], 1)) * 0.01 - a = np.hstack([bias, a]) - self.a_matrices.append(a) - else: - try: - # a^L, the nodes in our output layers - z = a @ self.weights[i] - a = self.output_func(z) - self.a_matrices.append(a) - self.z_matrices.append(z) - except Exception as OverflowError: - print( - "OverflowError in fit() in FFNN\nHOW TO DEBUG ERROR: Consider lowering your learning rate or scheduler specific parameters such as momentum, or check if your input values need scaling" - ) - - # this will be a^L - return a - - def _backpropagate(self, X, t, lam): - """ - Description: - ------------ - Performs the backpropagation algorithm. In other words, this method - calculates the gradient of all the layers starting at the - output layer, and moving from right to left accumulates the gradient until - the input layer is reached. Each layers respective weights are updated while - the algorithm propagates backwards from the output layer (auto-differentation in reverse mode). - - Parameters: - ------------ - I X (np.ndarray): The design matrix, with n rows of p features each. - II t (np.ndarray): The target vector, with n rows of p targets. - III lam (float32): regularization parameter used to punish the weights in case of overfitting - - Returns: - ------------ - No return value. - - """ - out_derivative = derivate(self.output_func) - hidden_derivative = derivate(self.hidden_func) - - for i in range(len(self.weights) - 1, -1, -1): - # delta terms for output - if i == len(self.weights) - 1: - # for multi-class classification - if ( - self.output_func.__name__ == "softmax" - ): - delta_matrix = self.a_matrices[i + 1] - t - # for single class classification - else: - cost_func_derivative = grad(self.cost_func(t)) - delta_matrix = out_derivative( - self.z_matrices[i + 1] - ) * cost_func_derivative(self.a_matrices[i + 1]) - - # delta terms for hidden layer - else: - delta_matrix = ( - self.weights[i + 1][1:, :] @ delta_matrix.T - ).T * hidden_derivative(self.z_matrices[i + 1]) - - # calculate gradient - gradient_weights = self.a_matrices[i][:, 1:].T @ delta_matrix - gradient_bias = np.sum(delta_matrix, axis=0).reshape( - 1, delta_matrix.shape[1] - ) - - # regularization term - gradient_weights += self.weights[i][1:, :] * lam - - # use scheduler - update_matrix = np.vstack( - [ - self.schedulers_bias[i].update_change(gradient_bias), - self.schedulers_weight[i].update_change(gradient_weights), - ] - ) - - # update weights and bias - self.weights[i] -= update_matrix - - def _accuracy(self, prediction: np.ndarray, target: np.ndarray): - """ - Description: - ------------ - Calculates accuracy of given prediction to target - - Parameters: - ------------ - I prediction (np.ndarray): vector of predicitons output network - (1s and 0s in case of classification, and real numbers in case of regression) - II target (np.ndarray): vector of true values (What the network ideally should predict) - - Returns: - ------------ - A floating point number representing the percentage of correctly classified instances. - """ - assert prediction.size == target.size - return np.average((target == prediction)) - def _set_classification(self): - """ - Description: - ------------ - Decides if FFNN acts as classifier (True) og regressor (False), - sets self.classification during init() - """ - self.classification = False - if ( - self.cost_func.__name__ == "CostLogReg" - or self.cost_func.__name__ == "CostCrossEntropy" - ): - self.classification = True - - def _progress_bar(self, progression, **kwargs): - """ - Description: - ------------ - Displays progress of training - """ - print_length = 40 - num_equals = int(progression * print_length) - num_not = print_length - num_equals - arrow = ">" if num_equals > 0 else "" - bar = "[" + "=" * (num_equals - 1) + arrow + "-" * num_not + "]" - perc_print = self._format(progression * 100, decimals=5) - line = f" {bar} {perc_print}% " - - for key in kwargs: - if not np.isnan(kwargs[key]): - value = self._format(kwargs[key], decimals=4) - line += f"| {key}: {value} " - sys.stdout.write("\r" + line) - sys.stdout.flush() - return len(line) - - def _format(self, value, decimals=4): - """ - Description: - ------------ - Formats decimal numbers for progress bar - """ - if value > 0: - v = value - elif value < 0: - v = -10 * value - else: - v = 1 - n = 1 + math.floor(math.log10(v)) - if n >= decimals - 1: - return str(round(value)) - return f"{value:.{decimals-n-1}f}" -!ec - -Before we make a model, we will quickly generate a dataset we can use -for our linear regression problem as shown below - -!bc pycod -import autograd.numpy as np -from sklearn.model_selection import train_test_split - -def SkrankeFunction(x, y): - return np.ravel(0 + 1*x + 2*y + 3*x**2 + 4*x*y + 5*y**2) - -def create_X(x, y, n): - if len(x.shape) > 1: - x = np.ravel(x) - y = np.ravel(y) - - N = len(x) - l = int((n + 1) * (n + 2) / 2) # Number of elements in beta - X = np.ones((N, l)) - - for i in range(1, n + 1): - q = int((i) * (i + 1) / 2) - for k in range(i + 1): - X[:, q + k] = (x ** (i - k)) * (y**k) - - return X - -step=0.5 -x = np.arange(0, 1, step) -y = np.arange(0, 1, step) -x, y = np.meshgrid(x, y) -target = SkrankeFunction(x, y) -target = target.reshape(target.shape[0], 1) - -poly_degree=3 -X = create_X(x, y, poly_degree) - -X_train, X_test, t_train, t_test = train_test_split(X, target) - -!ec - -Now that we have our dataset ready for the regression, we can create -our regressor. Note that with the seed parameter, we can make sure our -results stay the same every time we run the neural network. For -inititialization, we simply specify the dimensions (we wish the amount -of input nodes to be equal to the datapoints, and the output to -predict one value). - - -!bc pycod -input_nodes = X_train.shape[1] -output_nodes = 1 - -linear_regression = FFNN((input_nodes, output_nodes), output_func=identity, cost_func=CostOLS, seed=2023) - -!ec - -We then fit our model with our training data using the scheduler of our choice. - -!bc pycod -linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights - -scheduler = Constant(eta=1e-3) -scores = linear_regression.fit(X_train, t_train, scheduler) - - -!ec - -Due to the progress bar we can see the MSE (train_error) throughout -the FFNN's training. Note that the fit() function has some optional -parameters with defualt arguments. For example, the regularization -hyperparameter can be left ignored if not needed, and equally the FFNN -will by default run for 100 epochs. These can easily be changed, such -as for example: - -!bc pycod -linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights - -scores = linear_regression.fit(X_train, t_train, scheduler, lam=1e-4, epochs=1000) - -!ec - -We see that given more epochs to train on, the regressor reaches a lower MSE. - -Let us then switch to a binary classification. We use a binary -classification dataset, and follow a similar setup to the regression -case. - - - -!bc pycod -from sklearn.datasets import load_breast_cancer -from sklearn.preprocessing import MinMaxScaler - -wisconsin = load_breast_cancer() -X = wisconsin.data -target = wisconsin.target -target = target.reshape(target.shape[0], 1) - -X_train, X_val, t_train, t_val = train_test_split(X, target) - -scaler = MinMaxScaler() -scaler.fit(X_train) -X_train = scaler.transform(X_train) -X_val = scaler.transform(X_val) - - -!ec - -!bc pycod -input_nodes = X_train.shape[1] -output_nodes = 1 - -logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) - -!ec - -We will now make use of our validation data by passing it into our fit function as a keyword argument - -!bc pycod -logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights - -scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999) -scores = logistic_regression.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) - - -!ec - -Finally, we will create a neural network with 2 hidden layers with activation functions. -!bc pycod -input_nodes = X_train.shape[1] -hidden_nodes1 = 100 -hidden_nodes2 = 30 -output_nodes = 1 - -dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) - -neural_network = FFNN(dims, hidden_func=RELU, output_func=sigmoid, cost_func=CostLogReg, seed=2023) - - -!ec - -!bc pycod -neural_network.reset_weights() # reset weights such that previous runs or reruns don't affect the weights - -scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) -scores = neural_network.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val) - -!ec - -=== Multiclass classification === - -Finally, we will demonstrate the use case of multiclass classification -using our FFNN with the famous MNIST dataset, which contain images of -digits between the range of 0 to 9. - +=== Exercise a) === +Convince yourself about the mathematics for the confusion matrix, the ROC and the cumlative gain curves for both a binary and a multiclass classification problem. +=== Exercise b) === +Use a binary classification data available from _scikit-learn_. As an example you can use +the MNIST data set and just specialize to two numbers. To do so you can use the following code lines !bc pycod from sklearn.datasets import load_digits - -def onehot(target: np.ndarray): - onehot = np.zeros((target.size, target.max() + 1)) - onehot[np.arange(target.size), target] = 1 - return onehot - -digits = load_digits() - -X = digits.data -target = digits.target -target = onehot(target) - -input_nodes = 64 -hidden_nodes1 = 100 -hidden_nodes2 = 30 -output_nodes = 10 - -dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes) - -multiclass = FFNN(dims, hidden_func=LRELU, output_func=softmax, cost_func=CostCrossEntropy) - -multiclass.reset_weights() # reset weights such that previous runs or reruns don't affect the weights - -scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999) -scores = multiclass.fit(X, target, scheduler, epochs=1000) - +digits = load_digits(n_class=2) # Load only two classes, e.g., 0 and 1 +X, y = digits.data, digits.target !ec - - -!split -===== Testing the XOR gate and other gates ===== - -Let us now use our code to test the XOR gate. - +Alternatively, you can use the _make$\_$classification_ +functionality. This function generates a random $n$-class classification +dataset, which can be configured for binary classification by setting +n_classes=2. You can also control the number of samples, features, +informative features, redundant features, and more. !bc pycod -X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64) - -# The XOR gate -yXOR = np.array( [[ 0], [1] ,[1], [0]]) - -input_nodes = X.shape[1] -output_nodes = 1 - -logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023) -logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights -scheduler = Adam(eta=1e-1, rho=0.9, rho2=0.999) -scores = logistic_regression.fit(X, yXOR, scheduler, epochs=1000) +from sklearn.datasets import make_classification +X, y = make_classification(n_samples=1000, n_features=20, n_informative=10, n_redundant=5, n_classes=2, random_state=42) !ec -Not bad, but the results depend strongly on the learning reate. Try different learning rates. +You can use this option for the multiclass case as well, see the next exercise. +If you prefer to study other binary classification datasets, feel free +to replace the above suggestions with your own dataset. + +Make plots of the confusion matrix, the ROC curve and the cumulative gain curve. + +=== Exercise c) week 43 === + +As a multiclass problem, we will use the Iris data set discussed in +the exercises from weeks 41 and 42. This is a three-class data set and +you can set it up using _scikit-learn_, +!bc pycod +from sklearn.datasets import load_iris +iris = load_iris() +X = iris.data # Features +y = iris.target # Target labels +!ec + +Make plots of the confusion matrix, the ROC curve and the cumulative +gain curve for this (or other) multiclass data set. From 72a983d4464d386b90feb6d5ed46f1c4e8e06030 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 20 Oct 2025 09:41:54 +0200 Subject: [PATCH 08/14] update of week 43 --- .../_build/.doctrees/environment.pickle | Bin 473882 -> 511606 bytes .../_build/.doctrees/exercisesweek43.doctree | Bin 0 -> 49275 bytes .../_build/.doctrees/intro.doctree | Bin 46043 -> 46086 bytes .../_build/.doctrees/week43.doctree | Bin 0 -> 396528 bytes .../html/_sources/exercisesweek43.ipynb | 617 ++ .../_build/html/_sources/week43.ipynb | 5948 +++++++++++++++++ doc/LectureNotes/_build/html/chapter1.html | 3 + doc/LectureNotes/_build/html/chapter10.html | 3 + doc/LectureNotes/_build/html/chapter11.html | 3 + doc/LectureNotes/_build/html/chapter12.html | 3 + doc/LectureNotes/_build/html/chapter13.html | 3 + doc/LectureNotes/_build/html/chapter2.html | 3 + doc/LectureNotes/_build/html/chapter3.html | 3 + doc/LectureNotes/_build/html/chapter4.html | 3 + doc/LectureNotes/_build/html/chapter5.html | 3 + doc/LectureNotes/_build/html/chapter6.html | 3 + doc/LectureNotes/_build/html/chapter7.html | 3 + doc/LectureNotes/_build/html/chapter8.html | 3 + doc/LectureNotes/_build/html/chapter9.html | 3 + .../_build/html/chapteroptimization.html | 3 + doc/LectureNotes/_build/html/clustering.html | 3 + .../_build/html/exercisesweek34.html | 3 + .../_build/html/exercisesweek35.html | 3 + .../_build/html/exercisesweek36.html | 3 + .../_build/html/exercisesweek37.html | 3 + .../_build/html/exercisesweek38.html | 3 + .../_build/html/exercisesweek39.html | 3 + .../_build/html/exercisesweek41.html | 3 + .../_build/html/exercisesweek42.html | 9 +- .../_build/html/exercisesweek43.html | 846 +++ doc/LectureNotes/_build/html/genindex.html | 3 + doc/LectureNotes/_build/html/intro.html | 3 + doc/LectureNotes/_build/html/linalg.html | 3 + doc/LectureNotes/_build/html/objects.inv | Bin 1212 -> 1249 bytes doc/LectureNotes/_build/html/project1.html | 9 +- doc/LectureNotes/_build/html/project2.html | 3 + doc/LectureNotes/_build/html/schedule.html | 3 + doc/LectureNotes/_build/html/search.html | 3 + doc/LectureNotes/_build/html/searchindex.js | 2 +- doc/LectureNotes/_build/html/statistics.html | 3 + doc/LectureNotes/_build/html/teachers.html | 3 + doc/LectureNotes/_build/html/textbooks.html | 3 + doc/LectureNotes/_build/html/week34.html | 3 + doc/LectureNotes/_build/html/week35.html | 3 + doc/LectureNotes/_build/html/week36.html | 3 + doc/LectureNotes/_build/html/week37.html | 3 + doc/LectureNotes/_build/html/week38.html | 3 + doc/LectureNotes/_build/html/week39.html | 3 + doc/LectureNotes/_build/html/week40.html | 3 + doc/LectureNotes/_build/html/week41.html | 3 + doc/LectureNotes/_build/html/week42.html | 3 + doc/LectureNotes/_build/html/week43.html | 4609 +++++++++++++ .../jupyter_execute/exercisesweek43.ipynb | 617 ++ .../_build/jupyter_execute/week43.ipynb | 5948 +++++++++++++++++ 54 files changed, 18718 insertions(+), 7 deletions(-) create mode 100644 doc/LectureNotes/_build/.doctrees/exercisesweek43.doctree create mode 100644 doc/LectureNotes/_build/.doctrees/week43.doctree create mode 100644 doc/LectureNotes/_build/html/_sources/exercisesweek43.ipynb create mode 100644 doc/LectureNotes/_build/html/_sources/week43.ipynb create mode 100644 doc/LectureNotes/_build/html/exercisesweek43.html create mode 100644 doc/LectureNotes/_build/html/week43.html create mode 100644 doc/LectureNotes/_build/jupyter_execute/exercisesweek43.ipynb create mode 100644 doc/LectureNotes/_build/jupyter_execute/week43.ipynb diff --git a/doc/LectureNotes/_build/.doctrees/environment.pickle b/doc/LectureNotes/_build/.doctrees/environment.pickle index b80b16b8fad4022a6802bdde5e4e5696786513fa..1e49cad6e2ef933efa53d77e0f6aca1a60ad69b0 100644 GIT binary patch literal 511606 zcmd4437i~9bw6%f$4V<{wX0jQY_&YLwJY!J>Xs~@tJCu8LMvN7BoDnay*o3S%hNN` zu4RESm%JISu#k`tt`G?MK|(?ZcS5*A;1?1;3FMc5@=HQueh}aX3BM2sgyjEyue!Rb zXL?pr&9sO<_H1`m_p8_MRlR!k-m6#7%z48N*Ij=d{i`i;OX*BuV!$b!%an_Syi=%5 z*ShyqGr81$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1}^E0qH#%@d10WMI)Lq>0||64o(@K4aD{ z7*Uwi0Z`nfE0yP;vhztNijz;#jF~MKjLP0eQ5zTISez-KzMx9n`Xvcy!OJM@I+9IZ zTF0?|%VG&3b8r~(-f+XPK(JCOw=-Yb>cYTr7!7;fIH`)LwI2-by4 z>r=S+ntK=I!9jn~fvm<_$OZBI6#2kDhT` z5|~i4Gf_U2iA14%Hs(Pe<$z2QiJ3?AP|XlMVGLKS7g_Iwfs8oHhjwfN&Kl`xe&{q{ z74}H1>FAJ`Td57;?l!u(L+BY=GwF4UaoR{QgHbew2FCUDc7c4Ghyk2v4oFtY2R9r; z(Q`IrQWi>)k==0Az*l6n4g1+Oyp4(*(1G8uPuLwgfZXJ4i1Gk`OTY3Uk!R=WS$hYXSeFIb-C9jHrWo1nNtVl$$ZE zKpBYUkjYVBq^xp#-pFA5B4~7Qn3DK<*D*KPCgXlVU6{vnfU4AjF|zlc@vqbFdT)F z`8)(Ul{MvNp#Tzw#N@G@Nut}_v{9=NO#>Tz2-627krU0>cwa80FALl+qOI||Th_(& zZK3-OH7=|}MXMjz(8opYN2*WBUcQ?>E7m3Swb{%KpE8p}F!2>dui1+5OIPPXJ59Av z`Ou^@i$G@7vNPeWZdk5N-t`_?PK z!&KCk*M1>xlBh*Q0q5^aT~VL~lUEcm24OU`q>?!wrJm|~(oeMABi40*!io|eP5A0* Uh*b~tKdi6eaZBYehHC5oKLTtI{{R30 diff --git a/doc/LectureNotes/_build/.doctrees/exercisesweek43.doctree b/doc/LectureNotes/_build/.doctrees/exercisesweek43.doctree new file mode 100644 index 0000000000000000000000000000000000000000..675ddfade47eafda3c5de3ca8aa8e03b58bb7bb3 GIT binary patch literal 49275 zcmeHw4~!(&nV0w9>`v`^|Jh#0Nt~3|V{gy6yLV=G<3#I>ll?cbcfI4i^*GtYue!joiFND*camROiUd`->_u-40Ww+~|>GWU4%fs}2 zV7L8p)WIHn9k;digowjbSn_kWK zP5+K*-a31xTzAXCdZ6p2(z9CM+W%_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GrJTz(UW0Gp)5ord5|LvW@c_|gzuX$YP) z1V{qjtfHB@<)WM<=?Al+S}J)x`n3wFa8pm_GS_`p=mGkm(aAU zNZ5p?{hYsqrcIHs2~GQB{vu5)-p=I9S0MRw{t_yd=A%%tuk)8sv4@4SVaAK^<1e9N z5A#u|*nj6Qp<;(g)P#!tm_$ve*o!1;Ld8BrQYKXFTl^(dY#WK1P_eW8B~^B3t^@slKP-@gIL3?GGt{e+J~!#+xq zCNyj>Nt)2GHv_?nUnMoWm5ETZZ}HdX6G)yVaU(S=zQo5v+mZZ$kECP8d-y2i>uNp< z`TAY{67uz*`Af)G8i=UK*Nglm%{(lsGuJ4nrhkmdMG2-zn{&4iGx-G^U7$iBm0 zLdeEQ&HnTbB;V#QA!#r0QApY@(lsGzKjJSTX`dv86Oy*(Fn$S1W3XOD(ip5uku>_M zFTO~UMn|2BxY28+B5u5N72;OhFBEQ*%fkvgunC^5)j=Elf_lTFiuq2lZ|)oN*YXxT z@4{@Q6tKne^18^&;Oh;c8aJ3$rO=j8{Wx`2{bigXu8-EGb8z^_K}z^Wo*1u!O-@O% zr#RJLaUc0fyni2\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "119c0988", + "metadata": { + "editable": true + }, + "source": [ + "# Exercises week 43 \n", + "**October 20-24, 2025**\n", + "\n", + "Date: **Deadline Friday October 24 at midnight**" + ] + }, + { + "cell_type": "markdown", + "id": "909887eb", + "metadata": { + "editable": true + }, + "source": [ + "# Overarching aims of the exercises weeks 43 and 44\n", + "\n", + "The aim of the exercises this week is to gain some confidence with\n", + "ways to visualize the results of a classification problem. We will\n", + "target three ways of setting up the analysis. The first and simplest\n", + "one is the\n", + "1. so-called confusion matrix, and the next is the\n", + "\n", + "2. ROC curve and finally the\n", + "\n", + "3. Cumulative gain curve.\n", + "\n", + "We will use Logistic Regression as method for the classification in\n", + "this exercise. You can compare these results with those obtained with\n", + "your neural network code from project 2 without a hidden layer.\n", + "\n", + "In these exercises we will use binary and multi-class data sets\n", + "(the Iris data set from week 41).\n", + "\n", + "The underlying mathematics is described here." + ] + }, + { + "cell_type": "markdown", + "id": "1e1cb4fb", + "metadata": { + "editable": true + }, + "source": [ + "### Confusion Matrix\n", + "\n", + "A **confusion matrix** summarizes a classifier’s performance by\n", + "tabulating predictions versus true labels. For binary classification,\n", + "it is a $2\\times2$ table whose entries are counts of outcomes:" + ] + }, + { + "cell_type": "markdown", + "id": "7b090385", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{array}{l|cc} & \\text{Predicted Positive} & \\text{Predicted Negative} \\\\ \\hline \\text{Actual Positive} & TP & FN \\\\ \\text{Actual Negative} & FP & TN \\end{array}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "1e14904b", + "metadata": { + "editable": true + }, + "source": [ + "Here TP (true positives) is the number of cases correctly predicted as\n", + "positive, FP (false positives) is the number incorrectly predicted as\n", + "positive, TN (true negatives) is correctly predicted negative, and FN\n", + "(false negatives) is incorrectly predicted negative . In other words,\n", + "“positive” means class 1 and “negative” means class 0; for example, TP\n", + "occurs when the prediction and actual are both positive. Formally:" + ] + }, + { + "cell_type": "markdown", + "id": "e93ea290", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{TPR} = \\frac{\\text{TP}}{\\text{TP} + \\text{FN}}, \\quad \\text{FPR} = \\frac{\\text{FP}}{\\text{FP} + \\text{TN}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "c80bea5b", + "metadata": { + "editable": true + }, + "source": [ + "where TPR and FPR are the true and false positive rates defined below.\n", + "\n", + "In multiclass classification with $K$ classes, the confusion matrix\n", + "generalizes to a $K\\times K$ table. Entry $N_{ij}$ in the table is\n", + "the count of instances whose true class is $i$ and whose predicted\n", + "class is $j$. For example, a three-class confusion matrix can be written\n", + "as:" + ] + }, + { + "cell_type": "markdown", + "id": "a0f68f5f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{array}{c|ccc} & \\text{Pred Class 1} & \\text{Pred Class 2} & \\text{Pred Class 3} \\\\ \\hline \\text{Act Class 1} & N_{11} & N_{12} & N_{13} \\\\ \\text{Act Class 2} & N_{21} & N_{22} & N_{23} \\\\ \\text{Act Class 3} & N_{31} & N_{32} & N_{33} \\end{array}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "869669b2", + "metadata": { + "editable": true + }, + "source": [ + "Here the diagonal entries $N_{ii}$ are the true positives for each\n", + "class, and off-diagonal entries are misclassifications. This matrix\n", + "allows computation of per-class metrics: e.g. for class $i$,\n", + "$\\mathrm{TP}_i=N_{ii}$, $\\mathrm{FN}_i=\\sum_{j\\neq i}N_{ij}$,\n", + "$\\mathrm{FP}_i=\\sum_{j\\neq i}N_{ji}$, and $\\mathrm{TN}_i$ is the sum of\n", + "all remaining entries.\n", + "\n", + "As defined above, TPR and FPR come from the binary case. In binary\n", + "terms with $P$ actual positives and $N$ actual negatives, one has" + ] + }, + { + "cell_type": "markdown", + "id": "2abd82a7", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{TPR} = \\frac{TP}{P} = \\frac{TP}{TP+FN}, \\quad \\text{FPR} =\n", + "\\frac{FP}{N} = \\frac{FP}{FP+TN},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2f79325c", + "metadata": { + "editable": true + }, + "source": [ + "as used in standard confusion-matrix\n", + "formulations. These rates will be used in constructing ROC curves." + ] + }, + { + "cell_type": "markdown", + "id": "0ce65a47", + "metadata": { + "editable": true + }, + "source": [ + "### ROC Curve\n", + "\n", + "The Receiver Operating Characteristic (ROC) curve plots the trade-off\n", + "between true positives and false positives as a discrimination\n", + "threshold varies. Specifically, for a binary classifier that outputs\n", + "a score or probability, one varies the threshold $t$ for declaring\n", + "**positive**, and computes at each $t$ the true positive rate\n", + "$\\mathrm{TPR}(t)$ and false positive rate $\\mathrm{FPR}(t)$ using the\n", + "confusion matrix at that threshold. The ROC curve is then the graph\n", + "of TPR versus FPR. By definition," + ] + }, + { + "cell_type": "markdown", + "id": "d750fdff", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{TPR} = \\frac{TP}{TP+FN}, \\qquad \\mathrm{FPR} = \\frac{FP}{FP+TN},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "561bfb2c", + "metadata": { + "editable": true + }, + "source": [ + "where $TP,FP,TN,FN$ are counts determined by threshold $t$. A perfect\n", + "classifier would reach the point (FPR=0, TPR=1) at some threshold.\n", + "\n", + "Formally, the ROC curve is obtained by plotting\n", + "$(\\mathrm{FPR}(t),\\mathrm{TPR}(t))$ for all $t\\in[0,1]$ (or as $t$\n", + "sweeps through the sorted scores). The Area Under the ROC Curve (AUC)\n", + "quantifies the average performance over all thresholds. It can be\n", + "interpreted probabilistically: $\\mathrm{AUC} =\n", + "\\Pr\\bigl(s(X^+)>s(X^-)\\bigr)$, the probability that a random positive\n", + "instance $X^+$ receives a higher score $s$ than a random negative\n", + "instance $X^-$ . Equivalently, the AUC is the integral under the ROC\n", + "curve:" + ] + }, + { + "cell_type": "markdown", + "id": "5ca722fe", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{AUC} \\;=\\; \\int_{0}^{1} \\mathrm{TPR}(f)\\,df,\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "30080a86", + "metadata": { + "editable": true + }, + "source": [ + "where $f$ ranges over FPR (or fraction of negatives). A model that guesses at random yields a diagonal ROC (AUC=0.5), whereas a perfect model yields AUC=1.0." + ] + }, + { + "cell_type": "markdown", + "id": "9e627156", + "metadata": { + "editable": true + }, + "source": [ + "### Cumulative Gain\n", + "\n", + "The cumulative gain curve (or gains chart) evaluates how many\n", + "positives are captured as one targets an increasing fraction of the\n", + "population, sorted by model confidence. To construct it, sort all\n", + "instances by decreasing predicted probability of the positive class.\n", + "Then, for the top $\\alpha$ fraction of instances, compute the fraction\n", + "of all actual positives that fall in this subset. In formula form, if\n", + "$P$ is the total number of positive instances and $P(\\alpha)$ is the\n", + "number of positives among the top $\\alpha$ of the data, the cumulative\n", + "gain at level $\\alpha$ is" + ] + }, + { + "cell_type": "markdown", + "id": "3e9132ef", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{Gain}(\\alpha) \\;=\\; \\frac{P(\\alpha)}{P}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "75be6f5c", + "metadata": { + "editable": true + }, + "source": [ + "For example, cutting off at the top 10% of predictions yields a gain\n", + "equal to (positives in top 10%) divided by (total positives) .\n", + "Plotting $\\mathrm{Gain}(\\alpha)$ versus $\\alpha$ (often in percent)\n", + "gives the gain curve. The baseline (random) curve is the diagonal\n", + "$\\mathrm{Gain}(\\alpha)=\\alpha$, while an ideal model has a steep climb\n", + "toward 1.\n", + "\n", + "A related measure is the {\\em lift}, often called the gain ratio. It is the ratio of the model’s capture rate to that of random selection. Equivalently," + ] + }, + { + "cell_type": "markdown", + "id": "e5525570", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\mathrm{Lift}(\\alpha) \\;=\\; \\frac{\\mathrm{Gain}(\\alpha)}{\\alpha}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "18ff8dc2", + "metadata": { + "editable": true + }, + "source": [ + "A lift $>1$ indicates better-than-random targeting. In practice, gain\n", + "and lift charts (used e.g.\\ in marketing or imbalanced classification)\n", + "show how many positives can be “gained” by focusing on a fraction of\n", + "the population ." + ] + }, + { + "cell_type": "markdown", + "id": "c3d3fde8", + "metadata": { + "editable": true + }, + "source": [ + "### Other measures: Precision, Recall, and the F$_1$ Measure\n", + "\n", + "Precision and recall (sensitivity) quantify binary classification\n", + "accuracy in terms of positive predictions. They are defined from the\n", + "confusion matrix as:" + ] + }, + { + "cell_type": "markdown", + "id": "f1f14c8e", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\text{Precision} = \\frac{TP}{TP + FP}, \\qquad \\text{Recall} = \\frac{TP}{TP + FN}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "422cc743", + "metadata": { + "editable": true + }, + "source": [ + "Precision is the fraction of predicted positives that are correct, and\n", + "recall is the fraction of actual positives that are correctly\n", + "identified . A high-precision classifier makes few false-positive\n", + "errors, while a high-recall classifier makes few false-negative\n", + "errors.\n", + "\n", + "The F$_1$ score (balanced F-measure) combines precision and recall into a single metric via their harmonic mean. The usual formula is:" + ] + }, + { + "cell_type": "markdown", + "id": "621a2e8b", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "F_1 =2\\frac{\\text{Precision}\\times\\text{Recall}}{\\text{Precision} + \\text{Recall}}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "62eee54a", + "metadata": { + "editable": true + }, + "source": [ + "This can be shown to equal" + ] + }, + { + "cell_type": "markdown", + "id": "7a6a2e7a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{2\\,TP}{2\\,TP + FP + FN}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b96c9ff4", + "metadata": { + "editable": true + }, + "source": [ + "The F$_1$ score ranges from 0 (worst) to 1 (best), and balances the\n", + "trade-off between precision and recall.\n", + "\n", + "For multi-class classification, one computes per-class\n", + "precision/recall/F$_1$ (treating each class as “positive” in a\n", + "one-vs-rest manner) and then averages. Common averaging methods are:\n", + "\n", + "Micro-averaging: Sum all true positives, false positives, and false negatives across classes, then compute precision/recall/F$_1$ from these totals.\n", + "Macro-averaging: Compute the F$1$ score $F{1,i}$ for each class $i$ separately, then take the unweighted mean: $F_{1,\\mathrm{macro}} = \\frac{1}{K}\\sum_{i=1}^K F_{1,i}$ . This treats all classes equally regardless of size.\n", + "Weighted-averaging: Like macro-average, but weight each class’s $F_{1,i}$ by its support $n_i$ (true count): $F_{1,\\mathrm{weighted}} = \\frac{1}{N}\\sum_{i=1}^K n_i F_{1,i}$, where $N=\\sum_i n_i$. This accounts for class imbalance by giving more weight to larger classes .\n", + "\n", + "Each of these averages has different use-cases. Micro-average is\n", + "dominated by common classes, macro-average highlights performance on\n", + "rare classes, and weighted-average is a compromise. These formulas\n", + "and concepts allow rigorous evaluation of classifier performance in\n", + "both binary and multi-class settings." + ] + }, + { + "cell_type": "markdown", + "id": "9274bf3f", + "metadata": { + "editable": true + }, + "source": [ + "## Exercises\n", + "\n", + "Here is a simple code example which uses the Logistic regression machinery from **scikit-learn**.\n", + "At the end it sets up the confusion matrix and the ROC and cumulative gain curves.\n", + "Feel free to use these functionalities (we don't expect you to write your own code for say the confusion matrix)." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "be9ff0b9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "from sklearn.model_selection import train_test_split \n", + "# from sklearn.datasets import fill in the data set\n", + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "# Load the data, fill inn\n", + "mydata.data = ?\n", + "\n", + "X_train, X_test, y_train, y_test = train_test_split(mydata.data,cancer.target,random_state=0)\n", + "print(X_train.shape)\n", + "print(X_test.shape)\n", + "# Logistic Regression\n", + "# define which type of problem, binary or multiclass\n", + "logreg = LogisticRegression(solver='lbfgs')\n", + "logreg.fit(X_train, y_train)\n", + "\n", + "from sklearn.preprocessing import LabelEncoder\n", + "from sklearn.model_selection import cross_validate\n", + "#Cross validation\n", + "accuracy = cross_validate(logreg,X_test,y_test,cv=10)['test_score']\n", + "print(accuracy)\n", + "print(\"Test set accuracy with Logistic Regression: {:.2f}\".format(logreg.score(X_test,y_test)))\n", + "\n", + "import scikitplot as skplt\n", + "y_pred = logreg.predict(X_test)\n", + "skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n", + "plt.show()\n", + "y_probas = logreg.predict_proba(X_test)\n", + "skplt.metrics.plot_roc(y_test, y_probas)\n", + "plt.show()\n", + "skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "51760b3e", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise a)\n", + "\n", + "Convince yourself about the mathematics for the confusion matrix, the ROC and the cumlative gain curves for both a binary and a multiclass classification problem." + ] + }, + { + "cell_type": "markdown", + "id": "c1d42f5f", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise b)\n", + "\n", + "Use a binary classification data available from **scikit-learn**. As an example you can use\n", + "the MNIST data set and just specialize to two numbers. To do so you can use the following code lines" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d20bb8be", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_digits\n", + "digits = load_digits(n_class=2) # Load only two classes, e.g., 0 and 1\n", + "X, y = digits.data, digits.target" + ] + }, + { + "cell_type": "markdown", + "id": "828ea1cd", + "metadata": { + "editable": true + }, + "source": [ + "Alternatively, you can use the _make$\\_$classification_\n", + "functionality. This function generates a random $n$-class classification\n", + "dataset, which can be configured for binary classification by setting\n", + "n_classes=2. You can also control the number of samples, features,\n", + "informative features, redundant features, and more." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d271f0ba", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import make_classification\n", + "X, y = make_classification(n_samples=1000, n_features=20, n_informative=10, n_redundant=5, n_classes=2, random_state=42)" + ] + }, + { + "cell_type": "markdown", + "id": "0068b032", + "metadata": { + "editable": true + }, + "source": [ + "You can use this option for the multiclass case as well, see the next exercise.\n", + "If you prefer to study other binary classification datasets, feel free\n", + "to replace the above suggestions with your own dataset.\n", + "\n", + "Make plots of the confusion matrix, the ROC curve and the cumulative gain curve." + ] + }, + { + "cell_type": "markdown", + "id": "c45f5b41", + "metadata": { + "editable": true + }, + "source": [ + "### Exercise c) week 43\n", + "\n", + "As a multiclass problem, we will use the Iris data set discussed in\n", + "the exercises from weeks 41 and 42. This is a three-class data set and\n", + "you can set it up using **scikit-learn**," + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3b045d56", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_iris\n", + "iris = load_iris()\n", + "X = iris.data # Features\n", + "y = iris.target # Target labels" + ] + }, + { + "cell_type": "markdown", + "id": "14cc859c", + "metadata": { + "editable": true + }, + "source": [ + "Make plots of the confusion matrix, the ROC curve and the cumulative\n", + "gain curve for this (or other) multiclass data set." + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/LectureNotes/_build/html/_sources/week43.ipynb b/doc/LectureNotes/_build/html/_sources/week43.ipynb new file mode 100644 index 000000000..8d5235416 --- /dev/null +++ b/doc/LectureNotes/_build/html/_sources/week43.ipynb @@ -0,0 +1,5948 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b10156d4", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "f85baa2f", + "metadata": { + "editable": true + }, + "source": [ + "# Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations\n", + "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo, Norway\n", + "\n", + "Date: **October 20, 2025**" + ] + }, + { + "cell_type": "markdown", + "id": "543fad4a", + "metadata": { + "editable": true + }, + "source": [ + "## Plans for week 43\n", + "\n", + "**Material for the lecture on Monday October 20, 2025.**\n", + "\n", + "1. Reminder from last week, see also lecture notes from week 42 at as well as those from week 41, see see . \n", + "\n", + "2. Building our own Feed-forward Neural Network.\n", + "\n", + "3. Coding examples using Tensorflow/Keras and Pytorch examples. The Pytorch examples are adapted from Rashcka's text, see chapters 11-13.. \n", + "\n", + "4. Start discussions on how to use neural networks for solving differential equations (ordinary and partial ones). This topic continues next week as well.\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "id": "72acb4e9", + "metadata": { + "editable": true + }, + "source": [ + "## Exercises and lab session week 43\n", + "**Lab sessions on Tuesday and Wednesday.**\n", + "\n", + "1. Work on writing your own neural network code and discussions of project 2. If you didn't get time to do the exercises from the two last weeks, we recommend doing so as these exercises give you the basic elements of a neural network code.\n", + "\n", + "2. The exercises this week are tailored to the optional part of project 2, and deal with studying ways to display results from classification problems" + ] + }, + { + "cell_type": "markdown", + "id": "361768dc", + "metadata": { + "editable": true + }, + "source": [ + "## Using Automatic differentiation\n", + "\n", + "In our discussions of ordinary differential equations and neural network codes\n", + "we will also study the usage of Autograd, see for example in computing gradients for deep learning. For the documentation of Autograd and examples see the Autograd documentation at and the lecture slides from week 41, see ." + ] + }, + { + "cell_type": "markdown", + "id": "3e058671", + "metadata": { + "editable": true + }, + "source": [ + "## Back propagation and automatic differentiation\n", + "\n", + "For more details on the back propagation algorithm and automatic differentiation see\n", + "1. \n", + "\n", + "2. \n", + "\n", + "3. Slides 12-44 at " + ] + }, + { + "cell_type": "markdown", + "id": "8cbbf2bf", + "metadata": { + "editable": true + }, + "source": [ + "## Lecture Monday October 20" + ] + }, + { + "cell_type": "markdown", + "id": "78e2de21", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm and algorithm for a feed forward NN, initalizations\n", + "This is a reminder from last week.\n", + "\n", + "**The architecture (our model).**\n", + "\n", + "1. Set up your inputs and outputs (scalars, vectors, matrices or higher-order arrays)\n", + "\n", + "2. Define the number of hidden layers and hidden nodes\n", + "\n", + "3. Define activation functions for hidden layers and output layers\n", + "\n", + "4. Define optimizer (plan learning rate, momentum, ADAgrad, RMSprop, ADAM etc) and array of initial learning rates\n", + "\n", + "5. Define cost function and possible regularization terms with hyperparameters\n", + "\n", + "6. Initialize weights and biases\n", + "\n", + "7. Fix number of iterations for the feed forward part and back propagation part" + ] + }, + { + "cell_type": "markdown", + "id": "41a3dc23", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm, part 1\n", + "\n", + "Let us write this out in the form of an algorithm.\n", + "\n", + "**First**, we set up the input data $\\boldsymbol{x}$ and the activations\n", + "$\\boldsymbol{z}_1$ of the input layer and compute the activation function and\n", + "the pertinent outputs $\\boldsymbol{a}^1$.\n", + "\n", + "**Secondly**, we perform then the feed forward till we reach the output\n", + "layer and compute all $\\boldsymbol{z}_l$ of the input layer and compute the\n", + "activation function and the pertinent outputs $\\boldsymbol{a}^l$ for\n", + "$l=1,2,3,\\dots,L$.\n", + "\n", + "**Notation**: The first hidden layer has $l=1$ as label and the final output layer has $l=L$." + ] + }, + { + "cell_type": "markdown", + "id": "0e4ac2c0", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the back propagation algorithm, part 2\n", + "\n", + "Thereafter we compute the ouput error $\\boldsymbol{\\delta}^L$ by computing all" + ] + }, + { + "cell_type": "markdown", + "id": "e9fd2f83", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^L = \\sigma'(z_j^L)\\frac{\\partial {\\cal C}}{\\partial (a_j^L)}.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "16e2b900", + "metadata": { + "editable": true + }, + "source": [ + "Then we compute the back propagate error for each $l=L-1,L-2,\\dots,1$ as" + ] + }, + { + "cell_type": "markdown", + "id": "f9f4b9d8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l).\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "01be6441", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the Back propagation algorithm, part 3\n", + "\n", + "Finally, we update the weights and the biases using gradient descent\n", + "for each $l=L-1,L-2,\\dots,1$ (the first hidden layer) and update the weights and biases\n", + "according to the rules" + ] + }, + { + "cell_type": "markdown", + "id": "ce898b85", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "4e2e7314", + "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", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b7114295", + "metadata": { + "editable": true + }, + "source": [ + "with $\\eta$ being the learning rate." + ] + }, + { + "cell_type": "markdown", + "id": "69dfa048", + "metadata": { + "editable": true + }, + "source": [ + "## Updating the gradients\n", + "\n", + "With the back propagate error for each $l=L-1,L-2,\\dots,1$ as" + ] + }, + { + "cell_type": "markdown", + "id": "6efa469c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\delta_j^l = \\sum_k \\delta_k^{l+1}w_{kj}^{l+1}\\sigma'(z_j^l),\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "076e4937", + "metadata": { + "editable": true + }, + "source": [ + "we update the weights and the biases using gradient descent for each $l=L-1,L-2,\\dots,1$ and update the weights and biases according to the rules" + ] + }, + { + "cell_type": "markdown", + "id": "1072f5a1", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "w_{ij}^l\\leftarrow = w_{ij}^l- \\eta \\delta_j^la_i^{l-1},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "f77a7074", + "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", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "f12effab", + "metadata": { + "editable": true + }, + "source": [ + "## Activation functions\n", + "\n", + "A property that characterizes a neural network, other than its\n", + "connectivity, is the choice of activation function(s). The following\n", + "restrictions are imposed on an activation function for an FFNN to\n", + "fulfill the universal approximation theorem\n", + "\n", + " * Non-constant\n", + "\n", + " * Bounded\n", + "\n", + " * Monotonically-increasing\n", + "\n", + " * Continuous" + ] + }, + { + "cell_type": "markdown", + "id": "31eb54b1", + "metadata": { + "editable": true + }, + "source": [ + "### Activation functions, examples\n", + "\n", + "Typical examples are the logistic *Sigmoid*" + ] + }, + { + "cell_type": "markdown", + "id": "7a549168", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\sigma(x) = \\frac{1}{1 + e^{-x}},\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ce35ae73", + "metadata": { + "editable": true + }, + "source": [ + "and the *hyperbolic tangent* function" + ] + }, + { + "cell_type": "markdown", + "id": "d6cdfc89", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\sigma(x) = \\tanh(x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ddd59bb0", + "metadata": { + "editable": true + }, + "source": [ + "## The RELU function family\n", + "\n", + "The ReLU activation function suffers from a problem known as the dying\n", + "ReLUs: during training, some neurons effectively die, meaning they\n", + "stop outputting anything other than 0.\n", + "\n", + "In some cases, you may find that half of your network’s neurons are\n", + "dead, especially if you used a large learning rate. During training,\n", + "if a neuron’s weights get updated such that the weighted sum of the\n", + "neuron’s inputs is negative, it will start outputting 0. When this\n", + "happen, the neuron is unlikely to come back to life since the gradient\n", + "of the ReLU function is 0 when its input is negative." + ] + }, + { + "cell_type": "markdown", + "id": "f2a78e55", + "metadata": { + "editable": true + }, + "source": [ + "## ELU function\n", + "\n", + "To solve this problem, nowadays practitioners use a variant of the\n", + "ReLU function, such as the leaky ReLU discussed above or the so-called\n", + "exponential linear unit (ELU) function" + ] + }, + { + "cell_type": "markdown", + "id": "cde73faf", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "ELU(z) = \\left\\{\\begin{array}{cc} \\alpha\\left( \\exp{(z)}-1\\right) & z < 0,\\\\ z & z \\ge 0.\\end{array}\\right.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "08048672", + "metadata": { + "editable": true + }, + "source": [ + "## Which activation function should we use?\n", + "\n", + "In general it seems that the ELU activation function is better than\n", + "the leaky ReLU function (and its variants), which is better than\n", + "ReLU. ReLU performs better than $\\tanh$ which in turn performs better\n", + "than the logistic function.\n", + "\n", + "If runtime performance is an issue, then you may opt for the leaky\n", + "ReLU function over the ELU function If you don’t want to tweak yet\n", + "another hyperparameter, you may just use the default $\\alpha$ of\n", + "$0.01$ for the leaky ReLU, and $1$ for ELU. If you have spare time and\n", + "computing power, you can use cross-validation or bootstrap to evaluate\n", + "other activation functions." + ] + }, + { + "cell_type": "markdown", + "id": "a7085280", + "metadata": { + "editable": true + }, + "source": [ + "## More on activation functions, output layers\n", + "\n", + "In most cases you can use the ReLU activation function in the hidden\n", + "layers (or one of its variants).\n", + "\n", + "It is a bit faster to compute than other activation functions, and the\n", + "gradient descent optimization does in general not get stuck.\n", + "\n", + "**For the output layer:**\n", + "\n", + "* For classification the softmax activation function is generally a good choice for classification tasks (when the classes are mutually exclusive).\n", + "\n", + "* For regression tasks, you can simply use no activation function at all." + ] + }, + { + "cell_type": "markdown", + "id": "291e4fb2", + "metadata": { + "editable": true + }, + "source": [ + "## Building neural networks in Tensorflow and Keras\n", + "\n", + "Now we want to build on the experience gained from our neural network implementation in NumPy and scikit-learn\n", + "and use it to construct a neural network in Tensorflow. Once we have constructed a neural network in NumPy\n", + "and Tensorflow, building one in Keras is really quite trivial, though the performance may suffer. \n", + "\n", + "In our previous example we used only one hidden layer, and in this we will use two. From this it should be quite\n", + "clear how to build one using an arbitrary number of hidden layers, using data structures such as Python lists or\n", + "NumPy arrays." + ] + }, + { + "cell_type": "markdown", + "id": "a8c5f4c2", + "metadata": { + "editable": true + }, + "source": [ + "## Tensorflow\n", + "\n", + "Tensorflow is an open source library machine learning library\n", + "developed by the Google Brain team for internal use. It was released\n", + "under the Apache 2.0 open source license in November 9, 2015.\n", + "\n", + "Tensorflow is a computational framework that allows you to construct\n", + "machine learning models at different levels of abstraction, from\n", + "high-level, object-oriented APIs like Keras, down to the C++ kernels\n", + "that Tensorflow is built upon. The higher levels of abstraction are\n", + "simpler to use, but less flexible, and our choice of implementation\n", + "should reflect the problems we are trying to solve.\n", + "\n", + "[Tensorflow uses](https://www.tensorflow.org/guide/graphs) so-called graphs to represent your computation\n", + "in terms of the dependencies between individual operations, such that you first build a Tensorflow *graph*\n", + "to represent your model, and then create a Tensorflow *session* to run the graph.\n", + "\n", + "In this guide we will analyze the same data as we did in our NumPy and\n", + "scikit-learn tutorial, gathered from the MNIST database of images. We\n", + "will give an introduction to the lower level Python Application\n", + "Program Interfaces (APIs), and see how we use them to build our graph.\n", + "Then we will build (effectively) the same graph in Keras, to see just\n", + "how simple solving a machine learning problem can be.\n", + "\n", + "To install tensorflow on Unix/Linux systems, use pip as" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "9a0aac03", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "pip3 install tensorflow" + ] + }, + { + "cell_type": "markdown", + "id": "ca0c7865", + "metadata": { + "editable": true + }, + "source": [ + "and/or if you use **anaconda**, just write (or install from the graphical user interface)\n", + "(current release of CPU-only TensorFlow)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d0c581f7", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda create -n tf tensorflow\n", + "conda activate tf" + ] + }, + { + "cell_type": "markdown", + "id": "fe086bc9", + "metadata": { + "editable": true + }, + "source": [ + "To install the current release of GPU TensorFlow" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "f551fad9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda create -n tf-gpu tensorflow-gpu\n", + "conda activate tf-gpu" + ] + }, + { + "cell_type": "markdown", + "id": "58152cef", + "metadata": { + "editable": true + }, + "source": [ + "## Using Keras\n", + "\n", + "Keras is a high level [neural network](https://en.wikipedia.org/wiki/Application_programming_interface)\n", + "that supports Tensorflow, CTNK and Theano as backends. \n", + "If you have Anaconda installed you may run the following command" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "579b6a4a", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "conda install keras" + ] + }, + { + "cell_type": "markdown", + "id": "5da15206", + "metadata": { + "editable": true + }, + "source": [ + "You can look up the [instructions here](https://keras.io/) for more information.\n", + "\n", + "We will to a large extent use **keras** in this course." + ] + }, + { + "cell_type": "markdown", + "id": "cc970d32", + "metadata": { + "editable": true + }, + "source": [ + "## Collect and pre-process data\n", + "\n", + "Let us look again at the MINST data set." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a4f2c8a8", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "%matplotlib inline\n", + "\n", + "# import necessary packages\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import tensorflow as tf\n", + "from sklearn import datasets\n", + "\n", + "\n", + "# ensure the same random numbers appear every time\n", + "np.random.seed(0)\n", + "\n", + "# display images in notebook\n", + "%matplotlib inline\n", + "plt.rcParams['figure.figsize'] = (12,12)\n", + "\n", + "\n", + "# download MNIST dataset\n", + "digits = datasets.load_digits()\n", + "\n", + "# define inputs and labels\n", + "inputs = digits.images\n", + "labels = digits.target\n", + "\n", + "print(\"inputs = (n_inputs, pixel_width, pixel_height) = \" + str(inputs.shape))\n", + "print(\"labels = (n_inputs) = \" + str(labels.shape))\n", + "\n", + "\n", + "# flatten the image\n", + "# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64\n", + "n_inputs = len(inputs)\n", + "inputs = inputs.reshape(n_inputs, -1)\n", + "print(\"X = (n_inputs, n_features) = \" + str(inputs.shape))\n", + "\n", + "\n", + "# choose some random images to display\n", + "indices = np.arange(n_inputs)\n", + "random_indices = np.random.choice(indices, size=5)\n", + "\n", + "for i, image in enumerate(digits.images[random_indices]):\n", + " plt.subplot(1, 5, i+1)\n", + " plt.axis('off')\n", + " plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n", + " plt.title(\"Label: %d\" % digits.target[random_indices[i]])\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "d0c06f34", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from tensorflow.keras.layers import Input\n", + "from tensorflow.keras.models import Sequential #This allows appending layers to existing models\n", + "from tensorflow.keras.layers import Dense #This allows defining the characteristics of a particular layer\n", + "from tensorflow.keras import optimizers #This allows using whichever optimiser we want (sgd,adam,RMSprop)\n", + "from tensorflow.keras import regularizers #This allows using whichever regularizer we want (l1,l2,l1_l2)\n", + "from tensorflow.keras.utils import to_categorical #This allows using categorical cross entropy as the cost function\n", + "\n", + "from sklearn.model_selection import train_test_split\n", + "\n", + "# one-hot representation of labels\n", + "labels = to_categorical(labels)\n", + "\n", + "# split into train and test data\n", + "train_size = 0.8\n", + "test_size = 1 - train_size\n", + "X_train, X_test, Y_train, Y_test = train_test_split(inputs, labels, train_size=train_size,\n", + " test_size=test_size)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "8272ca95", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "epochs = 100\n", + "batch_size = 100\n", + "n_neurons_layer1 = 100\n", + "n_neurons_layer2 = 50\n", + "n_categories = 10\n", + "eta_vals = np.logspace(-5, 1, 7)\n", + "lmbd_vals = np.logspace(-5, 1, 7)\n", + "def create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories, eta, lmbd):\n", + " model = Sequential()\n", + " model.add(Dense(n_neurons_layer1, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))\n", + " model.add(Dense(n_neurons_layer2, activation='sigmoid', kernel_regularizer=regularizers.l2(lmbd)))\n", + " model.add(Dense(n_categories, activation='softmax'))\n", + " \n", + " sgd = optimizers.SGD(learning_rate=eta)\n", + " model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])\n", + " \n", + " return model" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "616613a7", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "DNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)\n", + " \n", + "for i, eta in enumerate(eta_vals):\n", + " for j, lmbd in enumerate(lmbd_vals):\n", + " DNN = create_neural_network_keras(n_neurons_layer1, n_neurons_layer2, n_categories,\n", + " eta=eta, lmbd=lmbd)\n", + " DNN.fit(X_train, Y_train, epochs=epochs, batch_size=batch_size, verbose=0)\n", + " scores = DNN.evaluate(X_test, Y_test)\n", + " \n", + " DNN_keras[i][j] = DNN\n", + " \n", + " print(\"Learning rate = \", eta)\n", + " print(\"Lambda = \", lmbd)\n", + " print(\"Test accuracy: %.3f\" % scores[1])\n", + " print()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f57a7b70", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# optional\n", + "# visual representation of grid search\n", + "# uses seaborn heatmap, could probably do this in matplotlib\n", + "import seaborn as sns\n", + "\n", + "sns.set()\n", + "\n", + "train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", + "test_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))\n", + "\n", + "for i in range(len(eta_vals)):\n", + " for j in range(len(lmbd_vals)):\n", + " DNN = DNN_keras[i][j]\n", + "\n", + " train_accuracy[i][j] = DNN.evaluate(X_train, Y_train)[1]\n", + " test_accuracy[i][j] = DNN.evaluate(X_test, Y_test)[1]\n", + "\n", + " \n", + "fig, ax = plt.subplots(figsize = (10, 10))\n", + "sns.heatmap(train_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", + "ax.set_title(\"Training Accuracy\")\n", + "ax.set_ylabel(\"$\\eta$\")\n", + "ax.set_xlabel(\"$\\lambda$\")\n", + "plt.show()\n", + "\n", + "fig, ax = plt.subplots(figsize = (10, 10))\n", + "sns.heatmap(test_accuracy, annot=True, ax=ax, cmap=\"viridis\")\n", + "ax.set_title(\"Test Accuracy\")\n", + "ax.set_ylabel(\"$\\eta$\")\n", + "ax.set_xlabel(\"$\\lambda$\")\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "a61b50a8", + "metadata": { + "editable": true + }, + "source": [ + "## Using Pytorch with the full MNIST data set" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "d220a7ad", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import torch\n", + "import torch.nn as nn\n", + "import torch.optim as optim\n", + "import torchvision\n", + "import torchvision.transforms as transforms\n", + "\n", + "# Device configuration: use GPU if available\n", + "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", + "\n", + "# MNIST dataset (downloads if not already present)\n", + "transform = transforms.Compose([\n", + " transforms.ToTensor(),\n", + " transforms.Normalize((0.5,), (0.5,)) # normalize to mean=0.5, std=0.5 (approx. [-1,1] pixel range)\n", + "])\n", + "train_dataset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)\n", + "test_dataset = torchvision.datasets.MNIST(root='./data', train=False, download=True, transform=transform)\n", + "\n", + "train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=64, shuffle=True)\n", + "test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=64, shuffle=False)\n", + "\n", + "\n", + "class NeuralNet(nn.Module):\n", + " def __init__(self):\n", + " super(NeuralNet, self).__init__()\n", + " self.fc1 = nn.Linear(28*28, 100) # first hidden layer (784 -> 100)\n", + " self.fc2 = nn.Linear(100, 100) # second hidden layer (100 -> 100)\n", + " self.fc3 = nn.Linear(100, 10) # output layer (100 -> 10 classes)\n", + " def forward(self, x):\n", + " x = x.view(x.size(0), -1) # flatten images into vectors of size 784\n", + " x = torch.relu(self.fc1(x)) # hidden layer 1 + ReLU activation\n", + " x = torch.relu(self.fc2(x)) # hidden layer 2 + ReLU activation\n", + " x = self.fc3(x) # output layer (logits for 10 classes)\n", + " return x\n", + "\n", + "model = NeuralNet().to(device)\n", + "\n", + "\n", + "criterion = nn.CrossEntropyLoss()\n", + "optimizer = optim.SGD(model.parameters(), lr=0.01, weight_decay=1e-4)\n", + "\n", + "num_epochs = 10\n", + "for epoch in range(num_epochs):\n", + " model.train() # set model to training mode\n", + " running_loss = 0.0\n", + " for images, labels in train_loader:\n", + " # Move data to device (GPU if available, else CPU)\n", + " images, labels = images.to(device), labels.to(device)\n", + "\n", + " optimizer.zero_grad() # reset gradients to zero\n", + " outputs = model(images) # forward pass: compute predictions\n", + " loss = criterion(outputs, labels) # compute cross-entropy loss\n", + " loss.backward() # backpropagate to compute gradients\n", + " optimizer.step() # update weights using SGD step \n", + "\n", + " running_loss += loss.item()\n", + " # Compute average loss over all batches in this epoch\n", + " avg_loss = running_loss / len(train_loader)\n", + " print(f\"Epoch {epoch+1}/{num_epochs}, Loss: {avg_loss:.4f}\")\n", + "\n", + "#Evaluation on the Test Set\n", + "\n", + "\n", + "\n", + "model.eval() # set model to evaluation mode \n", + "correct = 0\n", + "total = 0\n", + "with torch.no_grad(): # disable gradient calculation for evaluation \n", + " for images, labels in test_loader:\n", + " images, labels = images.to(device), labels.to(device)\n", + " outputs = model(images)\n", + " _, predicted = torch.max(outputs, dim=1) # class with highest score\n", + " total += labels.size(0)\n", + " correct += (predicted == labels).sum().item()\n", + "\n", + "accuracy = 100 * correct / total\n", + "print(f\"Test Accuracy: {accuracy:.2f}%\")" + ] + }, + { + "cell_type": "markdown", + "id": "d87d7514", + "metadata": { + "editable": true + }, + "source": [ + "## And a similar example using Tensorflow with Keras" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c6df6115", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "\n", + "import tensorflow as tf\n", + "from tensorflow import keras\n", + "from tensorflow.keras import layers, regularizers\n", + "\n", + "# Check for GPU (TensorFlow will use it automatically if available)\n", + "gpus = tf.config.list_physical_devices('GPU')\n", + "print(f\"GPUs available: {gpus}\")\n", + "\n", + "# 1) Load and preprocess MNIST\n", + "(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()\n", + "# Normalize to [0, 1]\n", + "x_train = (x_train.astype(\"float32\") / 255.0)\n", + "x_test = (x_test.astype(\"float32\") / 255.0)\n", + "\n", + "# 2) Build the model: 784 -> 100 -> 100 -> 10\n", + "l2_reg = 1e-4 # L2 regularization strength\n", + "\n", + "model = keras.Sequential([\n", + " layers.Input(shape=(28, 28)),\n", + " layers.Flatten(),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(100, activation=\"relu\",\n", + " kernel_regularizer=regularizers.l2(l2_reg)),\n", + " layers.Dense(10, activation=\"softmax\") # output probabilities for 10 classes\n", + "])\n", + "\n", + "# 3) Compile with SGD + weight decay via L2 regularizers\n", + "model.compile(\n", + " optimizer=keras.optimizers.SGD(learning_rate=0.01),\n", + " loss=\"sparse_categorical_crossentropy\",\n", + " metrics=[\"accuracy\"],\n", + ")\n", + "\n", + "model.summary()\n", + "\n", + "# 4) Train\n", + "history = model.fit(\n", + " x_train, y_train,\n", + " epochs=10,\n", + " batch_size=64,\n", + " validation_split=0.1, # optional: monitor validation during training\n", + " verbose=1\n", + ")\n", + "\n", + "# 5) Evaluate on test set\n", + "test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)\n", + "print(f\"Test accuracy: {test_acc:.4f}, Test loss: {test_loss:.4f}\")" + ] + }, + { + "cell_type": "markdown", + "id": "5fd4d319", + "metadata": { + "editable": true + }, + "source": [ + "## Building our own neural network code\n", + "\n", + "Here we present a flexible object oriented codebase\n", + "for a feed forward neural network, along with a demonstration of how\n", + "to use it. Before we get into the details of the neural network, we\n", + "will first present some implementations of various schedulers, cost\n", + "functions and activation functions that can be used together with the\n", + "neural network.\n", + "\n", + "The codes here were developed by Eric Reber and Gregor Kajda during spring 2023." + ] + }, + { + "cell_type": "markdown", + "id": "64134feb", + "metadata": { + "editable": true + }, + "source": [ + "### Learning rate methods\n", + "\n", + "The code below shows object oriented implementations of the Constant,\n", + "Momentum, Adagrad, AdagradMomentum, RMS prop and Adam schedulers. All\n", + "of the classes belong to the shared abstract Scheduler class, and\n", + "share the update_change() and reset() methods allowing for any of the\n", + "schedulers to be seamlessly used during the training stage, as will\n", + "later be shown in the fit() method of the neural\n", + "network. Update_change() only has one parameter, the gradient\n", + "($δ^l_ja^{l−1}_k$), and returns the change which will be subtracted\n", + "from the weights. The reset() function takes no parameters, and resets\n", + "the desired variables. For Constant and Momentum, reset does nothing." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "643f7a82", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "\n", + "class Scheduler:\n", + " \"\"\"\n", + " Abstract class for Schedulers\n", + " \"\"\"\n", + "\n", + " def __init__(self, eta):\n", + " self.eta = eta\n", + "\n", + " # should be overwritten\n", + " def update_change(self, gradient):\n", + " raise NotImplementedError\n", + "\n", + " # overwritten if needed\n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Constant(Scheduler):\n", + " def __init__(self, eta):\n", + " super().__init__(eta)\n", + "\n", + " def update_change(self, gradient):\n", + " return self.eta * gradient\n", + " \n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Momentum(Scheduler):\n", + " def __init__(self, eta: float, momentum: float):\n", + " super().__init__(eta)\n", + " self.momentum = momentum\n", + " self.change = 0\n", + "\n", + " def update_change(self, gradient):\n", + " self.change = self.momentum * self.change + self.eta * gradient\n", + " return self.change\n", + "\n", + " def reset(self):\n", + " pass\n", + "\n", + "\n", + "class Adagrad(Scheduler):\n", + " def __init__(self, eta):\n", + " super().__init__(eta)\n", + " self.G_t = None\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " if self.G_t is None:\n", + " self.G_t = np.zeros((gradient.shape[0], gradient.shape[0]))\n", + "\n", + " self.G_t += gradient @ gradient.T\n", + "\n", + " G_t_inverse = 1 / (\n", + " delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1)))\n", + " )\n", + " return self.eta * gradient * G_t_inverse\n", + "\n", + " def reset(self):\n", + " self.G_t = None\n", + "\n", + "\n", + "class AdagradMomentum(Scheduler):\n", + " def __init__(self, eta, momentum):\n", + " super().__init__(eta)\n", + " self.G_t = None\n", + " self.momentum = momentum\n", + " self.change = 0\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " if self.G_t is None:\n", + " self.G_t = np.zeros((gradient.shape[0], gradient.shape[0]))\n", + "\n", + " self.G_t += gradient @ gradient.T\n", + "\n", + " G_t_inverse = 1 / (\n", + " delta + np.sqrt(np.reshape(np.diagonal(self.G_t), (self.G_t.shape[0], 1)))\n", + " )\n", + " self.change = self.change * self.momentum + self.eta * gradient * G_t_inverse\n", + " return self.change\n", + "\n", + " def reset(self):\n", + " self.G_t = None\n", + "\n", + "\n", + "class RMS_prop(Scheduler):\n", + " def __init__(self, eta, rho):\n", + " super().__init__(eta)\n", + " self.rho = rho\n", + " self.second = 0.0\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + " self.second = self.rho * self.second + (1 - self.rho) * gradient * gradient\n", + " return self.eta * gradient / (np.sqrt(self.second + delta))\n", + "\n", + " def reset(self):\n", + " self.second = 0.0\n", + "\n", + "\n", + "class Adam(Scheduler):\n", + " def __init__(self, eta, rho, rho2):\n", + " super().__init__(eta)\n", + " self.rho = rho\n", + " self.rho2 = rho2\n", + " self.moment = 0\n", + " self.second = 0\n", + " self.n_epochs = 1\n", + "\n", + " def update_change(self, gradient):\n", + " delta = 1e-8 # avoid division ny zero\n", + "\n", + " self.moment = self.rho * self.moment + (1 - self.rho) * gradient\n", + " self.second = self.rho2 * self.second + (1 - self.rho2) * gradient * gradient\n", + "\n", + " moment_corrected = self.moment / (1 - self.rho**self.n_epochs)\n", + " second_corrected = self.second / (1 - self.rho2**self.n_epochs)\n", + "\n", + " return self.eta * moment_corrected / (np.sqrt(second_corrected + delta))\n", + "\n", + " def reset(self):\n", + " self.n_epochs += 1\n", + " self.moment = 0\n", + " self.second = 0" + ] + }, + { + "cell_type": "markdown", + "id": "dfa32b7e", + "metadata": { + "editable": true + }, + "source": [ + "### Usage of the above learning rate schedulers\n", + "\n", + "To initalize a scheduler, simply create the object and pass in the\n", + "necessary parameters such as the learning rate and the momentum as\n", + "shown below. As the Scheduler class is an abstract class it should not\n", + "called directly, and will raise an error upon usage." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "4b88b24e", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "momentum_scheduler = Momentum(eta=1e-3, momentum=0.9)\n", + "adam_scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999)" + ] + }, + { + "cell_type": "markdown", + "id": "2eea0e52", + "metadata": { + "editable": true + }, + "source": [ + "Here is a small example for how a segment of code using schedulers\n", + "could look. Switching out the schedulers is simple." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "090bee3c", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "weights = np.ones((3,3))\n", + "print(f\"Before scheduler:\\n{weights=}\")\n", + "\n", + "epochs = 10\n", + "for e in range(epochs):\n", + " gradient = np.random.rand(3, 3)\n", + " change = adam_scheduler.update_change(gradient)\n", + " weights = weights - change\n", + " adam_scheduler.reset()\n", + "\n", + "print(f\"\\nAfter scheduler:\\n{weights=}\")" + ] + }, + { + "cell_type": "markdown", + "id": "e0eee286", + "metadata": { + "editable": true + }, + "source": [ + "### Cost functions\n", + "\n", + "Here we discuss cost functions that can be used when creating the\n", + "neural network. Every cost function takes the target vector as its\n", + "parameter, and returns a function valued only at $x$ such that it may\n", + "easily be differentiated." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "191224bb", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "\n", + "def CostOLS(target):\n", + " \n", + " def func(X):\n", + " return (1.0 / target.shape[0]) * np.sum((target - X) ** 2)\n", + "\n", + " return func\n", + "\n", + "\n", + "def CostLogReg(target):\n", + "\n", + " def func(X):\n", + " \n", + " return -(1.0 / target.shape[0]) * np.sum(\n", + " (target * np.log(X + 10e-10)) + ((1 - target) * np.log(1 - X + 10e-10))\n", + " )\n", + "\n", + " return func\n", + "\n", + "\n", + "def CostCrossEntropy(target):\n", + " \n", + " def func(X):\n", + " return -(1.0 / target.size) * np.sum(target * np.log(X + 10e-10))\n", + "\n", + " return func" + ] + }, + { + "cell_type": "markdown", + "id": "7f4a0238", + "metadata": { + "editable": true + }, + "source": [ + "Below we give a short example of how these cost function may be used\n", + "to obtain results if you wish to test them out on your own using\n", + "AutoGrad's automatics differentiation." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "d822b656", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from autograd import grad\n", + "\n", + "target = np.array([[1, 2, 3]]).T\n", + "a = np.array([[4, 5, 6]]).T\n", + "\n", + "cost_func = CostCrossEntropy\n", + "cost_func_derivative = grad(cost_func(target))\n", + "\n", + "valued_at_a = cost_func_derivative(a)\n", + "print(f\"Derivative of cost function {cost_func.__name__} valued at a:\\n{valued_at_a}\")" + ] + }, + { + "cell_type": "markdown", + "id": "7ff32a3b", + "metadata": { + "editable": true + }, + "source": [ + "### Activation functions\n", + "\n", + "Finally, before we look at the neural network, we will look at the\n", + "activation functions which can be specified between the hidden layers\n", + "and as the output function. Each function can be valued for any given\n", + "vector or matrix X, and can be differentiated via derivate()." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "90045474", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import elementwise_grad\n", + "\n", + "def identity(X):\n", + " return X\n", + "\n", + "\n", + "def sigmoid(X):\n", + " try:\n", + " return 1.0 / (1 + np.exp(-X))\n", + " except FloatingPointError:\n", + " return np.where(X > np.zeros(X.shape), np.ones(X.shape), np.zeros(X.shape))\n", + "\n", + "\n", + "def softmax(X):\n", + " X = X - np.max(X, axis=-1, keepdims=True)\n", + " delta = 10e-10\n", + " return np.exp(X) / (np.sum(np.exp(X), axis=-1, keepdims=True) + delta)\n", + "\n", + "\n", + "def RELU(X):\n", + " return np.where(X > np.zeros(X.shape), X, np.zeros(X.shape))\n", + "\n", + "\n", + "def LRELU(X):\n", + " delta = 10e-4\n", + " return np.where(X > np.zeros(X.shape), X, delta * X)\n", + "\n", + "\n", + "def derivate(func):\n", + " if func.__name__ == \"RELU\":\n", + "\n", + " def func(X):\n", + " return np.where(X > 0, 1, 0)\n", + "\n", + " return func\n", + "\n", + " elif func.__name__ == \"LRELU\":\n", + "\n", + " def func(X):\n", + " delta = 10e-4\n", + " return np.where(X > 0, 1, delta)\n", + "\n", + " return func\n", + "\n", + " else:\n", + " return elementwise_grad(func)" + ] + }, + { + "cell_type": "markdown", + "id": "eec681dc", + "metadata": { + "editable": true + }, + "source": [ + "Below follows a short demonstration of how to use an activation\n", + "function. The derivative of the activation function will be important\n", + "when calculating the output delta term during backpropagation. Note\n", + "that derivate() can also be used for cost functions for a more\n", + "generalized approach." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "a36d4506", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "z = np.array([[4, 5, 6]]).T\n", + "print(f\"Input to activation function:\\n{z}\")\n", + "\n", + "act_func = sigmoid\n", + "a = act_func(z)\n", + "print(f\"\\nOutput from {act_func.__name__} activation function:\\n{a}\")\n", + "\n", + "act_func_derivative = derivate(act_func)\n", + "valued_at_z = act_func_derivative(a)\n", + "print(f\"\\nDerivative of {act_func.__name__} activation function valued at z:\\n{valued_at_z}\")" + ] + }, + { + "cell_type": "markdown", + "id": "d2358581", + "metadata": { + "editable": true + }, + "source": [ + "### The Neural Network\n", + "\n", + "Now that we have gotten a good understanding of the implementation of\n", + "some important components, we can take a look at an object oriented\n", + "implementation of a feed forward neural network. The feed forward\n", + "neural network has been implemented as a class named FFNN, which can\n", + "be initiated as a regressor or classifier dependant on the choice of\n", + "cost function. The FFNN can have any number of input nodes, hidden\n", + "layers with any amount of hidden nodes, and any amount of output nodes\n", + "meaning it can perform multiclass classification as well as binary\n", + "classification and regression problems. Although there is a lot of\n", + "code present, it makes for an easy to use and generalizeable interface\n", + "for creating many types of neural networks as will be demonstrated\n", + "below." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "9dd0b112", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import math\n", + "import autograd.numpy as np\n", + "import sys\n", + "import warnings\n", + "from autograd import grad, elementwise_grad\n", + "from random import random, seed\n", + "from copy import deepcopy, copy\n", + "from typing import Tuple, Callable\n", + "from sklearn.utils import resample\n", + "\n", + "warnings.simplefilter(\"error\")\n", + "\n", + "\n", + "class FFNN:\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Feed Forward Neural Network with interface enabling flexible design of a\n", + " nerual networks architecture and the specification of activation function\n", + " in the hidden layers and output layer respectively. This model can be used\n", + " for both regression and classification problems, depending on the output function.\n", + "\n", + " Attributes:\n", + " ------------\n", + " I dimensions (tuple[int]): A list of positive integers, which specifies the\n", + " number of nodes in each of the networks layers. The first integer in the array\n", + " defines the number of nodes in the input layer, the second integer defines number\n", + " of nodes in the first hidden layer and so on until the last number, which\n", + " specifies the number of nodes in the output layer.\n", + " II hidden_func (Callable): The activation function for the hidden layers\n", + " III output_func (Callable): The activation function for the output layer\n", + " IV cost_func (Callable): Our cost function\n", + " V seed (int): Sets random seed, makes results reproducible\n", + " \"\"\"\n", + "\n", + " def __init__(\n", + " self,\n", + " dimensions: tuple[int],\n", + " hidden_func: Callable = sigmoid,\n", + " output_func: Callable = lambda x: x,\n", + " cost_func: Callable = CostOLS,\n", + " seed: int = None,\n", + " ):\n", + " self.dimensions = dimensions\n", + " self.hidden_func = hidden_func\n", + " self.output_func = output_func\n", + " self.cost_func = cost_func\n", + " self.seed = seed\n", + " self.weights = list()\n", + " self.schedulers_weight = list()\n", + " self.schedulers_bias = list()\n", + " self.a_matrices = list()\n", + " self.z_matrices = list()\n", + " self.classification = None\n", + "\n", + " self.reset_weights()\n", + " self._set_classification()\n", + "\n", + " def fit(\n", + " self,\n", + " X: np.ndarray,\n", + " t: np.ndarray,\n", + " scheduler: Scheduler,\n", + " batches: int = 1,\n", + " epochs: int = 100,\n", + " lam: float = 0,\n", + " X_val: np.ndarray = None,\n", + " t_val: np.ndarray = None,\n", + " ):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " This function performs the training the neural network by performing the feedforward and backpropagation\n", + " algorithm to update the networks weights.\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray) : training data\n", + " II t (np.ndarray) : target data\n", + " III scheduler (Scheduler) : specified scheduler (algorithm for optimization of gradient descent)\n", + " IV scheduler_args (list[int]) : list of all arguments necessary for scheduler\n", + "\n", + " Optional Parameters:\n", + " ------------\n", + " V batches (int) : number of batches the datasets are split into, default equal to 1\n", + " VI epochs (int) : number of iterations used to train the network, default equal to 100\n", + " VII lam (float) : regularization hyperparameter lambda\n", + " VIII X_val (np.ndarray) : validation set\n", + " IX t_val (np.ndarray) : validation target set\n", + "\n", + " Returns:\n", + " ------------\n", + " I scores (dict) : A dictionary containing the performance metrics of the model.\n", + " The number of the metrics depends on the parameters passed to the fit-function.\n", + "\n", + " \"\"\"\n", + "\n", + " # setup \n", + " if self.seed is not None:\n", + " np.random.seed(self.seed)\n", + "\n", + " val_set = False\n", + " if X_val is not None and t_val is not None:\n", + " val_set = True\n", + "\n", + " # creating arrays for score metrics\n", + " train_errors = np.empty(epochs)\n", + " train_errors.fill(np.nan)\n", + " val_errors = np.empty(epochs)\n", + " val_errors.fill(np.nan)\n", + "\n", + " train_accs = np.empty(epochs)\n", + " train_accs.fill(np.nan)\n", + " val_accs = np.empty(epochs)\n", + " val_accs.fill(np.nan)\n", + "\n", + " self.schedulers_weight = list()\n", + " self.schedulers_bias = list()\n", + "\n", + " batch_size = X.shape[0] // batches\n", + "\n", + " X, t = resample(X, t)\n", + "\n", + " # this function returns a function valued only at X\n", + " cost_function_train = self.cost_func(t)\n", + " if val_set:\n", + " cost_function_val = self.cost_func(t_val)\n", + "\n", + " # create schedulers for each weight matrix\n", + " for i in range(len(self.weights)):\n", + " self.schedulers_weight.append(copy(scheduler))\n", + " self.schedulers_bias.append(copy(scheduler))\n", + "\n", + " print(f\"{scheduler.__class__.__name__}: Eta={scheduler.eta}, Lambda={lam}\")\n", + "\n", + " try:\n", + " for e in range(epochs):\n", + " for i in range(batches):\n", + " # allows for minibatch gradient descent\n", + " if i == batches - 1:\n", + " # If the for loop has reached the last batch, take all thats left\n", + " X_batch = X[i * batch_size :, :]\n", + " t_batch = t[i * batch_size :, :]\n", + " else:\n", + " X_batch = X[i * batch_size : (i + 1) * batch_size, :]\n", + " t_batch = t[i * batch_size : (i + 1) * batch_size, :]\n", + "\n", + " self._feedforward(X_batch)\n", + " self._backpropagate(X_batch, t_batch, lam)\n", + "\n", + " # reset schedulers for each epoch (some schedulers pass in this call)\n", + " for scheduler in self.schedulers_weight:\n", + " scheduler.reset()\n", + "\n", + " for scheduler in self.schedulers_bias:\n", + " scheduler.reset()\n", + "\n", + " # computing performance metrics\n", + " pred_train = self.predict(X)\n", + " train_error = cost_function_train(pred_train)\n", + "\n", + " train_errors[e] = train_error\n", + " if val_set:\n", + " \n", + " pred_val = self.predict(X_val)\n", + " val_error = cost_function_val(pred_val)\n", + " val_errors[e] = val_error\n", + "\n", + " if self.classification:\n", + " train_acc = self._accuracy(self.predict(X), t)\n", + " train_accs[e] = train_acc\n", + " if val_set:\n", + " val_acc = self._accuracy(pred_val, t_val)\n", + " val_accs[e] = val_acc\n", + "\n", + " # printing progress bar\n", + " progression = e / epochs\n", + " print_length = self._progress_bar(\n", + " progression,\n", + " train_error=train_errors[e],\n", + " train_acc=train_accs[e],\n", + " val_error=val_errors[e],\n", + " val_acc=val_accs[e],\n", + " )\n", + " except KeyboardInterrupt:\n", + " # allows for stopping training at any point and seeing the result\n", + " pass\n", + "\n", + " # visualization of training progression (similiar to tensorflow progression bar)\n", + " sys.stdout.write(\"\\r\" + \" \" * print_length)\n", + " sys.stdout.flush()\n", + " self._progress_bar(\n", + " 1,\n", + " train_error=train_errors[e],\n", + " train_acc=train_accs[e],\n", + " val_error=val_errors[e],\n", + " val_acc=val_accs[e],\n", + " )\n", + " sys.stdout.write(\"\")\n", + "\n", + " # return performance metrics for the entire run\n", + " scores = dict()\n", + "\n", + " scores[\"train_errors\"] = train_errors\n", + "\n", + " if val_set:\n", + " scores[\"val_errors\"] = val_errors\n", + "\n", + " if self.classification:\n", + " scores[\"train_accs\"] = train_accs\n", + "\n", + " if val_set:\n", + " scores[\"val_accs\"] = val_accs\n", + "\n", + " return scores\n", + "\n", + " def predict(self, X: np.ndarray, *, threshold=0.5):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Performs prediction after training of the network has been finished.\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each\n", + "\n", + " Optional Parameters:\n", + " ------------\n", + " II threshold (float) : sets minimal value for a prediction to be predicted as the positive class\n", + " in classification problems\n", + "\n", + " Returns:\n", + " ------------\n", + " I z (np.ndarray): A prediction vector (row) for each row in our design matrix\n", + " This vector is thresholded if regression=False, meaning that classification results\n", + " in a vector of 1s and 0s, while regressions in an array of decimal numbers\n", + "\n", + " \"\"\"\n", + "\n", + " predict = self._feedforward(X)\n", + "\n", + " if self.classification:\n", + " return np.where(predict > threshold, 1, 0)\n", + " else:\n", + " return predict\n", + "\n", + " def reset_weights(self):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Resets/Reinitializes the weights in order to train the network for a new problem.\n", + "\n", + " \"\"\"\n", + " if self.seed is not None:\n", + " np.random.seed(self.seed)\n", + "\n", + " self.weights = list()\n", + " for i in range(len(self.dimensions) - 1):\n", + " weight_array = np.random.randn(\n", + " self.dimensions[i] + 1, self.dimensions[i + 1]\n", + " )\n", + " weight_array[0, :] = np.random.randn(self.dimensions[i + 1]) * 0.01\n", + "\n", + " self.weights.append(weight_array)\n", + "\n", + " def _feedforward(self, X: np.ndarray):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Calculates the activation of each layer starting at the input and ending at the output.\n", + " Each following activation is calculated from a weighted sum of each of the preceeding\n", + " activations (except in the case of the input layer).\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each\n", + "\n", + " Returns:\n", + " ------------\n", + " I z (np.ndarray): A prediction vector (row) for each row in our design matrix\n", + " \"\"\"\n", + "\n", + " # reset matrices\n", + " self.a_matrices = list()\n", + " self.z_matrices = list()\n", + "\n", + " # if X is just a vector, make it into a matrix\n", + " if len(X.shape) == 1:\n", + " X = X.reshape((1, X.shape[0]))\n", + "\n", + " # Add a coloumn of zeros as the first coloumn of the design matrix, in order\n", + " # to add bias to our data\n", + " bias = np.ones((X.shape[0], 1)) * 0.01\n", + " X = np.hstack([bias, X])\n", + "\n", + " # a^0, the nodes in the input layer (one a^0 for each row in X - where the\n", + " # exponent indicates layer number).\n", + " a = X\n", + " self.a_matrices.append(a)\n", + " self.z_matrices.append(a)\n", + "\n", + " # The feed forward algorithm\n", + " for i in range(len(self.weights)):\n", + " if i < len(self.weights) - 1:\n", + " z = a @ self.weights[i]\n", + " self.z_matrices.append(z)\n", + " a = self.hidden_func(z)\n", + " # bias column again added to the data here\n", + " bias = np.ones((a.shape[0], 1)) * 0.01\n", + " a = np.hstack([bias, a])\n", + " self.a_matrices.append(a)\n", + " else:\n", + " try:\n", + " # a^L, the nodes in our output layers\n", + " z = a @ self.weights[i]\n", + " a = self.output_func(z)\n", + " self.a_matrices.append(a)\n", + " self.z_matrices.append(z)\n", + " except Exception as OverflowError:\n", + " print(\n", + " \"OverflowError in fit() in FFNN\\nHOW TO DEBUG ERROR: Consider lowering your learning rate or scheduler specific parameters such as momentum, or check if your input values need scaling\"\n", + " )\n", + "\n", + " # this will be a^L\n", + " return a\n", + "\n", + " def _backpropagate(self, X, t, lam):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Performs the backpropagation algorithm. In other words, this method\n", + " calculates the gradient of all the layers starting at the\n", + " output layer, and moving from right to left accumulates the gradient until\n", + " the input layer is reached. Each layers respective weights are updated while\n", + " the algorithm propagates backwards from the output layer (auto-differentation in reverse mode).\n", + "\n", + " Parameters:\n", + " ------------\n", + " I X (np.ndarray): The design matrix, with n rows of p features each.\n", + " II t (np.ndarray): The target vector, with n rows of p targets.\n", + " III lam (float32): regularization parameter used to punish the weights in case of overfitting\n", + "\n", + " Returns:\n", + " ------------\n", + " No return value.\n", + "\n", + " \"\"\"\n", + " out_derivative = derivate(self.output_func)\n", + " hidden_derivative = derivate(self.hidden_func)\n", + "\n", + " for i in range(len(self.weights) - 1, -1, -1):\n", + " # delta terms for output\n", + " if i == len(self.weights) - 1:\n", + " # for multi-class classification\n", + " if (\n", + " self.output_func.__name__ == \"softmax\"\n", + " ):\n", + " delta_matrix = self.a_matrices[i + 1] - t\n", + " # for single class classification\n", + " else:\n", + " cost_func_derivative = grad(self.cost_func(t))\n", + " delta_matrix = out_derivative(\n", + " self.z_matrices[i + 1]\n", + " ) * cost_func_derivative(self.a_matrices[i + 1])\n", + "\n", + " # delta terms for hidden layer\n", + " else:\n", + " delta_matrix = (\n", + " self.weights[i + 1][1:, :] @ delta_matrix.T\n", + " ).T * hidden_derivative(self.z_matrices[i + 1])\n", + "\n", + " # calculate gradient\n", + " gradient_weights = self.a_matrices[i][:, 1:].T @ delta_matrix\n", + " gradient_bias = np.sum(delta_matrix, axis=0).reshape(\n", + " 1, delta_matrix.shape[1]\n", + " )\n", + "\n", + " # regularization term\n", + " gradient_weights += self.weights[i][1:, :] * lam\n", + "\n", + " # use scheduler\n", + " update_matrix = np.vstack(\n", + " [\n", + " self.schedulers_bias[i].update_change(gradient_bias),\n", + " self.schedulers_weight[i].update_change(gradient_weights),\n", + " ]\n", + " )\n", + "\n", + " # update weights and bias\n", + " self.weights[i] -= update_matrix\n", + "\n", + " def _accuracy(self, prediction: np.ndarray, target: np.ndarray):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Calculates accuracy of given prediction to target\n", + "\n", + " Parameters:\n", + " ------------\n", + " I prediction (np.ndarray): vector of predicitons output network\n", + " (1s and 0s in case of classification, and real numbers in case of regression)\n", + " II target (np.ndarray): vector of true values (What the network ideally should predict)\n", + "\n", + " Returns:\n", + " ------------\n", + " A floating point number representing the percentage of correctly classified instances.\n", + " \"\"\"\n", + " assert prediction.size == target.size\n", + " return np.average((target == prediction))\n", + " def _set_classification(self):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Decides if FFNN acts as classifier (True) og regressor (False),\n", + " sets self.classification during init()\n", + " \"\"\"\n", + " self.classification = False\n", + " if (\n", + " self.cost_func.__name__ == \"CostLogReg\"\n", + " or self.cost_func.__name__ == \"CostCrossEntropy\"\n", + " ):\n", + " self.classification = True\n", + "\n", + " def _progress_bar(self, progression, **kwargs):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Displays progress of training\n", + " \"\"\"\n", + " print_length = 40\n", + " num_equals = int(progression * print_length)\n", + " num_not = print_length - num_equals\n", + " arrow = \">\" if num_equals > 0 else \"\"\n", + " bar = \"[\" + \"=\" * (num_equals - 1) + arrow + \"-\" * num_not + \"]\"\n", + " perc_print = self._format(progression * 100, decimals=5)\n", + " line = f\" {bar} {perc_print}% \"\n", + "\n", + " for key in kwargs:\n", + " if not np.isnan(kwargs[key]):\n", + " value = self._format(kwargs[key], decimals=4)\n", + " line += f\"| {key}: {value} \"\n", + " sys.stdout.write(\"\\r\" + line)\n", + " sys.stdout.flush()\n", + " return len(line)\n", + "\n", + " def _format(self, value, decimals=4):\n", + " \"\"\"\n", + " Description:\n", + " ------------\n", + " Formats decimal numbers for progress bar\n", + " \"\"\"\n", + " if value > 0:\n", + " v = value\n", + " elif value < 0:\n", + " v = -10 * value\n", + " else:\n", + " v = 1\n", + " n = 1 + math.floor(math.log10(v))\n", + " if n >= decimals - 1:\n", + " return str(round(value))\n", + " return f\"{value:.{decimals-n-1}f}\"" + ] + }, + { + "cell_type": "markdown", + "id": "b5aaa66b", + "metadata": { + "editable": true + }, + "source": [ + "Before we make a model, we will quickly generate a dataset we can use\n", + "for our linear regression problem as shown below" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "35f13536", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from sklearn.model_selection import train_test_split\n", + "\n", + "def SkrankeFunction(x, y):\n", + " return np.ravel(0 + 1*x + 2*y + 3*x**2 + 4*x*y + 5*y**2)\n", + "\n", + "def create_X(x, y, n):\n", + " if len(x.shape) > 1:\n", + " x = np.ravel(x)\n", + " y = np.ravel(y)\n", + "\n", + " N = len(x)\n", + " l = int((n + 1) * (n + 2) / 2) # Number of elements in beta\n", + " X = np.ones((N, l))\n", + "\n", + " for i in range(1, n + 1):\n", + " q = int((i) * (i + 1) / 2)\n", + " for k in range(i + 1):\n", + " X[:, q + k] = (x ** (i - k)) * (y**k)\n", + "\n", + " return X\n", + "\n", + "step=0.5\n", + "x = np.arange(0, 1, step)\n", + "y = np.arange(0, 1, step)\n", + "x, y = np.meshgrid(x, y)\n", + "target = SkrankeFunction(x, y)\n", + "target = target.reshape(target.shape[0], 1)\n", + "\n", + "poly_degree=3\n", + "X = create_X(x, y, poly_degree)\n", + "\n", + "X_train, X_test, t_train, t_test = train_test_split(X, target)" + ] + }, + { + "cell_type": "markdown", + "id": "12780998", + "metadata": { + "editable": true + }, + "source": [ + "Now that we have our dataset ready for the regression, we can create\n", + "our regressor. Note that with the seed parameter, we can make sure our\n", + "results stay the same every time we run the neural network. For\n", + "inititialization, we simply specify the dimensions (we wish the amount\n", + "of input nodes to be equal to the datapoints, and the output to\n", + "predict one value)." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "3de4263c", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "output_nodes = 1\n", + "\n", + "linear_regression = FFNN((input_nodes, output_nodes), output_func=identity, cost_func=CostOLS, seed=2023)" + ] + }, + { + "cell_type": "markdown", + "id": "e3ca1fb5", + "metadata": { + "editable": true + }, + "source": [ + "We then fit our model with our training data using the scheduler of our choice." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "714229a9", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Constant(eta=1e-3)\n", + "scores = linear_regression.fit(X_train, t_train, scheduler)" + ] + }, + { + "cell_type": "markdown", + "id": "2240c6b8", + "metadata": { + "editable": true + }, + "source": [ + "Due to the progress bar we can see the MSE (train_error) throughout\n", + "the FFNN's training. Note that the fit() function has some optional\n", + "parameters with defualt arguments. For example, the regularization\n", + "hyperparameter can be left ignored if not needed, and equally the FFNN\n", + "will by default run for 100 epochs. These can easily be changed, such\n", + "as for example:" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "96f9f1ab", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "linear_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scores = linear_regression.fit(X_train, t_train, scheduler, lam=1e-4, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "21af3f64", + "metadata": { + "editable": true + }, + "source": [ + "We see that given more epochs to train on, the regressor reaches a lower MSE.\n", + "\n", + "Let us then switch to a binary classification. We use a binary\n", + "classification dataset, and follow a similar setup to the regression\n", + "case." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "98f0055d", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_breast_cancer\n", + "from sklearn.preprocessing import MinMaxScaler\n", + "\n", + "wisconsin = load_breast_cancer()\n", + "X = wisconsin.data\n", + "target = wisconsin.target\n", + "target = target.reshape(target.shape[0], 1)\n", + "\n", + "X_train, X_val, t_train, t_val = train_test_split(X, target)\n", + "\n", + "scaler = MinMaxScaler()\n", + "scaler.fit(X_train)\n", + "X_train = scaler.transform(X_train)\n", + "X_val = scaler.transform(X_val)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "fbd2675f", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "output_nodes = 1\n", + "\n", + "logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023)" + ] + }, + { + "cell_type": "markdown", + "id": "64ed3461", + "metadata": { + "editable": true + }, + "source": [ + "We will now make use of our validation data by passing it into our fit function as a keyword argument" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "1cdc9d23", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-3, rho=0.9, rho2=0.999)\n", + "scores = logistic_regression.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val)" + ] + }, + { + "cell_type": "markdown", + "id": "13e2f881", + "metadata": { + "editable": true + }, + "source": [ + "Finally, we will create a neural network with 2 hidden layers with activation functions." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "c28f2181", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "input_nodes = X_train.shape[1]\n", + "hidden_nodes1 = 100\n", + "hidden_nodes2 = 30\n", + "output_nodes = 1\n", + "\n", + "dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes)\n", + "\n", + "neural_network = FFNN(dims, hidden_func=RELU, output_func=sigmoid, cost_func=CostLogReg, seed=2023)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "3150b724", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "neural_network.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999)\n", + "scores = neural_network.fit(X_train, t_train, scheduler, epochs=1000, X_val=X_val, t_val=t_val)" + ] + }, + { + "cell_type": "markdown", + "id": "17aebab2", + "metadata": { + "editable": true + }, + "source": [ + "### Multiclass classification\n", + "\n", + "Finally, we will demonstrate the use case of multiclass classification\n", + "using our FFNN with the famous MNIST dataset, which contain images of\n", + "digits between the range of 0 to 9." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "997c5001", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_digits\n", + "\n", + "def onehot(target: np.ndarray):\n", + " onehot = np.zeros((target.size, target.max() + 1))\n", + " onehot[np.arange(target.size), target] = 1\n", + " return onehot\n", + "\n", + "digits = load_digits()\n", + "\n", + "X = digits.data\n", + "target = digits.target\n", + "target = onehot(target)\n", + "\n", + "input_nodes = 64\n", + "hidden_nodes1 = 100\n", + "hidden_nodes2 = 30\n", + "output_nodes = 10\n", + "\n", + "dims = (input_nodes, hidden_nodes1, hidden_nodes2, output_nodes)\n", + "\n", + "multiclass = FFNN(dims, hidden_func=LRELU, output_func=softmax, cost_func=CostCrossEntropy)\n", + "\n", + "multiclass.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "\n", + "scheduler = Adam(eta=1e-4, rho=0.9, rho2=0.999)\n", + "scores = multiclass.fit(X, target, scheduler, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "43d805bc", + "metadata": { + "editable": true + }, + "source": [ + "## Testing the XOR gate and other gates\n", + "\n", + "Let us now use our code to test the XOR gate." + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "4bbaf697", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "X = np.array([ [0, 0], [0, 1], [1, 0],[1, 1]],dtype=np.float64)\n", + "\n", + "# The XOR gate\n", + "yXOR = np.array( [[ 0], [1] ,[1], [0]])\n", + "\n", + "input_nodes = X.shape[1]\n", + "output_nodes = 1\n", + "\n", + "logistic_regression = FFNN((input_nodes, output_nodes), output_func=sigmoid, cost_func=CostLogReg, seed=2023)\n", + "logistic_regression.reset_weights() # reset weights such that previous runs or reruns don't affect the weights\n", + "scheduler = Adam(eta=1e-1, rho=0.9, rho2=0.999)\n", + "scores = logistic_regression.fit(X, yXOR, scheduler, epochs=1000)" + ] + }, + { + "cell_type": "markdown", + "id": "31e852a7", + "metadata": { + "editable": true + }, + "source": [ + "Not bad, but the results depend strongly on the learning reate. Try different learning rates." + ] + }, + { + "cell_type": "markdown", + "id": "9792c0c3", + "metadata": { + "editable": true + }, + "source": [ + "## Solving differential equations with Deep Learning\n", + "\n", + "The Universal Approximation Theorem states that a neural network can\n", + "approximate any function at a single hidden layer along with one input\n", + "and output layer to any given precision.\n", + "\n", + "**Book on solving differential equations with ML methods.**\n", + "\n", + "[An Introduction to Neural Network Methods for Differential Equations](https://www.springer.com/gp/book/9789401798150), by Yadav and Kumar.\n", + "\n", + "**Physics informed neural networks.**\n", + "\n", + "[Scientific Machine Learning Through Physics–Informed Neural Networks: Where we are and What’s Next](https://link.springer.com/article/10.1007/s10915-022-01939-z), by Cuomo et al\n", + "\n", + "**Thanks to Kristine Baluka Hein.**\n", + "\n", + "The lectures on differential equations were developed by Kristine Baluka Hein, now PhD student at IFI.\n", + "A great thanks to Kristine." + ] + }, + { + "cell_type": "markdown", + "id": "9214a407", + "metadata": { + "editable": true + }, + "source": [ + "## Ordinary Differential Equations first\n", + "\n", + "An ordinary differential equation (ODE) is an equation involving functions having one variable.\n", + "\n", + "In general, an ordinary differential equation looks like" + ] + }, + { + "cell_type": "markdown", + "id": "40a78c33", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{ode} \\tag{1}\n", + "f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right) = 0\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "42dae561", + "metadata": { + "editable": true + }, + "source": [ + "where $g(x)$ is the function to find, and $g^{(n)}(x)$ is the $n$-th derivative of $g(x)$.\n", + "\n", + "The $f\\left(x, g(x), g'(x), g''(x), \\, \\dots \\, , g^{(n)}(x)\\right)$ is just a way to write that there is an expression involving $x$ and $g(x), \\ g'(x), \\ g''(x), \\, \\dots \\, , \\text{ and } g^{(n)}(x)$ on the left side of the equality sign in ([1](#ode)).\n", + "The highest order of derivative, that is the value of $n$, determines to the order of the equation.\n", + "The equation is referred to as a $n$-th order ODE.\n", + "Along with ([1](#ode)), some additional conditions of the function $g(x)$ are typically given\n", + "for the solution to be unique." + ] + }, + { + "cell_type": "markdown", + "id": "b4bf5f2e", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "\n", + "Let the trial solution $g_t(x)$ be" + ] + }, + { + "cell_type": "markdown", + "id": "1f4f3eba", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation}\n", + "\tg_t(x) = h_1(x) + h_2(x,N(x,P))\n", + "\\label{_auto1} \\tag{2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "d799a47c", + "metadata": { + "editable": true + }, + "source": [ + "where $h_1(x)$ is a function that makes $g_t(x)$ satisfy a given set\n", + "of conditions, $N(x,P)$ a neural network with weights and biases\n", + "described by $P$ and $h_2(x, N(x,P))$ some expression involving the\n", + "neural network. The role of the function $h_2(x, N(x,P))$, is to\n", + "ensure that the output from $N(x,P)$ is zero when $g_t(x)$ is\n", + "evaluated at the values of $x$ where the given conditions must be\n", + "satisfied. The function $h_1(x)$ should alone make $g_t(x)$ satisfy\n", + "the conditions.\n", + "\n", + "But what about the network $N(x,P)$?\n", + "\n", + "As described previously, an optimization method could be used to minimize the parameters of a neural network, that being its weights and biases, through backward propagation." + ] + }, + { + "cell_type": "markdown", + "id": "abb02959", + "metadata": { + "editable": true + }, + "source": [ + "## Minimization process\n", + "\n", + "For the minimization to be defined, we need to have a cost function at hand to minimize.\n", + "\n", + "It is given that $f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right)$ should be equal to zero in ([1](#ode)).\n", + "We can choose to consider the mean squared error as the cost function for an input $x$.\n", + "Since we are looking at one input, the cost function is just $f$ squared.\n", + "The cost function $c\\left(x, P \\right)$ can therefore be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "6468ecf8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(x, P\\right) = \\big(f\\left(x, \\, g(x), \\, g'(x), \\, g''(x), \\, \\dots \\, , \\, g^{(n)}(x)\\right)\\big)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e7441b12", + "metadata": { + "editable": true + }, + "source": [ + "If $N$ inputs are given as a vector $\\boldsymbol{x}$ with elements $x_i$ for $i = 1,\\dots,N$,\n", + "the cost function becomes" + ] + }, + { + "cell_type": "markdown", + "id": "0ffd1c29", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{cost} \\tag{3}\n", + "\tC\\left(\\boldsymbol{x}, P\\right) = \\frac{1}{N} \\sum_{i=1}^N \\big(f\\left(x_i, \\, g(x_i), \\, g'(x_i), \\, g''(x_i), \\, \\dots \\, , \\, g^{(n)}(x_i)\\right)\\big)^2\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e55c8d3e", + "metadata": { + "editable": true + }, + "source": [ + "The neural net should then find the parameters $P$ that minimizes the cost function in\n", + "([3](#cost)) for a set of $N$ training samples $x_i$." + ] + }, + { + "cell_type": "markdown", + "id": "8a940e88", + "metadata": { + "editable": true + }, + "source": [ + "## Minimizing the cost function using gradient descent and automatic differentiation\n", + "\n", + "To perform the minimization using gradient descent, the gradient of $C\\left(\\boldsymbol{x}, P\\right)$ is needed.\n", + "It might happen so that finding an analytical expression of the gradient of $C(\\boldsymbol{x}, P)$ from ([3](#cost)) gets too messy, depending on which cost function one desires to use.\n", + "\n", + "Luckily, there exists libraries that makes the job for us through automatic differentiation.\n", + "Automatic differentiation is a method of finding the derivatives numerically with very high precision." + ] + }, + { + "cell_type": "markdown", + "id": "547613c0", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Exponential decay\n", + "\n", + "An exponential decay of a quantity $g(x)$ is described by the equation" + ] + }, + { + "cell_type": "markdown", + "id": "826651d6", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solve_expdec} \\tag{4}\n", + " g'(x) = -\\gamma g(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "870b960b", + "metadata": { + "editable": true + }, + "source": [ + "with $g(0) = g_0$ for some chosen initial value $g_0$.\n", + "\n", + "The analytical solution of ([4](#solve_expdec)) is" + ] + }, + { + "cell_type": "markdown", + "id": "5a8fd1e3", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " g(x) = g_0 \\exp\\left(-\\gamma x\\right)\n", + "\\label{_auto2} \\tag{5}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "55b4f286", + "metadata": { + "editable": true + }, + "source": [ + "Having an analytical solution at hand, it is possible to use it to compare how well a neural network finds a solution of ([4](#solve_expdec))." + ] + }, + { + "cell_type": "markdown", + "id": "7e4f689b", + "metadata": { + "editable": true + }, + "source": [ + "## The function to solve for\n", + "\n", + "The program will use a neural network to solve" + ] + }, + { + "cell_type": "markdown", + "id": "01e8e999", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solveode} \\tag{6}\n", + "g'(x) = -\\gamma g(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7ccea9f1", + "metadata": { + "editable": true + }, + "source": [ + "where $g(0) = g_0$ with $\\gamma$ and $g_0$ being some chosen values.\n", + "\n", + "In this example, $\\gamma = 2$ and $g_0 = 10$." + ] + }, + { + "cell_type": "markdown", + "id": "47fde776", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "To begin with, a trial solution $g_t(t)$ must be chosen. A general trial solution for ordinary differential equations could be" + ] + }, + { + "cell_type": "markdown", + "id": "f7a8f626", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x, P) = h_1(x) + h_2(x, N(x, P))\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "66551df0", + "metadata": { + "editable": true + }, + "source": [ + "with $h_1(x)$ ensuring that $g_t(x)$ satisfies some conditions and $h_2(x,N(x, P))$ an expression involving $x$ and the output from the neural network $N(x,P)$ with $P $ being the collection of the weights and biases for each layer. For now, it is assumed that the network consists of one input layer, one hidden layer, and one output layer." + ] + }, + { + "cell_type": "markdown", + "id": "c354ef4e", + "metadata": { + "editable": true + }, + "source": [ + "## Setup of Network\n", + "\n", + "In this network, there are no weights and bias at the input layer, so $P = \\{ P_{\\text{hidden}}, P_{\\text{output}} \\}$.\n", + "If there are $N_{\\text{hidden} }$ neurons in the hidden layer, then $P_{\\text{hidden}}$ is a $N_{\\text{hidden} } \\times (1 + N_{\\text{input}})$ matrix, given that there are $N_{\\text{input}}$ neurons in the input layer.\n", + "\n", + "The first column in $P_{\\text{hidden} }$ represents the bias for each neuron in the hidden layer and the second column represents the weights for each neuron in the hidden layer from the input layer.\n", + "If there are $N_{\\text{output} }$ neurons in the output layer, then $P_{\\text{output}} $ is a $N_{\\text{output} } \\times (1 + N_{\\text{hidden} })$ matrix.\n", + "\n", + "Its first column represents the bias of each neuron and the remaining columns represents the weights to each neuron.\n", + "\n", + "It is given that $g(0) = g_0$. The trial solution must fulfill this condition to be a proper solution of ([6](#solveode)). A possible way to ensure that $g_t(0, P) = g_0$, is to let $F(N(x,P)) = x \\cdot N(x,P)$ and $A(x) = g_0$. This gives the following trial solution:" + ] + }, + { + "cell_type": "markdown", + "id": "a574c0b7", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{trial} \\tag{7}\n", + "g_t(x, P) = g_0 + x \\cdot N(x, P)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "22f440c8", + "metadata": { + "editable": true + }, + "source": [ + "## Reformulating the problem\n", + "\n", + "We wish that our neural network manages to minimize a given cost function.\n", + "\n", + "A reformulation of out equation, ([6](#solveode)), must therefore be done,\n", + "such that it describes the problem a neural network can solve for.\n", + "\n", + "The neural network must find the set of weights and biases $P$ such that the trial solution in ([7](#trial)) satisfies ([6](#solveode)).\n", + "\n", + "The trial solution" + ] + }, + { + "cell_type": "markdown", + "id": "0ff80a83", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x, P) = g_0 + x \\cdot N(x, P)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "6829edab", + "metadata": { + "editable": true + }, + "source": [ + "has been chosen such that it already solves the condition $g(0) = g_0$. What remains, is to find $P$ such that" + ] + }, + { + "cell_type": "markdown", + "id": "381c61e2", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{nnmin} \\tag{8}\n", + "g_t'(x, P) = - \\gamma g_t(x, P)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ac36a03d", + "metadata": { + "editable": true + }, + "source": [ + "is fulfilled as *best as possible*." + ] + }, + { + "cell_type": "markdown", + "id": "2899becc", + "metadata": { + "editable": true + }, + "source": [ + "## More technicalities\n", + "\n", + "The left hand side and right hand side of ([8](#nnmin)) must be computed separately, and then the neural network must choose weights and biases, contained in $P$, such that the sides are equal as best as possible.\n", + "This means that the absolute or squared difference between the sides must be as close to zero, ideally equal to zero.\n", + "In this case, the difference squared shows to be an appropriate measurement of how erroneous the trial solution is with respect to $P$ of the neural network.\n", + "\n", + "This gives the following cost function our neural network must solve for:" + ] + }, + { + "cell_type": "markdown", + "id": "d52c8124", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P}\\Big\\{ \\big(g_t'(x, P) - ( -\\gamma g_t(x, P) \\big)^2 \\Big\\}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3f8f684e", + "metadata": { + "editable": true + }, + "source": [ + "(the notation $\\min_{P}\\{ f(x, P) \\}$ means that we desire to find $P$ that yields the minimum of $f(x, P)$)\n", + "\n", + "or, in terms of weights and biases for the hidden and output layer in our network:" + ] + }, + { + "cell_type": "markdown", + "id": "92cc16c9", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P_{\\text{hidden} }, \\ P_{\\text{output} }}\\Big\\{ \\big(g_t'(x, \\{ P_{\\text{hidden} }, P_{\\text{output} }\\}) - ( -\\gamma g_t(x, \\{ P_{\\text{hidden} }, P_{\\text{output} }\\}) \\big)^2 \\Big\\}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "628e0dfc", + "metadata": { + "editable": true + }, + "source": [ + "for an input value $x$." + ] + }, + { + "cell_type": "markdown", + "id": "e54b4c6e", + "metadata": { + "editable": true + }, + "source": [ + "## More details\n", + "\n", + "If the neural network evaluates $g_t(x, P)$ at more values for $x$, say $N$ values $x_i$ for $i = 1, \\dots, N$, then the *total* error to minimize becomes" + ] + }, + { + "cell_type": "markdown", + "id": "80dc48dd", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{min} \\tag{9}\n", + "\\min_{P}\\Big\\{\\frac{1}{N} \\sum_{i=1}^N \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2 \\Big\\}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "e57a1d70", + "metadata": { + "editable": true + }, + "source": [ + "Letting $\\boldsymbol{x}$ be a vector with elements $x_i$ and $C(\\boldsymbol{x}, P) = \\frac{1}{N} \\sum_i \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2$ denote the cost function, the minimization problem that our network must solve, becomes" + ] + }, + { + "cell_type": "markdown", + "id": "8ad67e57", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\min_{P} C(\\boldsymbol{x}, P)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "4eed66ce", + "metadata": { + "editable": true + }, + "source": [ + "In terms of $P_{\\text{hidden} }$ and $P_{\\text{output} }$, this could also be expressed as\n", + "\n", + "$$\n", + "\\min_{P_{\\text{hidden} }, \\ P_{\\text{output} }} C(\\boldsymbol{x}, \\{P_{\\text{hidden} }, P_{\\text{output} }\\})\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "9d652c56", + "metadata": { + "editable": true + }, + "source": [ + "## A possible implementation of a neural network\n", + "\n", + "For simplicity, it is assumed that the input is an array $\\boldsymbol{x} = (x_1, \\dots, x_N)$ with $N$ elements. It is at these points the neural network should find $P$ such that it fulfills ([9](#min)).\n", + "\n", + "First, the neural network must feed forward the inputs.\n", + "This means that $\\boldsymbol{x}s$ must be passed through an input layer, a hidden layer and a output layer. The input layer in this case, does not need to process the data any further.\n", + "The input layer will consist of $N_{\\text{input} }$ neurons, passing its element to each neuron in the hidden layer. The number of neurons in the hidden layer will be $N_{\\text{hidden} }$." + ] + }, + { + "cell_type": "markdown", + "id": "9a5a1ad7", + "metadata": { + "editable": true + }, + "source": [ + "## Technicalities\n", + "\n", + "For the $i$-th in the hidden layer with weight $w_i^{\\text{hidden} }$ and bias $b_i^{\\text{hidden} }$, the weighting from the $j$-th neuron at the input layer is:" + ] + }, + { + "cell_type": "markdown", + "id": "ed15e067", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "z_{i,j}^{\\text{hidden}} &= b_i^{\\text{hidden}} + w_i^{\\text{hidden}}x_j \\\\\n", + "&=\n", + "\\begin{pmatrix}\n", + "b_i^{\\text{hidden}} & w_i^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 \\\\\n", + "x_j\n", + "\\end{pmatrix}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "827ac223", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities I\n", + "\n", + "The result after weighting the inputs at the $i$-th hidden neuron can be written as a vector:" + ] + }, + { + "cell_type": "markdown", + "id": "a0a7b13f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "\\boldsymbol{z}_{i}^{\\text{hidden}} &= \\Big( b_i^{\\text{hidden}} + w_i^{\\text{hidden}}x_1 , \\ b_i^{\\text{hidden}} + w_i^{\\text{hidden}} x_2, \\ \\dots \\, , \\ b_i^{\\text{hidden}} + w_i^{\\text{hidden}} x_N\\Big) \\\\\n", + "&=\n", + "\\begin{pmatrix}\n", + " b_i^{\\text{hidden}} & w_i^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 & 1 & \\dots & 1 \\\\\n", + "x_1 & x_2 & \\dots & x_N\n", + "\\end{pmatrix} \\\\\n", + "&= \\boldsymbol{p}_{i, \\text{hidden}}^T X\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0879010a", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities II\n", + "\n", + "The vector $\\boldsymbol{p}_{i, \\text{hidden}}^T$ constitutes each row in $P_{\\text{hidden} }$, which contains the weights for the neural network to minimize according to ([9](#min)).\n", + "\n", + "After having found $\\boldsymbol{z}_{i}^{\\text{hidden}} $ for every $i$-th neuron within the hidden layer, the vector will be sent to an activation function $a_i(\\boldsymbol{z})$.\n", + "\n", + "In this example, the sigmoid function has been chosen to be the activation function for each hidden neuron:" + ] + }, + { + "cell_type": "markdown", + "id": "66ac91b3", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "f(z) = \\frac{1}{1 + \\exp{(-z)}}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "470c74b5", + "metadata": { + "editable": true + }, + "source": [ + "It is possible to use other activations functions for the hidden layer also.\n", + "\n", + "The output $\\boldsymbol{x}_i^{\\text{hidden}}$ from each $i$-th hidden neuron is:\n", + "\n", + "$$\n", + "\\boldsymbol{x}_i^{\\text{hidden} } = f\\big( \\boldsymbol{z}_{i}^{\\text{hidden}} \\big)\n", + "$$\n", + "\n", + "The outputs $\\boldsymbol{x}_i^{\\text{hidden} } $ are then sent to the output layer.\n", + "\n", + "The output layer consists of one neuron in this case, and combines the\n", + "output from each of the neurons in the hidden layers. The output layer\n", + "combines the results from the hidden layer using some weights $w_i^{\\text{output}}$\n", + "and biases $b_i^{\\text{output}}$. In this case,\n", + "it is assumes that the number of neurons in the output layer is one." + ] + }, + { + "cell_type": "markdown", + "id": "bf5e6967", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities III\n", + "\n", + "The procedure of weighting the output neuron $j$ in the hidden layer to the $i$-th neuron in the output layer is similar as for the hidden layer described previously." + ] + }, + { + "cell_type": "markdown", + "id": "766b88f8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "z_{1,j}^{\\text{output}} & =\n", + "\\begin{pmatrix}\n", + "b_1^{\\text{output}} & \\boldsymbol{w}_1^{\\text{output}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 \\\\\n", + "\\boldsymbol{x}_j^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5c114139", + "metadata": { + "editable": true + }, + "source": [ + "## Final technicalities IV\n", + "\n", + "Expressing $z_{1,j}^{\\text{output}}$ as a vector gives the following way of weighting the inputs from the hidden layer:" + ] + }, + { + "cell_type": "markdown", + "id": "45596281", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\boldsymbol{z}_{1}^{\\text{output}} =\n", + "\\begin{pmatrix}\n", + "b_1^{\\text{output}} & \\boldsymbol{w}_1^{\\text{output}}\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "1 & 1 & \\dots & 1 \\\\\n", + "\\boldsymbol{x}_1^{\\text{hidden}} & \\boldsymbol{x}_2^{\\text{hidden}} & \\dots & \\boldsymbol{x}_N^{\\text{hidden}}\n", + "\\end{pmatrix}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2c1378fb", + "metadata": { + "editable": true + }, + "source": [ + "In this case we seek a continuous range of values since we are approximating a function. This means that after computing $\\boldsymbol{z}_{1}^{\\text{output}}$ the neural network has finished its feed forward step, and $\\boldsymbol{z}_{1}^{\\text{output}}$ is the final output of the network." + ] + }, + { + "cell_type": "markdown", + "id": "66a732e1", + "metadata": { + "editable": true + }, + "source": [ + "## Back propagation\n", + "\n", + "The next step is to decide how the parameters should be changed such that they minimize the cost function.\n", + "\n", + "The chosen cost function for this problem is" + ] + }, + { + "cell_type": "markdown", + "id": "fdf81225", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C(\\boldsymbol{x}, P) = \\frac{1}{N} \\sum_i \\big(g_t'(x_i, P) - ( -\\gamma g_t(x_i, P) \\big)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "9bb52111", + "metadata": { + "editable": true + }, + "source": [ + "In order to minimize the cost function, an optimization method must be chosen.\n", + "\n", + "Here, gradient descent with a constant step size has been chosen." + ] + }, + { + "cell_type": "markdown", + "id": "f3e495b4", + "metadata": { + "editable": true + }, + "source": [ + "## Gradient descent\n", + "\n", + "The idea of the gradient descent algorithm is to update parameters in\n", + "a direction where the cost function decreases goes to a minimum.\n", + "\n", + "In general, the update of some parameters $\\boldsymbol{\\omega}$ given a cost\n", + "function defined by some weights $\\boldsymbol{\\omega}$, $C(\\boldsymbol{x},\n", + "\\boldsymbol{\\omega})$, goes as follows:" + ] + }, + { + "cell_type": "markdown", + "id": "adc904df", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\boldsymbol{\\omega}_{\\text{new} } = \\boldsymbol{\\omega} - \\lambda \\nabla_{\\boldsymbol{\\omega}} C(\\boldsymbol{x}, \\boldsymbol{\\omega})\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2d01b1b5", + "metadata": { + "editable": true + }, + "source": [ + "for a number of iterations or until $ \\big|\\big| \\boldsymbol{\\omega}_{\\text{new} } - \\boldsymbol{\\omega} \\big|\\big|$ becomes smaller than some given tolerance.\n", + "\n", + "The value of $\\lambda$ decides how large steps the algorithm must take\n", + "in the direction of $ \\nabla_{\\boldsymbol{\\omega}} C(\\boldsymbol{x}, \\boldsymbol{\\omega})$.\n", + "The notation $\\nabla_{\\boldsymbol{\\omega}}$ express the gradient with respect\n", + "to the elements in $\\boldsymbol{\\omega}$.\n", + "\n", + "In our case, we have to minimize the cost function $C(\\boldsymbol{x}, P)$ with\n", + "respect to the two sets of weights and biases, that is for the hidden\n", + "layer $P_{\\text{hidden} }$ and for the output layer $P_{\\text{output}\n", + "}$ .\n", + "\n", + "This means that $P_{\\text{hidden} }$ and $P_{\\text{output} }$ is updated by" + ] + }, + { + "cell_type": "markdown", + "id": "5077f4f7", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "P_{\\text{hidden},\\text{new}} &= P_{\\text{hidden}} - \\lambda \\nabla_{P_{\\text{hidden}}} C(\\boldsymbol{x}, P) \\\\\n", + "P_{\\text{output},\\text{new}} &= P_{\\text{output}} - \\lambda \\nabla_{P_{\\text{output}}} C(\\boldsymbol{x}, P)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "fb01e943", + "metadata": { + "editable": true + }, + "source": [ + "## The code for solving the ODE" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "6347e101", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# Assuming one input, hidden, and output layer\n", + "def neural_network(params, x):\n", + "\n", + " # Find the weights (including and biases) for the hidden and output layer.\n", + " # Assume that params is a list of parameters for each layer.\n", + " # The biases are the first element for each array in params,\n", + " # and the weights are the remaning elements in each array in params.\n", + "\n", + " w_hidden = params[0]\n", + " w_output = params[1]\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " ## Hidden layer:\n", + "\n", + " # Add a row of ones to include bias\n", + " x_input = np.concatenate((np.ones((1,num_values)), x_input ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_input)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " ## Output layer:\n", + "\n", + " # Include bias:\n", + " x_hidden = np.concatenate((np.ones((1,num_values)), x_hidden ), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_hidden)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial(x,params, g0 = 10):\n", + " return g0 + x*neural_network(params,x)\n", + "\n", + "# The right side of the ODE:\n", + "def g(x, g_trial, gamma = 2):\n", + " return -gamma*g_trial\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the neural network\n", + " d_net_out = elementwise_grad(neural_network,1)(P,x)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = g(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# Solve the exponential decay ODE using neural network with one input, hidden, and output layer\n", + "def solve_ode_neural_network(x, num_neurons_hidden, num_iter, lmb):\n", + " ## Set up initial weights and biases\n", + "\n", + " # For the hidden layer\n", + " p0 = npr.randn(num_neurons_hidden, 2 )\n", + "\n", + " # For the output layer\n", + " p1 = npr.randn(1, num_neurons_hidden + 1 ) # +1 since bias is included\n", + "\n", + " P = [p0, p1]\n", + "\n", + " print('Initial cost: %g'%cost_function(P, x))\n", + "\n", + " ## Start finding the optimal weights using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of two arrays;\n", + " # one for the gradient w.r.t P_hidden and\n", + " # one for the gradient w.r.t P_output\n", + " cost_grad = cost_function_grad(P, x)\n", + "\n", + " P[0] = P[0] - lmb * cost_grad[0]\n", + " P[1] = P[1] - lmb * cost_grad[1]\n", + "\n", + " print('Final cost: %g'%cost_function(P, x))\n", + "\n", + " return P\n", + "\n", + "def g_analytic(x, gamma = 2, g0 = 10):\n", + " return g0*np.exp(-gamma*x)\n", + "\n", + "# Solve the given problem\n", + "if __name__ == '__main__':\n", + " # Set seed such that the weight are initialized\n", + " # with same weights and biases for every run.\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " N = 10\n", + " x = np.linspace(0, 1, N)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = 10\n", + " num_iter = 10000\n", + " lmb = 0.001\n", + "\n", + " # Use the network\n", + " P = solve_ode_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " # Print the deviation from the trial solution and true solution\n", + " res = g_trial(x,P)\n", + " res_analytical = g_analytic(x)\n", + "\n", + " print('Max absolute difference: %g'%np.max(np.abs(res - res_analytical)))\n", + "\n", + " # Plot the results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, res_analytical)\n", + " plt.plot(x, res[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "59e5acda", + "metadata": { + "editable": true + }, + "source": [ + "## The network with one input layer, specified number of hidden layers, and one output layer\n", + "\n", + "It is also possible to extend the construction of our network into a more general one, allowing the network to contain more than one hidden layers.\n", + "\n", + "The number of neurons within each hidden layer are given as a list of integers in the program below." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "f1a60516", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# The neural network with one input layer and one output layer,\n", + "# but with number of hidden layers specified by the user.\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial_deep(x,params, g0 = 10):\n", + " return g0 + x*deep_neural_network(params, x)\n", + "\n", + "# The right side of the ODE:\n", + "def g(x, g_trial, gamma = 2):\n", + " return -gamma*g_trial\n", + "\n", + "# The same cost function as before, but calls deep_neural_network instead.\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the neural network\n", + " d_net_out = elementwise_grad(deep_neural_network,1)(P,x)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial_deep,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = g(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# Solve the exponential decay ODE using neural network with one input and one output layer,\n", + "# but with specified number of hidden layers from the user.\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # The number of elements in the list num_hidden_neurons thus represents\n", + " # the number of hidden layers.\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weights and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weights using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "def g_analytic(x, gamma = 2, g0 = 10):\n", + " return g0*np.exp(-gamma*x)\n", + "\n", + "# Solve the given problem\n", + "if __name__ == '__main__':\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " N = 10\n", + " x = np.linspace(0, 1, N)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = np.array([10,10])\n", + " num_iter = 10000\n", + " lmb = 0.001\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " res = g_trial_deep(x,P)\n", + " res_analytical = g_analytic(x)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of a deep neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, res_analytical)\n", + " plt.plot(x, res[0,:])\n", + " plt.legend(['analytical','dnn'])\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "807a375c", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Population growth\n", + "\n", + "A logistic model of population growth assumes that a population converges toward an equilibrium.\n", + "The population growth can be modeled by" + ] + }, + { + "cell_type": "markdown", + "id": "d35839bb", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{log} \\tag{10}\n", + "\tg'(t) = \\alpha g(t)(A - g(t))\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "2991d1fe", + "metadata": { + "editable": true + }, + "source": [ + "where $g(t)$ is the population density at time $t$, $\\alpha > 0$ the growth rate and $A > 0$ is the maximum population number in the environment.\n", + "Also, at $t = 0$ the population has the size $g(0) = g_0$, where $g_0$ is some chosen constant.\n", + "\n", + "In this example, similar network as for the exponential decay using Autograd has been used to solve the equation. However, as the implementation might suffer from e.g numerical instability\n", + "and high execution time (this might be more apparent in the examples solving PDEs),\n", + "using a library like TensorFlow is recommended.\n", + "Here, we stay with a more simple approach and implement for comparison, the simple forward Euler method." + ] + }, + { + "cell_type": "markdown", + "id": "ee668a71", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the problem\n", + "\n", + "Here, we will model a population $g(t)$ in an environment having carrying capacity $A$.\n", + "The population follows the model" + ] + }, + { + "cell_type": "markdown", + "id": "febf10cc", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{solveode_population} \\tag{11}\n", + "g'(t) = \\alpha g(t)(A - g(t))\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "494194e3", + "metadata": { + "editable": true + }, + "source": [ + "where $g(0) = g_0$.\n", + "\n", + "In this example, we let $\\alpha = 2$, $A = 1$, and $g_0 = 1.2$." + ] + }, + { + "cell_type": "markdown", + "id": "5efa7b11", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "\n", + "We will get a slightly different trial solution, as the boundary conditions are different\n", + "compared to the case for exponential decay.\n", + "\n", + "A possible trial solution satisfying the condition $g(0) = g_0$ could be\n", + "\n", + "$$\n", + "h_1(t) = g_0 + t \\cdot N(t,P)\n", + "$$\n", + "\n", + "with $N(t,P)$ being the output from the neural network with weights and biases for each layer collected in the set $P$.\n", + "\n", + "The analytical solution is\n", + "\n", + "$$\n", + "g(t) = \\frac{Ag_0}{g_0 + (A - g_0)\\exp(-\\alpha A t)}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "568131dc", + "metadata": { + "editable": true + }, + "source": [ + "## The program using Autograd\n", + "\n", + "The network will be the similar as for the exponential decay example, but with some small modifications for our problem." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "8737e028", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "# Function to get the parameters.\n", + "# Done such that one can easily change the paramaters after one's liking.\n", + "def get_parameters():\n", + " alpha = 2\n", + " A = 1\n", + " g0 = 1.2\n", + " return alpha, A, g0\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d_g_t = elementwise_grad(g_trial_deep,0)(x,P)\n", + "\n", + " # The right side of the ODE\n", + " func = f(x, g_t)\n", + "\n", + " err_sqr = (d_g_t - func)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum / np.size(err_sqr)\n", + "\n", + "# The right side of the ODE:\n", + "def f(x, g_trial):\n", + " alpha,A, g0 = get_parameters()\n", + " return alpha*g_trial*(A - g_trial)\n", + "\n", + "# The trial solution using the deep neural network:\n", + "def g_trial_deep(x, params):\n", + " alpha,A, g0 = get_parameters()\n", + " return g0 + x*deep_neural_network(params,x)\n", + "\n", + "# The analytical solution:\n", + "def g_analytic(t):\n", + " alpha,A, g0 = get_parameters()\n", + " return A*g0/(g0 + (A - g0)*np.exp(-alpha*A*t))\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nt = 10\n", + " T = 1\n", + " t = np.linspace(0,T, Nt)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [100, 50, 25]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(t,P)\n", + " g_analytical = g_analytic(t)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " diff_ag = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%diff_ag)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(t, g_analytical)\n", + " plt.plot(t, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "0904f64d", + "metadata": { + "editable": true + }, + "source": [ + "## Using forward Euler to solve the ODE\n", + "\n", + "A straightforward way of solving an ODE numerically, is to use Euler's method.\n", + "\n", + "Euler's method uses Taylor series to approximate the value at a function $f$ at a step $\\Delta x$ from $x$:\n", + "\n", + "$$\n", + "f(x + \\Delta x) \\approx f(x) + \\Delta x f'(x)\n", + "$$\n", + "\n", + "In our case, using Euler's method to approximate the value of $g$ at a step $\\Delta t$ from $t$ yields" + ] + }, + { + "cell_type": "markdown", + "id": "6f3577a8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + " g(t + \\Delta t) &\\approx g(t) + \\Delta t g'(t) \\\\\n", + " &= g(t) + \\Delta t \\big(\\alpha g(t)(A - g(t))\\big)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "56d4410b", + "metadata": { + "editable": true + }, + "source": [ + "along with the condition that $g(0) = g_0$.\n", + "\n", + "Let $t_i = i \\cdot \\Delta t$ where $\\Delta t = \\frac{T}{N_t-1}$ where $T$ is the final time our solver must solve for and $N_t$ the number of values for $t \\in [0, T]$ for $i = 0, \\dots, N_t-1$.\n", + "\n", + "For $i \\geq 1$, we have that" + ] + }, + { + "cell_type": "markdown", + "id": "48d2707e", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "t_i &= i\\Delta t \\\\\n", + "&= (i - 1)\\Delta t + \\Delta t \\\\\n", + "&= t_{i-1} + \\Delta t\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "66d99f85", + "metadata": { + "editable": true + }, + "source": [ + "Now, if $g_i = g(t_i)$ then" + ] + }, + { + "cell_type": "markdown", + "id": "3c9447d9", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\begin{aligned}\n", + " g_i &= g(t_i) \\\\\n", + " &= g(t_{i-1} + \\Delta t) \\\\\n", + " &\\approx g(t_{i-1}) + \\Delta t \\big(\\alpha g(t_{i-1})(A - g(t_{i-1}))\\big) \\\\\n", + " &= g_{i-1} + \\Delta t \\big(\\alpha g_{i-1}(A - g_{i-1})\\big)\n", + " \\end{aligned}\n", + "\\end{equation} \\label{odenum} \\tag{12}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "724b97f1", + "metadata": { + "editable": true + }, + "source": [ + "for $i \\geq 1$ and $g_0 = g(t_0) = g(0) = g_0$.\n", + "\n", + "Equation ([12](#odenum)) could be implemented in the following way,\n", + "extending the program that uses the network using Autograd:" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "58b0da70", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Assume that all function definitions from the example program using Autograd\n", + "# are located here.\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nt = 10\n", + " T = 1\n", + " t = np.linspace(0,T, Nt)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [100,50,25]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(t,P)\n", + " g_analytical = g_analytic(t)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " diff_ag = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%diff_ag)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(t, g_analytical)\n", + " plt.plot(t, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " ## Find an approximation to the funtion using forward Euler\n", + "\n", + " alpha, A, g0 = get_parameters()\n", + " dt = T/(Nt - 1)\n", + "\n", + " # Perform forward Euler to solve the ODE\n", + " g_euler = np.zeros(Nt)\n", + " g_euler[0] = g0\n", + "\n", + " for i in range(1,Nt):\n", + " g_euler[i] = g_euler[i-1] + dt*(alpha*g_euler[i-1]*(A - g_euler[i-1]))\n", + "\n", + " # Print the errors done by each method\n", + " diff1 = np.max(np.abs(g_euler - g_analytical))\n", + " diff2 = np.max(np.abs(g_dnn_ag[0,:] - g_analytical))\n", + "\n", + " print('Max absolute difference between Euler method and analytical: %g'%diff1)\n", + " print('Max absolute difference between deep neural network and analytical: %g'%diff2)\n", + "\n", + " # Plot results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.plot(t,g_euler)\n", + " plt.plot(t,g_analytical)\n", + " plt.plot(t,g_dnn_ag[0,:])\n", + "\n", + " plt.legend(['euler','analytical','dnn'])\n", + " plt.xlabel('Time t')\n", + " plt.ylabel('g(t)')\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "f1230dee", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Solving the one dimensional Poisson equation\n", + "\n", + "The Poisson equation for $g(x)$ in one dimension is" + ] + }, + { + "cell_type": "markdown", + "id": "ba2c6d0a", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{poisson} \\tag{13}\n", + " -g''(x) = f(x)\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bab1c7d3", + "metadata": { + "editable": true + }, + "source": [ + "where $f(x)$ is a given function for $x \\in (0,1)$.\n", + "\n", + "The conditions that $g(x)$ is chosen to fulfill, are" + ] + }, + { + "cell_type": "markdown", + "id": "42bfde23", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + " g(0) &= 0 \\\\\n", + " g(1) &= 0\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "7b3a2504", + "metadata": { + "editable": true + }, + "source": [ + "This equation can be solved numerically using programs where e.g Autograd and TensorFlow are used.\n", + "The results from the networks can then be compared to the analytical solution.\n", + "In addition, it could be interesting to see how a typical method for numerically solving second order ODEs compares to the neural networks." + ] + }, + { + "cell_type": "markdown", + "id": "a419909c", + "metadata": { + "editable": true + }, + "source": [ + "## The specific equation to solve for\n", + "\n", + "Here, the function $g(x)$ to solve for follows the equation" + ] + }, + { + "cell_type": "markdown", + "id": "125f8197", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "-g''(x) = f(x),\\qquad x \\in (0,1)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "16376b60", + "metadata": { + "editable": true + }, + "source": [ + "where $f(x)$ is a given function, along with the chosen conditions" + ] + }, + { + "cell_type": "markdown", + "id": "044c76ec", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{aligned}\n", + "g(0) = g(1) = 0\n", + "\\end{aligned}\\label{cond} \\tag{14}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "0ec4860b", + "metadata": { + "editable": true + }, + "source": [ + "In this example, we consider the case when $f(x) = (3x + x^2)\\exp(x)$.\n", + "\n", + "For this case, a possible trial solution satisfying the conditions could be" + ] + }, + { + "cell_type": "markdown", + "id": "03e27ec0", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g_t(x) = x \\cdot (1-x) \\cdot N(P,x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "82fdb51f", + "metadata": { + "editable": true + }, + "source": [ + "The analytical solution for this problem is" + ] + }, + { + "cell_type": "markdown", + "id": "82e39d0e", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "g(x) = x(1 - x)\\exp(x)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "bf029e6c", + "metadata": { + "editable": true + }, + "source": [ + "## Solving the equation using Autograd" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "e10d7641", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "## Set up the cost function specified for this Poisson equation:\n", + "\n", + "# The right side of the ODE\n", + "def f(x):\n", + " return (3*x + x**2)*np.exp(x)\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P)\n", + "\n", + " right_side = f(x)\n", + "\n", + " err_sqr = (-d2_g_t - right_side)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum/np.size(err_sqr)\n", + "\n", + "# The trial solution:\n", + "def g_trial_deep(x,P):\n", + " return x*(1-x)*deep_neural_network(P,x)\n", + "\n", + "# The analytic solution;\n", + "def g_analytic(x):\n", + " return x*(1-x)*np.exp(x)\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10\n", + " x = np.linspace(0,1, Nx)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [200,100]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(x,P)\n", + " g_analytical = g_analytic(x)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + " max_diff = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " print(\"The max absolute difference between the solutions is: %g\"%max_diff)\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, g_analytical)\n", + " plt.plot(x, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "82891392", + "metadata": { + "editable": true + }, + "source": [ + "## Comparing with a numerical scheme\n", + "\n", + "The Poisson equation is possible to solve using Taylor series to approximate the second derivative.\n", + "\n", + "Using Taylor series, the second derivative can be expressed as\n", + "\n", + "$$\n", + "g''(x) = \\frac{g(x + \\Delta x) - 2g(x) + g(x-\\Delta x)}{\\Delta x^2} + E_{\\Delta x}(x)\n", + "$$\n", + "\n", + "where $\\Delta x$ is a small step size and $E_{\\Delta x}(x)$ being the error term.\n", + "\n", + "Looking away from the error terms gives an approximation to the second derivative:" + ] + }, + { + "cell_type": "markdown", + "id": "ad4ef510", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{approx} \\tag{15}\n", + "g''(x) \\approx \\frac{g(x + \\Delta x) - 2g(x) + g(x-\\Delta x)}{\\Delta x^2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "eb8ab804", + "metadata": { + "editable": true + }, + "source": [ + "If $x_i = i \\Delta x = x_{i-1} + \\Delta x$ and $g_i = g(x_i)$ for $i = 1,\\dots N_x - 2$ with $N_x$ being the number of values for $x$, ([15](#approx)) becomes" + ] + }, + { + "cell_type": "markdown", + "id": "f9b7b2a0", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "g''(x_i) &\\approx \\frac{g(x_i + \\Delta x) - 2g(x_i) + g(x_i -\\Delta x)}{\\Delta x^2} \\\\\n", + "&= \\frac{g_{i+1} - 2g_i + g_{i-1}}{\\Delta x^2}\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "6a71c7bb", + "metadata": { + "editable": true + }, + "source": [ + "Since we know from our problem that" + ] + }, + { + "cell_type": "markdown", + "id": "d19780a8", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "-g''(x) &= f(x) \\\\\n", + "&= (3x + x^2)\\exp(x)\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "00fedc6e", + "metadata": { + "editable": true + }, + "source": [ + "along with the conditions $g(0) = g(1) = 0$,\n", + "the following scheme can be used to find an approximate solution for $g(x)$ numerically:" + ] + }, + { + "cell_type": "markdown", + "id": "28005c86", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\begin{aligned}\n", + " -\\Big( \\frac{g_{i+1} - 2g_i + g_{i-1}}{\\Delta x^2} \\Big) &= f(x_i) \\\\\n", + " -g_{i+1} + 2g_i - g_{i-1} &= \\Delta x^2 f(x_i)\n", + " \\end{aligned}\n", + "\\end{equation} \\label{odesys} \\tag{16}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "d562bb0c", + "metadata": { + "editable": true + }, + "source": [ + "for $i = 1, \\dots, N_x - 2$ where $g_0 = g_{N_x - 1} = 0$ and $f(x_i) = (3x_i + x_i^2)\\exp(x_i)$, which is given for our specific problem.\n", + "\n", + "The equation can be rewritten into a matrix equation:" + ] + }, + { + "cell_type": "markdown", + "id": "bdee81e4", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{aligned}\n", + "\\begin{pmatrix}\n", + "2 & -1 & 0 & \\dots & 0 \\\\\n", + "-1 & 2 & -1 & \\dots & 0 \\\\\n", + "\\vdots & & \\ddots & & \\vdots \\\\\n", + "0 & \\dots & -1 & 2 & -1 \\\\\n", + "0 & \\dots & 0 & -1 & 2\\\\\n", + "\\end{pmatrix}\n", + "\\begin{pmatrix}\n", + "g_1 \\\\\n", + "g_2 \\\\\n", + "\\vdots \\\\\n", + "g_{N_x - 3} \\\\\n", + "g_{N_x - 2}\n", + "\\end{pmatrix}\n", + "&=\n", + "\\Delta x^2\n", + "\\begin{pmatrix}\n", + "f(x_1) \\\\\n", + "f(x_2) \\\\\n", + "\\vdots \\\\\n", + "f(x_{N_x - 3}) \\\\\n", + "f(x_{N_x - 2})\n", + "\\end{pmatrix} \\\\\n", + "\\boldsymbol{A}\\boldsymbol{g} &= \\boldsymbol{f},\n", + "\\end{aligned}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "ddf436f5", + "metadata": { + "editable": true + }, + "source": [ + "which makes it possible to solve for the vector $\\boldsymbol{g}$." + ] + }, + { + "cell_type": "markdown", + "id": "66ae2d44", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the code\n", + "\n", + "We can then compare the result from this numerical scheme with the output from our network using Autograd:" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "17f02a24", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import grad, elementwise_grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import pyplot as plt\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # N_hidden is the number of hidden layers\n", + " # deep_params is a list, len() should be used\n", + " N_hidden = len(deep_params) - 1 # -1 since params consists of\n", + " # parameters to all the hidden\n", + " # layers AND the output layer.\n", + "\n", + " # Assumes input x being an one-dimensional array\n", + " num_values = np.size(x)\n", + " x = x.reshape(-1, num_values)\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + "\n", + " # Due to multiple hidden layers, define a variable referencing to the\n", + " # output of the previous layer:\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_values)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output\n", + "\n", + "\n", + "def solve_ode_deep_neural_network(x, num_neurons, num_iter, lmb):\n", + " # num_hidden_neurons is now a list of number of neurons within each hidden layer\n", + "\n", + " # Find the number of hidden layers:\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 )\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: %g'%cost_function_deep(P, x))\n", + "\n", + " ## Start finding the optimal weigths using gradient descent\n", + "\n", + " # Find the Python function that represents the gradient of the cost function\n", + " # w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer\n", + " cost_function_deep_grad = grad(cost_function_deep,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " # Evaluate the gradient at the current weights and biases in P.\n", + " # The cost_grad consist now of N_hidden + 1 arrays; the gradient w.r.t the weights and biases\n", + " # in the hidden layers and output layers evaluated at x.\n", + " cost_deep_grad = cost_function_deep_grad(P, x)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_deep_grad[l]\n", + "\n", + " print('Final cost: %g'%cost_function_deep(P, x))\n", + "\n", + " return P\n", + "\n", + "## Set up the cost function specified for this Poisson equation:\n", + "\n", + "# The right side of the ODE\n", + "def f(x):\n", + " return (3*x + x**2)*np.exp(x)\n", + "\n", + "def cost_function_deep(P, x):\n", + "\n", + " # Evaluate the trial function with the current parameters P\n", + " g_t = g_trial_deep(x,P)\n", + "\n", + " # Find the derivative w.r.t x of the trial function\n", + " d2_g_t = elementwise_grad(elementwise_grad(g_trial_deep,0))(x,P)\n", + "\n", + " right_side = f(x)\n", + "\n", + " err_sqr = (-d2_g_t - right_side)**2\n", + " cost_sum = np.sum(err_sqr)\n", + "\n", + " return cost_sum/np.size(err_sqr)\n", + "\n", + "# The trial solution:\n", + "def g_trial_deep(x,P):\n", + " return x*(1-x)*deep_neural_network(P,x)\n", + "\n", + "# The analytic solution;\n", + "def g_analytic(x):\n", + " return x*(1-x)*np.exp(x)\n", + "\n", + "if __name__ == '__main__':\n", + " npr.seed(4155)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10\n", + " x = np.linspace(0,1, Nx)\n", + "\n", + " ## Set up the initial parameters\n", + " num_hidden_neurons = [200,100]\n", + " num_iter = 1000\n", + " lmb = 1e-3\n", + "\n", + " P = solve_ode_deep_neural_network(x, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " g_dnn_ag = g_trial_deep(x,P)\n", + " g_analytical = g_analytic(x)\n", + "\n", + " # Find the maximum absolute difference between the solutons:\n", + "\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.title('Performance of neural network solving an ODE compared to the analytical solution')\n", + " plt.plot(x, g_analytical)\n", + " plt.plot(x, g_dnn_ag[0,:])\n", + " plt.legend(['analytical','nn'])\n", + " plt.xlabel('x')\n", + " plt.ylabel('g(x)')\n", + "\n", + " ## Perform the computation using the numerical scheme\n", + "\n", + " dx = 1/(Nx - 1)\n", + "\n", + " # Set up the matrix A\n", + " A = np.zeros((Nx-2,Nx-2))\n", + "\n", + " A[0,0] = 2\n", + " A[0,1] = -1\n", + "\n", + " for i in range(1,Nx-3):\n", + " A[i,i-1] = -1\n", + " A[i,i] = 2\n", + " A[i,i+1] = -1\n", + "\n", + " A[Nx - 3, Nx - 4] = -1\n", + " A[Nx - 3, Nx - 3] = 2\n", + "\n", + " # Set up the vector f\n", + " f_vec = dx**2 * f(x[1:-1])\n", + "\n", + " # Solve the equation\n", + " g_res = np.linalg.solve(A,f_vec)\n", + "\n", + " g_vec = np.zeros(Nx)\n", + " g_vec[1:-1] = g_res\n", + "\n", + " # Print the differences between each method\n", + " max_diff1 = np.max(np.abs(g_dnn_ag - g_analytical))\n", + " max_diff2 = np.max(np.abs(g_vec - g_analytical))\n", + " print(\"The max absolute difference between the analytical solution and DNN Autograd: %g\"%max_diff1)\n", + " print(\"The max absolute difference between the analytical solution and numerical scheme: %g\"%max_diff2)\n", + "\n", + " # Plot the results\n", + " plt.figure(figsize=(10,10))\n", + "\n", + " plt.plot(x,g_vec)\n", + " plt.plot(x,g_analytical)\n", + " plt.plot(x,g_dnn_ag[0,:])\n", + "\n", + " plt.legend(['numerical scheme','analytical','dnn'])\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "51ee4433", + "metadata": { + "editable": true + }, + "source": [ + "## Partial Differential Equations\n", + "\n", + "A partial differential equation (PDE) has a solution here the function\n", + "is defined by multiple variables. The equation may involve all kinds\n", + "of combinations of which variables the function is differentiated with\n", + "respect to.\n", + "\n", + "In general, a partial differential equation for a function $g(x_1,\\dots,x_N)$ with $N$ variables may be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "1ec16aab", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{PDE} \\tag{17}\n", + " f\\left(x_1, \\, \\dots \\, , x_N, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1}, \\dots , \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_N}, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(x_1,\\dots,x_N) }{\\partial x_N^n} \\right) = 0\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "64fd215d", + "metadata": { + "editable": true + }, + "source": [ + "where $f$ is an expression involving all kinds of possible mixed derivatives of $g(x_1,\\dots,x_N)$ up to an order $n$. In order for the solution to be unique, some additional conditions must also be given." + ] + }, + { + "cell_type": "markdown", + "id": "3efab799", + "metadata": { + "editable": true + }, + "source": [ + "## Type of problem\n", + "\n", + "The problem our network must solve for, is similar to the ODE case.\n", + "We must have a trial solution $g_t$ at hand.\n", + "\n", + "For instance, the trial solution could be expressed as" + ] + }, + { + "cell_type": "markdown", + "id": "80e6d77c", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + " g_t(x_1,\\dots,x_N) = h_1(x_1,\\dots,x_N) + h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "f08a42bd", + "metadata": { + "editable": true + }, + "source": [ + "where $h_1(x_1,\\dots,x_N)$ is a function that ensures $g_t(x_1,\\dots,x_N)$ satisfies some given conditions.\n", + "The neural network $N(x_1,\\dots,x_N,P)$ has weights and biases described by $P$ and $h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))$ is an expression using the output from the neural network in some way.\n", + "\n", + "The role of the function $h_2(x_1,\\dots,x_N,N(x_1,\\dots,x_N,P))$, is to ensure that the output of $N(x_1,\\dots,x_N,P)$ is zero when $g_t(x_1,\\dots,x_N)$ is evaluated at the values of $x_1,\\dots,x_N$ where the given conditions must be satisfied. The function $h_1(x_1,\\dots,x_N)$ should alone make $g_t(x_1,\\dots,x_N)$ satisfy the conditions." + ] + }, + { + "cell_type": "markdown", + "id": "af035b50", + "metadata": { + "editable": true + }, + "source": [ + "## Network requirements\n", + "\n", + "The network tries then the minimize the cost function following the\n", + "same ideas as described for the ODE case, but now with more than one\n", + "variables to consider. The concept still remains the same; find a set\n", + "of parameters $P$ such that the expression $f$ in ([17](#PDE)) is as\n", + "close to zero as possible.\n", + "\n", + "As for the ODE case, the cost function is the mean squared error that\n", + "the network must try to minimize. The cost function for the network to\n", + "minimize is" + ] + }, + { + "cell_type": "markdown", + "id": "ee147dfb", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(x_1, \\dots, x_N, P\\right) = \\left( f\\left(x_1, \\, \\dots \\, , x_N, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1}, \\dots , \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_N}, \\frac{\\partial g(x_1,\\dots,x_N) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(x_1,\\dots,x_N) }{\\partial x_N^n} \\right) \\right)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "850e95ed", + "metadata": { + "editable": true + }, + "source": [ + "## More details\n", + "\n", + "If we let $\\boldsymbol{x} = \\big( x_1, \\dots, x_N \\big)$ be an array containing the values for $x_1, \\dots, x_N$ respectively, the cost function can be reformulated into the following:" + ] + }, + { + "cell_type": "markdown", + "id": "96f9cca4", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(\\boldsymbol{x}, P\\right) = f\\left( \\left( \\boldsymbol{x}, \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_1}, \\dots , \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_N}, \\frac{\\partial g(\\boldsymbol{x}) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(\\boldsymbol{x}) }{\\partial x_N^n} \\right) \\right)^2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "70394cae", + "metadata": { + "editable": true + }, + "source": [ + "If we also have $M$ different sets of values for $x_1, \\dots, x_N$, that is $\\boldsymbol{x}_i = \\big(x_1^{(i)}, \\dots, x_N^{(i)}\\big)$ for $i = 1,\\dots,M$ being the rows in matrix $X$, the cost function can be generalized into" + ] + }, + { + "cell_type": "markdown", + "id": "d06e6c30", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "C\\left(X, P \\right) = \\sum_{i=1}^M f\\left( \\left( \\boldsymbol{x}_i, \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_1}, \\dots , \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_N}, \\frac{\\partial g(\\boldsymbol{x}_i) }{\\partial x_1\\partial x_2}, \\, \\dots \\, , \\frac{\\partial^n g(\\boldsymbol{x}_i) }{\\partial x_N^n} \\right) \\right)^2.\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "b4972f88", + "metadata": { + "editable": true + }, + "source": [ + "## Example: The diffusion equation\n", + "\n", + "In one spatial dimension, the equation reads" + ] + }, + { + "cell_type": "markdown", + "id": "3d35cbd3", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial g(x,t)}{\\partial t} = \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "984bf645", + "metadata": { + "editable": true + }, + "source": [ + "where a possible choice of conditions are" + ] + }, + { + "cell_type": "markdown", + "id": "9d58d0ec", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "g(0,t) &= 0 ,\\qquad t \\geq 0 \\\\\n", + "g(1,t) &= 0, \\qquad t \\geq 0 \\\\\n", + "g(x,0) &= u(x),\\qquad x\\in [0,1]\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "99cf8f47", + "metadata": { + "editable": true + }, + "source": [ + "with $u(x)$ being some given function." + ] + }, + { + "cell_type": "markdown", + "id": "777ad3a8", + "metadata": { + "editable": true + }, + "source": [ + "## Defining the problem\n", + "\n", + "For this case, we want to find $g(x,t)$ such that" + ] + }, + { + "cell_type": "markdown", + "id": "7182b747", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation}\n", + " \\frac{\\partial g(x,t)}{\\partial t} = \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "\\end{equation} \\label{diffonedim} \\tag{18}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "3c40d528", + "metadata": { + "editable": true + }, + "source": [ + "and" + ] + }, + { + "cell_type": "markdown", + "id": "7cb1e15a", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "g(0,t) &= 0 ,\\qquad t \\geq 0 \\\\\n", + "g(1,t) &= 0, \\qquad t \\geq 0 \\\\\n", + "g(x,0) &= u(x),\\qquad x\\in [0,1]\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "5c4bcdb5", + "metadata": { + "editable": true + }, + "source": [ + "with $u(x) = \\sin(\\pi x)$.\n", + "\n", + "First, let us set up the deep neural network.\n", + "The deep neural network will follow the same structure as discussed in the examples solving the ODEs.\n", + "First, we will look into how Autograd could be used in a network tailored to solve for bivariate functions." + ] + }, + { + "cell_type": "markdown", + "id": "c84ff432", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd\n", + "\n", + "The only change to do here, is to extend our network such that\n", + "functions of multiple parameters are correctly handled. In this case\n", + "we have two variables in our function to solve for, that is time $t$\n", + "and position $x$. The variables will be represented by a\n", + "one-dimensional array in the program. The program will evaluate the\n", + "network at each possible pair $(x,t)$, given an array for the desired\n", + "$x$-values and $t$-values to approximate the solution at." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "ba62ab4c", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]" + ] + }, + { + "cell_type": "markdown", + "id": "7fd9e6dc", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd; The trial solution\n", + "\n", + "The cost function must then iterate through the given arrays\n", + "containing values for $x$ and $t$, defines a point $(x,t)$ the deep\n", + "neural network and the trial solution is evaluated at, and then finds\n", + "the Jacobian of the trial solution.\n", + "\n", + "A possible trial solution for this PDE is\n", + "\n", + "$$\n", + "g_t(x,t) = h_1(x,t) + x(1-x)tN(x,t,P)\n", + "$$\n", + "\n", + "with $A(x,t)$ being a function ensuring that $g_t(x,t)$ satisfies our given conditions, and $N(x,t,P)$ being the output from the deep neural network using weights and biases for each layer from $P$.\n", + "\n", + "To fulfill the conditions, $A(x,t)$ could be:\n", + "\n", + "$$\n", + "h_1(x,t) = (1-t)\\Big(u(x) - \\big((1-x)u(0) + x u(1)\\big)\\Big) = (1-t)u(x) = (1-t)\\sin(\\pi x)\n", + "$$\n", + "since $(0) = u(1) = 0$ and $u(x) = \\sin(\\pi x)$." + ] + }, + { + "cell_type": "markdown", + "id": "6c63c928", + "metadata": { + "editable": true + }, + "source": [ + "## Why the jacobian?\n", + "\n", + "The Jacobian is used because the program must find the derivative of\n", + "the trial solution with respect to $x$ and $t$.\n", + "\n", + "This gives the necessity of computing the Jacobian matrix, as we want\n", + "to evaluate the gradient with respect to $x$ and $t$ (note that the\n", + "Jacobian of a scalar-valued multivariate function is simply its\n", + "gradient).\n", + "\n", + "In Autograd, the differentiation is by default done with respect to\n", + "the first input argument of your Python function. Since the points is\n", + "an array representing $x$ and $t$, the Jacobian is calculated using\n", + "the values of $x$ and $t$.\n", + "\n", + "To find the second derivative with respect to $x$ and $t$, the\n", + "Jacobian can be found for the second time. The result is a Hessian\n", + "matrix, which is the matrix containing all the possible second order\n", + "mixed derivatives of $g(x,t)$." + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "4192bf3d", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Set up the trial function:\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point)\n", + "\n", + "# The right side of the ODE:\n", + "def f(point):\n", + " return 0.\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_jacobian_func = jacobian(g_trial)\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t = g_trial(point,P)\n", + " g_t_jacobian = g_t_jacobian_func(point,P)\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_dt = g_t_jacobian[1]\n", + " g_t_d2x = g_t_hessian[0][0]\n", + "\n", + " func = f(point)\n", + "\n", + " err_sqr = ( (g_t_dt - g_t_d2x) - func)**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum" + ] + }, + { + "cell_type": "markdown", + "id": "87f8417d", + "metadata": { + "editable": true + }, + "source": [ + "## Setting up the network using Autograd; The full program\n", + "\n", + "Having set up the network, along with the trial solution and cost function, we can now see how the deep neural network performs by comparing the results to the analytical solution.\n", + "\n", + "The analytical solution of our problem is\n", + "\n", + "$$\n", + "g(x,t) = \\exp(-\\pi^2 t)\\sin(\\pi x)\n", + "$$\n", + "\n", + "A possible way to implement a neural network solving the PDE, is given below.\n", + "Be aware, though, that it is fairly slow for the parameters used.\n", + "A better result is possible, but requires more iterations, and thus longer time to complete.\n", + "\n", + "Indeed, the program below is not optimal in its implementation, but rather serves as an example on how to implement and use a neural network to solve a PDE.\n", + "Using TensorFlow results in a much better execution time. Try it!" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "1572e93b", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import jacobian,hessian,grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import cm\n", + "from matplotlib import pyplot as plt\n", + "from mpl_toolkits.mplot3d import axes3d\n", + "\n", + "## Set up the network\n", + "\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]\n", + "\n", + "## Define the trial solution and cost function\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return (1-t)*u(x) + x*(1-x)*t*deep_neural_network(P,point)\n", + "\n", + "# The right side of the ODE:\n", + "def f(point):\n", + " return 0.\n", + "\n", + "# The cost function:\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_jacobian_func = jacobian(g_trial)\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t = g_trial(point,P)\n", + " g_t_jacobian = g_t_jacobian_func(point,P)\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_dt = g_t_jacobian[1]\n", + " g_t_d2x = g_t_hessian[0][0]\n", + "\n", + " func = f(point)\n", + "\n", + " err_sqr = ( (g_t_dt - g_t_d2x) - func)**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum /( np.size(x)*np.size(t) )\n", + "\n", + "## For comparison, define the analytical solution\n", + "def g_analytic(point):\n", + " x,t = point\n", + " return np.exp(-np.pi**2*t)*np.sin(np.pi*x)\n", + "\n", + "## Set up a function for training the network to solve for the equation\n", + "def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb):\n", + " ## Set up initial weigths and biases\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: ',cost_function(P, x, t))\n", + "\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " cost_grad = cost_function_grad(P, x , t)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_grad[l]\n", + "\n", + " print('Final cost: ',cost_function(P, x, t))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " ### Use the neural network:\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10; Nt = 10\n", + " x = np.linspace(0, 1, Nx)\n", + " t = np.linspace(0,1,Nt)\n", + "\n", + " ## Set up the parameters for the network\n", + " num_hidden_neurons = [100, 25]\n", + " num_iter = 250\n", + " lmb = 0.01\n", + "\n", + " P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " ## Store the results\n", + " g_dnn_ag = np.zeros((Nx, Nt))\n", + " G_analytical = np.zeros((Nx, Nt))\n", + " for i,x_ in enumerate(x):\n", + " for j, t_ in enumerate(t):\n", + " point = np.array([x_, t_])\n", + " g_dnn_ag[i,j] = g_trial(point,P)\n", + "\n", + " G_analytical[i,j] = g_analytic(point)\n", + "\n", + " # Find the map difference between the analytical and the computed solution\n", + " diff_ag = np.abs(g_dnn_ag - G_analytical)\n", + " print('Max absolute difference between the analytical solution and the network: %g'%np.max(diff_ag))\n", + "\n", + " ## Plot the solutions in two dimensions, that being in position and time\n", + "\n", + " T,X = np.meshgrid(t,x)\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons))\n", + " s = ax.plot_surface(T,X,g_dnn_ag,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Analytical solution')\n", + " s = ax.plot_surface(T,X,G_analytical,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Difference')\n", + " s = ax.plot_surface(T,X,diff_ag,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " ## Take some slices of the 3D plots just to see the solutions at particular times\n", + " indx1 = 0\n", + " indx2 = int(Nt/2)\n", + " indx3 = Nt-1\n", + "\n", + " t1 = t[indx1]\n", + " t2 = t[indx2]\n", + " t3 = t[indx3]\n", + "\n", + " # Slice the results from the DNN\n", + " res1 = g_dnn_ag[:,indx1]\n", + " res2 = g_dnn_ag[:,indx2]\n", + " res3 = g_dnn_ag[:,indx3]\n", + "\n", + " # Slice the analytical results\n", + " res_analytical1 = G_analytical[:,indx1]\n", + " res_analytical2 = G_analytical[:,indx2]\n", + " res_analytical3 = G_analytical[:,indx3]\n", + "\n", + " # Plot the slices\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t1)\n", + " plt.plot(x, res1)\n", + " plt.plot(x,res_analytical1)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t2)\n", + " plt.plot(x, res2)\n", + " plt.plot(x,res_analytical2)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t3)\n", + " plt.plot(x, res3)\n", + " plt.plot(x,res_analytical3)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "bf7afd74", + "metadata": { + "editable": true + }, + "source": [ + "## Example: Solving the wave equation with Neural Networks\n", + "\n", + "The wave equation is" + ] + }, + { + "cell_type": "markdown", + "id": "fdef78b2", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\frac{\\partial^2 g(x,t)}{\\partial t^2} = c^2\\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "be570613", + "metadata": { + "editable": true + }, + "source": [ + "with $c$ being the specified wave speed.\n", + "\n", + "Here, the chosen conditions are" + ] + }, + { + "cell_type": "markdown", + "id": "9f81e04f", + "metadata": { + "editable": true + }, + "source": [ + "$$\n", + "\\begin{align*}\n", + "\tg(0,t) &= 0 \\\\\n", + "\tg(1,t) &= 0 \\\\\n", + "\tg(x,0) &= u(x) \\\\\n", + "\t\\frac{\\partial g(x,t)}{\\partial t} \\Big |_{t = 0} &= v(x)\n", + "\\end{align*}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "91171d8b", + "metadata": { + "editable": true + }, + "source": [ + "where $\\frac{\\partial g(x,t)}{\\partial t} \\Big |_{t = 0}$ means the derivative of $g(x,t)$ with respect to $t$ is evaluated at $t = 0$, and $u(x)$ and $v(x)$ being given functions." + ] + }, + { + "cell_type": "markdown", + "id": "dbbbb8a5", + "metadata": { + "editable": true + }, + "source": [ + "## The problem to solve for\n", + "\n", + "The wave equation to solve for, is" + ] + }, + { + "cell_type": "markdown", + "id": "3f1be58e", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{equation} \\label{wave} \\tag{19}\n", + "\\frac{\\partial^2 g(x,t)}{\\partial t^2} = c^2 \\frac{\\partial^2 g(x,t)}{\\partial x^2}\n", + "\\end{equation}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "d54c4188", + "metadata": { + "editable": true + }, + "source": [ + "where $c$ is the given wave speed.\n", + "The chosen conditions for this equation are" + ] + }, + { + "cell_type": "markdown", + "id": "952c58e8", + "metadata": { + "editable": true + }, + "source": [ + "\n", + "
            \n", + "\n", + "$$\n", + "\\begin{aligned}\n", + "g(0,t) &= 0, &t \\geq 0 \\\\\n", + "g(1,t) &= 0, &t \\geq 0 \\\\\n", + "g(x,0) &= u(x), &x\\in[0,1] \\\\\n", + "\\frac{\\partial g(x,t)}{\\partial t}\\Big |_{t = 0} &= v(x), &x \\in [0,1]\n", + "\\end{aligned} \\label{condwave} \\tag{20}\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "a650bae2", + "metadata": { + "editable": true + }, + "source": [ + "In this example, let $c = 1$ and $u(x) = \\sin(\\pi x)$ and $v(x) = -\\pi\\sin(\\pi x)$." + ] + }, + { + "cell_type": "markdown", + "id": "9e0b8996", + "metadata": { + "editable": true + }, + "source": [ + "## The trial solution\n", + "Setting up the network is done in similar matter as for the example of solving the diffusion equation.\n", + "The only things we have to change, is the trial solution such that it satisfies the conditions from ([20](#condwave)) and the cost function.\n", + "\n", + "The trial solution becomes slightly different since we have other conditions than in the example of solving the diffusion equation. Here, a possible trial solution $g_t(x,t)$ is\n", + "\n", + "$$\n", + "g_t(x,t) = h_1(x,t) + x(1-x)t^2N(x,t,P)\n", + "$$\n", + "\n", + "where\n", + "\n", + "$$\n", + "h_1(x,t) = (1-t^2)u(x) + tv(x)\n", + "$$\n", + "\n", + "Note that this trial solution satisfies the conditions only if $u(0) = v(0) = u(1) = v(1) = 0$, which is the case in this example." + ] + }, + { + "cell_type": "markdown", + "id": "0f3f1985", + "metadata": { + "editable": true + }, + "source": [ + "## The analytical solution\n", + "\n", + "The analytical solution for our specific problem, is\n", + "\n", + "$$\n", + "g(x,t) = \\sin(\\pi x)\\cos(\\pi t) - \\sin(\\pi x)\\sin(\\pi t)\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "id": "fbd35329", + "metadata": { + "editable": true + }, + "source": [ + "## Solving the wave equation - the full program using Autograd" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "6ccf9344", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "import autograd.numpy as np\n", + "from autograd import hessian,grad\n", + "import autograd.numpy.random as npr\n", + "from matplotlib import cm\n", + "from matplotlib import pyplot as plt\n", + "from mpl_toolkits.mplot3d import axes3d\n", + "\n", + "## Set up the trial function:\n", + "def u(x):\n", + " return np.sin(np.pi*x)\n", + "\n", + "def v(x):\n", + " return -np.pi*np.sin(np.pi*x)\n", + "\n", + "def h1(point):\n", + " x,t = point\n", + " return (1 - t**2)*u(x) + t*v(x)\n", + "\n", + "def g_trial(point,P):\n", + " x,t = point\n", + " return h1(point) + x*(1-x)*t**2*deep_neural_network(P,point)\n", + "\n", + "## Define the cost function\n", + "def cost_function(P, x, t):\n", + " cost_sum = 0\n", + "\n", + " g_t_hessian_func = hessian(g_trial)\n", + "\n", + " for x_ in x:\n", + " for t_ in t:\n", + " point = np.array([x_,t_])\n", + "\n", + " g_t_hessian = g_t_hessian_func(point,P)\n", + "\n", + " g_t_d2x = g_t_hessian[0][0]\n", + " g_t_d2t = g_t_hessian[1][1]\n", + "\n", + " err_sqr = ( (g_t_d2t - g_t_d2x) )**2\n", + " cost_sum += err_sqr\n", + "\n", + " return cost_sum / (np.size(t) * np.size(x))\n", + "\n", + "## The neural network\n", + "def sigmoid(z):\n", + " return 1/(1 + np.exp(-z))\n", + "\n", + "def deep_neural_network(deep_params, x):\n", + " # x is now a point and a 1D numpy array; make it a column vector\n", + " num_coordinates = np.size(x,0)\n", + " x = x.reshape(num_coordinates,-1)\n", + "\n", + " num_points = np.size(x,1)\n", + "\n", + " # N_hidden is the number of hidden layers\n", + " N_hidden = len(deep_params) - 1 # -1 since params consist of parameters to all the hidden layers AND the output layer\n", + "\n", + " # Assume that the input layer does nothing to the input x\n", + " x_input = x\n", + " x_prev = x_input\n", + "\n", + " ## Hidden layers:\n", + "\n", + " for l in range(N_hidden):\n", + " # From the list of parameters P; find the correct weigths and bias for this layer\n", + " w_hidden = deep_params[l]\n", + "\n", + " # Add a row of ones to include bias\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev ), axis = 0)\n", + "\n", + " z_hidden = np.matmul(w_hidden, x_prev)\n", + " x_hidden = sigmoid(z_hidden)\n", + "\n", + " # Update x_prev such that next layer can use the output from this layer\n", + " x_prev = x_hidden\n", + "\n", + " ## Output layer:\n", + "\n", + " # Get the weights and bias for this layer\n", + " w_output = deep_params[-1]\n", + "\n", + " # Include bias:\n", + " x_prev = np.concatenate((np.ones((1,num_points)), x_prev), axis = 0)\n", + "\n", + " z_output = np.matmul(w_output, x_prev)\n", + " x_output = z_output\n", + "\n", + " return x_output[0][0]\n", + "\n", + "## The analytical solution\n", + "def g_analytic(point):\n", + " x,t = point\n", + " return np.sin(np.pi*x)*np.cos(np.pi*t) - np.sin(np.pi*x)*np.sin(np.pi*t)\n", + "\n", + "def solve_pde_deep_neural_network(x,t, num_neurons, num_iter, lmb):\n", + " ## Set up initial weigths and biases\n", + " N_hidden = np.size(num_neurons)\n", + "\n", + " ## Set up initial weigths and biases\n", + "\n", + " # Initialize the list of parameters:\n", + " P = [None]*(N_hidden + 1) # + 1 to include the output layer\n", + "\n", + " P[0] = npr.randn(num_neurons[0], 2 + 1 ) # 2 since we have two points, +1 to include bias\n", + " for l in range(1,N_hidden):\n", + " P[l] = npr.randn(num_neurons[l], num_neurons[l-1] + 1) # +1 to include bias\n", + "\n", + " # For the output layer\n", + " P[-1] = npr.randn(1, num_neurons[-1] + 1 ) # +1 since bias is included\n", + "\n", + " print('Initial cost: ',cost_function(P, x, t))\n", + "\n", + " cost_function_grad = grad(cost_function,0)\n", + "\n", + " # Let the update be done num_iter times\n", + " for i in range(num_iter):\n", + " cost_grad = cost_function_grad(P, x , t)\n", + "\n", + " for l in range(N_hidden+1):\n", + " P[l] = P[l] - lmb * cost_grad[l]\n", + "\n", + "\n", + " print('Final cost: ',cost_function(P, x, t))\n", + "\n", + " return P\n", + "\n", + "if __name__ == '__main__':\n", + " ### Use the neural network:\n", + " npr.seed(15)\n", + "\n", + " ## Decide the vales of arguments to the function to solve\n", + " Nx = 10; Nt = 10\n", + " x = np.linspace(0, 1, Nx)\n", + " t = np.linspace(0,1,Nt)\n", + "\n", + " ## Set up the parameters for the network\n", + " num_hidden_neurons = [50,20]\n", + " num_iter = 1000\n", + " lmb = 0.01\n", + "\n", + " P = solve_pde_deep_neural_network(x,t, num_hidden_neurons, num_iter, lmb)\n", + "\n", + " ## Store the results\n", + " res = np.zeros((Nx, Nt))\n", + " res_analytical = np.zeros((Nx, Nt))\n", + " for i,x_ in enumerate(x):\n", + " for j, t_ in enumerate(t):\n", + " point = np.array([x_, t_])\n", + " res[i,j] = g_trial(point,P)\n", + "\n", + " res_analytical[i,j] = g_analytic(point)\n", + "\n", + " diff = np.abs(res - res_analytical)\n", + " print(\"Max difference between analytical and solution from nn: %g\"%np.max(diff))\n", + "\n", + " ## Plot the solutions in two dimensions, that being in position and time\n", + "\n", + " T,X = np.meshgrid(t,x)\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Solution from the deep neural network w/ %d layer'%len(num_hidden_neurons))\n", + " s = ax.plot_surface(T,X,res,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Analytical solution')\n", + " s = ax.plot_surface(T,X,res_analytical,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + "\n", + " fig = plt.figure(figsize=(10,10))\n", + " ax = fig.add_suplot(projection='3d')\n", + " ax.set_title('Difference')\n", + " s = ax.plot_surface(T,X,diff,linewidth=0,antialiased=False,cmap=cm.viridis)\n", + " ax.set_xlabel('Time $t$')\n", + " ax.set_ylabel('Position $x$');\n", + "\n", + " ## Take some slices of the 3D plots just to see the solutions at particular times\n", + " indx1 = 0\n", + " indx2 = int(Nt/2)\n", + " indx3 = Nt-1\n", + "\n", + " t1 = t[indx1]\n", + " t2 = t[indx2]\n", + " t3 = t[indx3]\n", + "\n", + " # Slice the results from the DNN\n", + " res1 = res[:,indx1]\n", + " res2 = res[:,indx2]\n", + " res3 = res[:,indx3]\n", + "\n", + " # Slice the analytical results\n", + " res_analytical1 = res_analytical[:,indx1]\n", + " res_analytical2 = res_analytical[:,indx2]\n", + " res_analytical3 = res_analytical[:,indx3]\n", + "\n", + " # Plot the slices\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t1)\n", + " plt.plot(x, res1)\n", + " plt.plot(x,res_analytical1)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t2)\n", + " plt.plot(x, res2)\n", + " plt.plot(x,res_analytical2)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.figure(figsize=(10,10))\n", + " plt.title(\"Computed solutions at time = %g\"%t3)\n", + " plt.plot(x, res3)\n", + " plt.plot(x,res_analytical3)\n", + " plt.legend(['dnn','analytical'])\n", + "\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "id": "988e09cf", + "metadata": { + "editable": true + }, + "source": [ + "## Resources on differential equations and deep learning\n", + "\n", + "1. [Artificial neural networks for solving ordinary and partial differential equations by I.E. Lagaris et al](https://pdfs.semanticscholar.org/d061/df393e0e8fbfd0ea24976458b7d42419040d.pdf)\n", + "\n", + "2. [Neural networks for solving differential equations by A. Honchar](https://becominghuman.ai/neural-networks-for-solving-differential-equations-fa230ac5e04c)\n", + "\n", + "3. [Solving differential equations using neural networks by M.M Chiaramonte and M. Kiener](http://cs229.stanford.edu/proj2013/ChiaramonteKiener-SolvingDifferentialEquationsUsingNeuralNetworks.pdf)\n", + "\n", + "4. [Introduction to Partial Differential Equations by A. Tveito, R. Winther](https://www.springer.com/us/book/9783540225515)" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/doc/LectureNotes/_build/html/chapter1.html b/doc/LectureNotes/_build/html/chapter1.html index 97d9d2466..d8a8b2f91 100644 --- a/doc/LectureNotes/_build/html/chapter1.html +++ b/doc/LectureNotes/_build/html/chapter1.html @@ -257,6 +257,9 @@ +
          7. Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
          8. +
          9. Exercises week 43
          10. +

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

            Projects

    next

    -

    Project 1 on Machine Learning, deadline October 6 (midnight), 2025

    +

    Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations

    diff --git a/doc/LectureNotes/_build/html/exercisesweek43.html b/doc/LectureNotes/_build/html/exercisesweek43.html new file mode 100644 index 000000000..8d4bd1b6b --- /dev/null +++ b/doc/LectureNotes/_build/html/exercisesweek43.html @@ -0,0 +1,846 @@ + + + + + + + + + + + Exercises week 43 — Applied Data Analysis and Machine Learning + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    +
    +
    +
    +
    + +
    + +
    + + + + + +
    +
    + + + +
    + + + + + + + + + + + + + +
    + +
    + + + +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + + +
    + +
    + +
    + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    +
    + + + + + + + + +
    + + +
    +

    Exercises week 43#

    +

    October 20-24, 2025

    +

    Date: Deadline Friday October 24 at midnight

    +
    +
    +

    Overarching aims of the exercises weeks 43 and 44#

    +

    The aim of the exercises this week is to gain some confidence with +ways to visualize the results of a classification problem. We will +target three ways of setting up the analysis. The first and simplest +one is the

    +
      +
    1. so-called confusion matrix, and the next is the

    2. +
    3. ROC curve and finally the

    4. +
    5. Cumulative gain curve.

    6. +
    +

    We will use Logistic Regression as method for the classification in +this exercise. You can compare these results with those obtained with +your neural network code from project 2 without a hidden layer.

    +

    In these exercises we will use binary and multi-class data sets +(the Iris data set from week 41).

    +

    The underlying mathematics is described here.

    +
    +

    Confusion Matrix#

    +

    A confusion matrix summarizes a classifier’s performance by +tabulating predictions versus true labels. For binary classification, +it is a \(2\times2\) table whose entries are counts of outcomes:

    +
    +\[\begin{split} +\begin{array}{l|cc} & \text{Predicted Positive} & \text{Predicted Negative} \\ \hline \text{Actual Positive} & TP & FN \\ \text{Actual Negative} & FP & TN \end{array}. +\end{split}\]
    +

    Here TP (true positives) is the number of cases correctly predicted as +positive, FP (false positives) is the number incorrectly predicted as +positive, TN (true negatives) is correctly predicted negative, and FN +(false negatives) is incorrectly predicted negative . In other words, +“positive” means class 1 and “negative” means class 0; for example, TP +occurs when the prediction and actual are both positive. Formally:

    +
    +\[ +\text{TPR} = \frac{\text{TP}}{\text{TP} + \text{FN}}, \quad \text{FPR} = \frac{\text{FP}}{\text{FP} + \text{TN}}, +\]
    +

    where TPR and FPR are the true and false positive rates defined below.

    +

    In multiclass classification with \(K\) classes, the confusion matrix +generalizes to a \(K\times K\) table. Entry \(N_{ij}\) in the table is +the count of instances whose true class is \(i\) and whose predicted +class is \(j\). For example, a three-class confusion matrix can be written +as:

    +
    +\[\begin{split} +\begin{array}{c|ccc} & \text{Pred Class 1} & \text{Pred Class 2} & \text{Pred Class 3} \\ \hline \text{Act Class 1} & N_{11} & N_{12} & N_{13} \\ \text{Act Class 2} & N_{21} & N_{22} & N_{23} \\ \text{Act Class 3} & N_{31} & N_{32} & N_{33} \end{array}. +\end{split}\]
    +

    Here the diagonal entries \(N_{ii}\) are the true positives for each +class, and off-diagonal entries are misclassifications. This matrix +allows computation of per-class metrics: e.g. for class \(i\), +\(\mathrm{TP}_i=N_{ii}\), \(\mathrm{FN}_i=\sum_{j\neq i}N_{ij}\), +\(\mathrm{FP}_i=\sum_{j\neq i}N_{ji}\), and \(\mathrm{TN}_i\) is the sum of +all remaining entries.

    +

    As defined above, TPR and FPR come from the binary case. In binary +terms with \(P\) actual positives and \(N\) actual negatives, one has

    +
    +\[ +\text{TPR} = \frac{TP}{P} = \frac{TP}{TP+FN}, \quad \text{FPR} = +\frac{FP}{N} = \frac{FP}{FP+TN}, +\]
    +

    as used in standard confusion-matrix +formulations. These rates will be used in constructing ROC curves.

    +
    +
    +

    ROC Curve#

    +

    The Receiver Operating Characteristic (ROC) curve plots the trade-off +between true positives and false positives as a discrimination +threshold varies. Specifically, for a binary classifier that outputs +a score or probability, one varies the threshold \(t\) for declaring +positive, and computes at each \(t\) the true positive rate +\(\mathrm{TPR}(t)\) and false positive rate \(\mathrm{FPR}(t)\) using the +confusion matrix at that threshold. The ROC curve is then the graph +of TPR versus FPR. By definition,

    +
    +\[ +\mathrm{TPR} = \frac{TP}{TP+FN}, \qquad \mathrm{FPR} = \frac{FP}{FP+TN}, +\]
    +

    where \(TP,FP,TN,FN\) are counts determined by threshold \(t\). A perfect +classifier would reach the point (FPR=0, TPR=1) at some threshold.

    +

    Formally, the ROC curve is obtained by plotting +\((\mathrm{FPR}(t),\mathrm{TPR}(t))\) for all \(t\in[0,1]\) (or as \(t\) +sweeps through the sorted scores). The Area Under the ROC Curve (AUC) +quantifies the average performance over all thresholds. It can be +interpreted probabilistically: \(\mathrm{AUC} = +\Pr\bigl(s(X^+)>s(X^-)\bigr)\), the probability that a random positive +instance \(X^+\) receives a higher score \(s\) than a random negative +instance \(X^-\) . Equivalently, the AUC is the integral under the ROC +curve:

    +
    +\[ +\mathrm{AUC} \;=\; \int_{0}^{1} \mathrm{TPR}(f)\,df, +\]
    +

    where \(f\) ranges over FPR (or fraction of negatives). A model that guesses at random yields a diagonal ROC (AUC=0.5), whereas a perfect model yields AUC=1.0.

    +
    +
    +

    Cumulative Gain#

    +

    The cumulative gain curve (or gains chart) evaluates how many +positives are captured as one targets an increasing fraction of the +population, sorted by model confidence. To construct it, sort all +instances by decreasing predicted probability of the positive class. +Then, for the top \(\alpha\) fraction of instances, compute the fraction +of all actual positives that fall in this subset. In formula form, if +\(P\) is the total number of positive instances and \(P(\alpha)\) is the +number of positives among the top \(\alpha\) of the data, the cumulative +gain at level \(\alpha\) is

    +
    +\[ +\mathrm{Gain}(\alpha) \;=\; \frac{P(\alpha)}{P}. +\]
    +

    For example, cutting off at the top 10% of predictions yields a gain +equal to (positives in top 10%) divided by (total positives) . +Plotting \(\mathrm{Gain}(\alpha)\) versus \(\alpha\) (often in percent) +gives the gain curve. The baseline (random) curve is the diagonal +\(\mathrm{Gain}(\alpha)=\alpha\), while an ideal model has a steep climb +toward 1.

    +

    A related measure is the {\em lift}, often called the gain ratio. It is the ratio of the model’s capture rate to that of random selection. Equivalently,

    +
    +\[ +\mathrm{Lift}(\alpha) \;=\; \frac{\mathrm{Gain}(\alpha)}{\alpha}. +\]
    +

    A lift \(>1\) indicates better-than-random targeting. In practice, gain +and lift charts (used e.g.\ in marketing or imbalanced classification) +show how many positives can be “gained” by focusing on a fraction of +the population .

    +
    +
    +

    Other measures: Precision, Recall, and the F\(_1\) Measure#

    +

    Precision and recall (sensitivity) quantify binary classification +accuracy in terms of positive predictions. They are defined from the +confusion matrix as:

    +
    +\[ +\text{Precision} = \frac{TP}{TP + FP}, \qquad \text{Recall} = \frac{TP}{TP + FN}. +\]
    +

    Precision is the fraction of predicted positives that are correct, and +recall is the fraction of actual positives that are correctly +identified . A high-precision classifier makes few false-positive +errors, while a high-recall classifier makes few false-negative +errors.

    +

    The F\(_1\) score (balanced F-measure) combines precision and recall into a single metric via their harmonic mean. The usual formula is:

    +
    +\[ +F_1 =2\frac{\text{Precision}\times\text{Recall}}{\text{Precision} + \text{Recall}}. +\]
    +

    This can be shown to equal

    +
    +\[ +\frac{2\,TP}{2\,TP + FP + FN}. +\]
    +

    The F\(_1\) score ranges from 0 (worst) to 1 (best), and balances the +trade-off between precision and recall.

    +

    For multi-class classification, one computes per-class +precision/recall/F\(_1\) (treating each class as “positive” in a +one-vs-rest manner) and then averages. Common averaging methods are:

    +

    Micro-averaging: Sum all true positives, false positives, and false negatives across classes, then compute precision/recall/F\(_1\) from these totals. +Macro-averaging: Compute the F\(1\) score \(F{1,i}\) for each class \(i\) separately, then take the unweighted mean: \(F_{1,\mathrm{macro}} = \frac{1}{K}\sum_{i=1}^K F_{1,i}\) . This treats all classes equally regardless of size. +Weighted-averaging: Like macro-average, but weight each class’s \(F_{1,i}\) by its support \(n_i\) (true count): \(F_{1,\mathrm{weighted}} = \frac{1}{N}\sum_{i=1}^K n_i F_{1,i}\), where \(N=\sum_i n_i\). This accounts for class imbalance by giving more weight to larger classes .

    +

    Each of these averages has different use-cases. Micro-average is +dominated by common classes, macro-average highlights performance on +rare classes, and weighted-average is a compromise. These formulas +and concepts allow rigorous evaluation of classifier performance in +both binary and multi-class settings.

    +
    +
    +

    Exercises#

    +

    Here is a simple code example which uses the Logistic regression machinery from scikit-learn. +At the end it sets up the confusion matrix and the ROC and cumulative gain curves. +Feel free to use these functionalities (we don’t expect you to write your own code for say the confusion matrix).

    +
    +
    +
    %matplotlib inline
    +
    +import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import  train_test_split 
    +# from sklearn.datasets import fill in the data set
    +from sklearn.linear_model import LogisticRegression
    +
    +# Load the data, fill inn
    +mydata.data = ?
    +
    +X_train, X_test, y_train, y_test = train_test_split(mydata.data,cancer.target,random_state=0)
    +print(X_train.shape)
    +print(X_test.shape)
    +# Logistic Regression
    +# define which type of problem, binary or multiclass
    +logreg = LogisticRegression(solver='lbfgs')
    +logreg.fit(X_train, y_train)
    +
    +from sklearn.preprocessing import LabelEncoder
    +from sklearn.model_selection import cross_validate
    +#Cross validation
    +accuracy = cross_validate(logreg,X_test,y_test,cv=10)['test_score']
    +print(accuracy)
    +print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
    +
    +import scikitplot as skplt
    +y_pred = logreg.predict(X_test)
    +skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
    +plt.show()
    +y_probas = logreg.predict_proba(X_test)
    +skplt.metrics.plot_roc(y_test, y_probas)
    +plt.show()
    +skplt.metrics.plot_cumulative_gain(y_test, y_probas)
    +plt.show()
    +
    +
    +
    +
    +
    +

    Exercise a)#

    +

    Convince yourself about the mathematics for the confusion matrix, the ROC and the cumlative gain curves for both a binary and a multiclass classification problem.

    +
    +
    +

    Exercise b)#

    +

    Use a binary classification data available from scikit-learn. As an example you can use +the MNIST data set and just specialize to two numbers. To do so you can use the following code lines

    +
    +
    +
    from sklearn.datasets import load_digits
    +digits = load_digits(n_class=2) # Load only two classes, e.g., 0 and 1
    +X, y = digits.data, digits.target
    +
    +
    +
    +
    +

    Alternatively, you can use the make\(\_\)classification +functionality. This function generates a random \(n\)-class classification +dataset, which can be configured for binary classification by setting +n_classes=2. You can also control the number of samples, features, +informative features, redundant features, and more.

    +
    +
    +
    from sklearn.datasets import make_classification
    +X, y = make_classification(n_samples=1000, n_features=20, n_informative=10, n_redundant=5, n_classes=2, random_state=42)
    +
    +
    +
    +
    +

    You can use this option for the multiclass case as well, see the next exercise. +If you prefer to study other binary classification datasets, feel free +to replace the above suggestions with your own dataset.

    +

    Make plots of the confusion matrix, the ROC curve and the cumulative gain curve.

    +
    +
    +

    Exercise c) week 43#

    +

    As a multiclass problem, we will use the Iris data set discussed in +the exercises from weeks 41 and 42. This is a three-class data set and +you can set it up using scikit-learn,

    +
    +
    +
    from sklearn.datasets import load_iris
    +iris = load_iris()
    +X = iris.data  # Features
    +y = iris.target # Target labels
    +
    +
    +
    +
    +

    Make plots of the confusion matrix, the ROC curve and the cumulative +gain curve for this (or other) multiclass data set.

    +
    +
    +
    + + + + +
    + + + + + + + + +
    + + + + + + +
    +
    + + +
    + + +
    +
    +
    + + + + + +
    +
    + + \ No newline at end of file diff --git a/doc/LectureNotes/_build/html/genindex.html b/doc/LectureNotes/_build/html/genindex.html index 9d1273c53..e62a52710 100644 --- a/doc/LectureNotes/_build/html/genindex.html +++ b/doc/LectureNotes/_build/html/genindex.html @@ -254,6 +254,9 @@ +
  • Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
  • +
  • Exercises week 43
  • +

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects

    Projects