Loading [MathJax]/extensions/TeX/boldsymbol.js

 

 

 

Exercise 2: Extended program

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

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

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

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

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

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