$25
Exercise 1: Designing a Neural Network (25 P)
We would like to implement a neural network that classifies data points in R2 according to decision boundary given in the figure below.
We consider as an elementary computation the threshold neuron whose relation between inputs (ai)i and output aj is given by
zj = Pi aiwij + bj aj = 1zj>0.
(a) Design at hand a neural network that takes x1 and x2 as input and produces the output “1” if the input belongs to class A, and “0” if the input belongs to class B. Draw the neural network model and write down the weights wij and bias bj of each neuron.
Exercise 2: Backward Propagation (5+20 P)
We consider a neural network that takes two inputs x1 and x2 and produces an output y based on the following set of computations:
z3 = x1 · w13 + x2 · w23 z5 = a3 · w35 + a4 · w45 y = a5 + a6
a3 = tanh(z3) a5 = tanh(z5)
z4 = x1 · w14 + x2 · w24 z6 = a3 · w36 + a4 · w46
a4 = tanh(z4) a6 = tanh(z6)
(a) Draw the neural network graph associated to this set of computations.
(b) Write the set of backward computations that leads to the evaluation of the partial derivative ∂y/∂w13. Your answer should avoid redundant computations. Hint: tanh0(t) = 1 − (tanh(t))2.
Exercise 3: Programming (50 P)
Download the programming files on ISIS and follow the instructions.
Training a Neural Network
In this homework, our objective is to implement a simple neural network from scratch, in particular, error backpropagation and the gradient descent optimization procedure. We first import some useful libraries.
function in two dimensions. We denote our two inputs as x1 and x2 and use the suffix d and g to designate the actual dataset and the grid dataset.
Part 1: Implementing Error Backpropagation (30 P)
: zj = x1w1j + x2w2j + bj
∀25j=1: aj = max where x_1,x_2 are the two input variables and y is the We would like to implement the neural network with the equations: output of the network. The parameters of the neural network are initialized randomly using the normal distributions w_{ij} \sim \mathcal{N} (\mu=0,\sigma^2=1/2), b_{j} \sim \mathcal{N}(\mu=0,\sigma^2=1), v_{j} \sim \mathcal{N}(\mu=0,\sigma^2=1/25). The following code initializes the parameters of the network and implements the forward pass defined above. The neural network is composed of 50 neurons.
\max(0,-y^{(k)} t^{(k)}) where N is the number of data points, y is the output of the network and t is the label.
Task:
Complete the function below so that it returns the gradient of the error w.r.t. the parameters of the model.
Exercise 2: Training with Gradient Descent (20 P)
We would like to use error backpropagation to optimize the parameters of the neural network. The code below optimizes the network for 128 iterations and at some chosen iterations plots the decision function along with the current error.
Task:
Complete the procedure above to perform at each iteration a step along the gradient in the parameter space. A good choice of learning rate is \eta=0.1.