|
6.2.3 Function Approximation in Two Dimensions
It is easy to approximate functions with several inputs in the same way as with single input functions. A simple example with two inputs is shown here.
Read in the Neural Networks package.
In[1]:=
Generate data and look at the function.
In[2]:=

You can modify the example by changing the function generating the data and by changing the number of neuron basis functions in the following initialization. Notice that you will obtain slightly different results if you repeat the example without any changes at all. This is due to the randomness in the RBF initialization, described in the algorithm for RBF network initialization.
Initialize an RBF network with two neurons.
In[8]:=
Out[8]=
You can apply the initialized network to the input data and plot the network output. Compare the result with the true function in the previous plot.
Look at the initialized RBF network.
In[9]:=

So far the network has only been initialized. Now it is time to train it.
Fit the RBF network to the data.
In[11]:=

Normally, there are several local minima; therefore, if you repeat the initialization and the training, you can expect to obtain different results.
You can use NetPlot to illustrate the trained RBF network over the data range.
Look at the result with the fitted RBF network.
In[12]:=

This plot shows the function approximation after the eight iterations of training. NetPlot may also be applied to the training record to obtain a graphics array of function estimates at specified iteration intervals, as shown here.
In[13]:=

If you prefer, the progress can be animated as described in Section 5.2.1, Function Approximation in One Dimension, instead of being given in a graphics array.
With the option DataFormat ErrorDistribution, you can obtain a histogram showing the distribution of the approximation errors.
In[14]:=

|