Exercise "Artificial Neural Networks"

  1. (6 points)

    In this exercise we construct a simplest artificial neural network which will be trained to interpolate a tabulated function.

    It is an ordinary three-layer neural network with one neuron in the input layer, several neurons in the hidden layer, and one neuron in the output layer,

                               [hidden neuron]
                              /               \
                             /                 \
                            /                   \
    x  --->[identity neuron]---[hidden neuron]---[summation neuron]--->  y=F(x)
                            \                   /  
                             \                 /  
                              \               /  
                               [hidden neuron]
    

    The input neuron is an identity neuron: it simply sends the input, a real number x, to all hidden neurons.

    The output neuron is a summation neuron: it sums the outputs of the hidden neurons and sends the result to the output.

    The hidden neurons are ordinary neurons: the neuron number i transforms its input signal, x, into the its output signal, y, as

    y=f((x-ai)/bi)*wi,

    where f is the activation function (the same for all hidden neurons) and where ai, bi, wi are the parameters of the neuron number i.

    The activation function can be

    or any another suitable function.

    The whole network then functions as one big non-linear multi-parameter function y=Fp(x), where p={ai,bi,wi}i=1..n is the set of parameters of the network.

    Given the tabulated function, {xk,yk}k=1..N, the training of the network consists of tuning its parameters to minimize the deviation

    δ(p)=∑k=1..N(Fp(xk)-yk,

    which amounts to minimization of the deviation δ(p) in the space of the parameters of the network. This minimization can be done with your own minimization routine.

    A class to keep this network could be in the form

    class ann {
    	int n; /* number of hidden neurons */
    	Func<double,double> f; /* activation function */
    	vector params; /* network parameters */
    	double feedforwad(double x); /* apply the network to imput parameter x */
    	void train(vector x,vector y); /* train to interpolate the given table {x,y} */
    	}
    
  2. (3 points) Modify the previous exercise such that the network, after training, could also approximate the derivative and the anti-derivative of the tabulated function.

  3. (1 point) Implement an artificial neural network that can be trained to approximate a solution to the differential equation

    Φ[y(x)]≡Φ(y'',y',y,x)=0,

    (where Φ is generally a non-linear function of its arguments) on an interval [a,b] with the boundary condition at a given point 'c',

    y(c)=yc, y'(c)=y'c,

    where c∈[a,b] and yc and y'c are given numbers.

    The cost function to minimize might be

    δ(p)=∫ab|Φ[Fp,x]|dx +|Fp(c)-yc|(b-a) +|Fp'(c)-y'c|(b-a) .

    or

    δ(p)=∫ab|Φ[Fp,x]|²dx +|Fp(c)-yc|²(b-a) +|Fp'(c)-y'c|²(b-a) .