Aerospace and Mechanical Engineering

Homework 8

B. Goodwine
Spring, 1999 |
Issued: April 14, 1999 Due: April 21, 1999 |

**Note:** do either

- problems 1 through 5,
**or** - problems 1 and 6 only.

- (0 points) Download and compile the sample neural network code which is like
what was distributed in class. To compile it, type
gcc -o neural neural.c -lm

and the resulting executable will be called`neural`

.When run,

`neural`

will train a neural network to approximate the sine function, and plot a comparison of the network output and the actual sine function values. The program should automatically display a graph that looks like this:The default values are for the network to have 10

`HIDDEN`

nodes in one hidden layer, and to train for 20000`ITERATIONS`

. These parameters are defined near the top of the code.Notes:

- As written, this code must be run on a Sun workstation.
- To run it in Linux, you must remove the
definition of
`MAX_RAND`

, and replace every other occurrence of`MAX_RAND`

with`RAND_MAX`

. - I have no idea how to run it in Windows 95, 98 or NT.

- 10
`HIDDEN`

nodes is actually too many. Reduce the number of hidden nodes to try to determine the effect of having fewer nodes.In particular, answer the following questions (10 points each).

- What is the effect of reducing the number of hidden nodes?
- Does there appear to be a minimum number of hidden nodes for the network to satisfactorily approximate the sine function?
- What, if any, appears to be the relationship between the
number of hidden nodes and the amount of training
(
*i.e.*the number of`ITERATIONS`

, required? - What seems to be the optimal number of
`HIDDEN`

nodes,*i.e.*the smallest number that adequately approximates the function and does not require a very long time to train?

- (5 points) Near the end of the code is a section that
prints the output of the neural network and the sine function to
a file called "network.m." Change the range of the
`for`

loop so that several periods of the sine function are plotted to verify that the network only approximates the function well around the points on which it was trained. - (25 points) Modify the network, and training data points, if necessary, so that the network adequately approximates the sine function for at least two complete periods.
- (20 points) Determine the
*minimum number*of data points needed to train the network to adequately approximate the sine function for at least two complete periods. Note that the location of the data points may have a substantial effect.

- (90 points) Use the sample code as a skeleton to create a
neural network to approximate an
*unknown*function. Possible examples include:- predicting the weather,
- predicting the stock market,
- predicting the outcome of sporting events,
*etc*.

*prior*approval from the instructor. Also, be careful to pick a problem for which you can obtain data that is easily quantifiable. (Some stock market data is available from the instructor).

B. Goodwine (