Lecture 6 - Multi-Layer Feedforward Neural Networks Using Matlab Part 2
Lecture 6 - Multi-Layer Feedforward Neural Networks Using Matlab Part 2
Qadri Hamarsheh
Example 3
Here a perceptron is created with a 1-element input ranging from -10 to 10,
and one neuron.
net = newp ([-10 10],1);
Here the network is given a batch of inputs P. The error is calculated by
subtracting the output Y from target T. Then the mean absolute error is
calculated.
P = [-10 -5 0 5 10];
T = [0 0 1 1 1];
Y = sim (net, P)
E = T-Y;
perf = mae (E) ;
Example 4
Here a two-layer feed-forward network is created with a 1-element input
ranging from -10 to 10, four hidden tansig neurons, and one purelin
output neuron.
net = newff ([-10 10],[4 1],{'tansig','purelin'});
Here the network is given a batch of inputs P. The error is calculated by
subtracting the output A from target T. Then the mean squared error is
calculated.
P = [-10 -5 0 5 10];
T= [0 0 1 1 1];
Y = sim(net,P)
E = T-Y
perf = mse(E)
Example 5:
load house_dataset;
inputs = houseInputs;
targets = houseTargets;
net = newff (inputs, targets, 20);
net = train(net, inputs, targets);
outputs = sim(net, inputs)
%outputs1 = net (inputs);
errors = outputs - targets;
perf = perform(net, outputs, targets)