0% found this document useful (0 votes)
57 views7 pages

CI Labw5

COM907M1 laboratory session: week 5 Use of Neural network toolbox GUI and Creating NN subsystems. In what follows you bring up the GUI Network / Data Manager. This window has its own work area. When using GUI, you need to export the GUI results to workspace. Similarly, you can import results from the command line workspace to GUI.

Uploaded by

loebid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views7 pages

CI Labw5

COM907M1 laboratory session: week 5 Use of Neural network toolbox GUI and Creating NN subsystems. In what follows you bring up the GUI Network / Data Manager. This window has its own work area. When using GUI, you need to export the GUI results to workspace. Similarly, you can import results from the command line workspace to GUI.

Uploaded by

loebid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Computational Intelligence COM907M1 Laboratory Session: week 5 Use of Neural Network Toolbox GUI and Creating NN Subsystems

Neural network GUI is designed to be simple and user friendly. In what follows you bring up the GUI Network/Data Manager. This window has its own work area. When using GUI, you need to export the GUI results to workspace. Similarly, you can import results from the command line workspace to GUI. Once the network/data manager is up and running, you can create a network, view it, train it, simulate it and export the final results to the workspace. Exercise 1: Use of Neural Network Toolbox GUI To start, type nntool at the command line and it will bring the network/data manager shown in Figure 1. >> nntool The following Network/Data Manager appears on the screen

Figure 1: Network/Data Manager

Define network input/output Click on New Data, new window Create New Data appears

Figure 2: Create New Data Set the name data1 and enter the values as shown. Make sure that Data Type is set to Inputs. Similarly, specify the output data. Create Network Click on New Network, new window Create New Network appears

Figure 3: Create New Network Enter a name for network in the Network Name field

Choose network type from the pull down menu Specify input ranges Select learning algorithm from pull down menu e.g. trainlm, traingd (see handout of week 4) Choose performance function such as sum of squared error. Specify number of layers in the network and Specify number of neurons in each layer and transfer function for the layer. (for details of Neural networks architecture, see handout of week 4) Once the architecture is defined, you can view the network by clicking on the View. It will show the architecture of the network defined above as Figure 4.

Figure 4: Network architecture Training Network To train the network, click on the name of the network to highlight it. This leads to a new window labelled Networks: Name of network. At this point you can view the network again by clicking the top tab Train. You can also check on the initialisation by clicking on top tab Initialize. Specify the inputs and outputs by clicking on the left tab Training Info and selecting data1 from the pop-down list of inputs and t from the pull-down list of targets.

Importing from Command line To make things simple, create a new data set, e.g vector R, and then import it. Click on Import and set the destination Name to R and then click Import and verify by looking at the Network/Data Manager as shown in Figure 5.

Figure 5: Import or Load Network/Data manager. Exercise 2: Creating Blocks and Subsystems for use in Simulink Neural Network Toolbox provides a set of blocks you can use to build neural networks in Simulinks or which can be used by the function gensim to generate the simkulink version of any neural network that has created in MATLAB. To bring up the block set, type neural at command prompt >>neural Window appears with these blocks shown in Figure 6. Each of these blocks contains additional blocks. Double-clicking on the transfer function block will bring up a window containing several transfer function blocks.

Figure 6: Neural window with block sets Using these blocks, you can create your own defined neural networks. An example of a simple neural network consists of two hidden neurons with sigmoid activation function and a single output neuron with linear activation function is shown in Figure 7.

0.5 w3
w

0.9 w2
2 p1

w z p p

dotprod1

tansig

dotprod3 netsum
w

w z p

dotprod5

purelin

Scope

z z p

0.6 w1
4 p2

dotprod2

tansig1

dotprod4

Figure 7: Two-layered NN created using neural blocks. You can create a subsystems by selecting blocks, dashed-line box in Figure 7, and choosing option Create Subsystem under Edit menu which looks like block shown in Figure 8(a) or you can select the whole system as a subsystem which looks like Figure 8(b). Such blocks can be saved in library and used later.

Subsystem

(b) (a) Figure 8: Neural Network Subsystems created from model in Fig. 7 Create the Simulink model in Figure 7 by your own. Create the subsystem shown in Figure 8(a). Finally Simulate the NN subsystem with different values and/or random number generator. Exercise 3: Creating an NN subsystem The function gensim() generates block descriptions of networks so you can simulate them in Simulink. gensim(net,st) Net is the neural network defined either in an m-file or NN Toolbox. The second argument to gensim determines the sample time, which is normally chosen to be some positive real value. If the network has no delays associated with its input weights or layer weights, this value is set to 1. That is, -1 tells gensim to generate a network with continuous sampling. For example, the following m-file defines an NN for

function approximation, trains the NN and then generates a NN block description shown in Figure 9. %Taining data set p=[-1:0.05:1]; %noisy sine wave t=sin(2*pi*p)+0.1*randn(size(p)); net=newff([-1 1],[20,1],{'tansig','purelin'},'traingdx'); net.trainParam.show=50; net.trainParam.epochs=1300; pt=p*0.979; y=sim(net,pt) plot(p,t) hold on plot(p,y,'r') %generate NN block description gensim(net,-1)

Figure 9: NN block description Exercise 4: A 3rd order nonlinear function is given below f ( x) = x 3 + 2 x 2 + 5x Develop a Simulink model for the above function. Using the simulink model generate a set of input-output data. Using the I/O data set, design an MLP, which will approximate the function. Create an NN subsystem and then simulate the system. You need to submit a report on the exercise 4. It should consists of the following Set of I/O data Plot of the function Network architecture Learning profile

You might also like