Octave MLP Neural Networks
Octave MLP Neural Networks
Octave MLP Neural Networks
Using Octave NN
Package
Nung Kion, Lee
Faculty of Cognitive Sciences and Human Development
UNIVERSITI MALAYSIA SARAWAK
Introduction
Octave provides a simple neural network package to construct the Multilayer
Perceptron Neural Networks which is compatible (partially) with Matlab.
Only feedforward backprogation neural network is implemented.
Only one training algorithm is available (the Levenberg-Marquardt)
Steps of Using Neural Networks as Classifier
train function
Train the neural
network
Take Note!!!
In Octave, the training, test, or
validation data must be prepared in
columns. That is the rows are features
and the columns are training input
patterns.
The target patterns/desired output of
corresponding to input patterns must
be arranged in columns as well.
Input-output patterns format for Octave NN
package Input Target
Input
Input output pairs for
Octave NN
Target
Exercise 1
Download the iris.data from Morpheus and extract the input and output
patterns into inputdata and outputdata respectively.
Prepare the inputdata and outputdata in the format suitable for Octave NN
input.
Min_Max Function
Pulangkan nilai minimum dan maximum setiap baris dalam matrix untuk
kegunaan fungsi newff.
Exercise 2
Use the min_max function to determine the min and max value of each
feature value of the iris dataset you have loaded into Octave workspace in
Exercise 1.
Syntax:
[mTrain, mTest, mVali] = subset (mData,nTargets,iOpti,fTest,fVali)
mData – the complete training data with input and output values. E.g. in iris data, the mData is a 7
x 150 matrix (4 inputs and 3 outputs).
nTargets – the number of outputs (e.g. 3 in iris data).
iOpti – randomize the columns of data (permute). 0- No; 1 or 2 – Yes (see ref)
fTest – percentage of data use for testing (default is 1/3 of data)
fVali – percentage of data use for cross-validation (default is 1/6 of data).
Exercise 3
Note that: the value of fTest + fVali < 1. If fTest + fVali = 1, then no data for
training. It is suggested to use the default.
Load the iris.data into mData variable. Create train, test, validation
subsets with 0.6, 0.2, 0.1 percentage. Verify your subsets using the size
command on the produced subsets.
Standardization of inputs
Read the following articles to understand why standardization of input feature
values.
1. http://stackoverflow.com/questions/4674623/why-do-we-have-to-normalize-
the-input-for-an-artificial-neural-network
2. http://stats.stackexchange.com/questions/7757/data-normalization-and-
standardization-in-neural-networks
3. ftp://ftp.sas.com/pub/neural/FAQ2.html#A_std
Standardization converts feature values to have zero mean and standard deviation
is 1.
We can standardize both input feature values and/or target values depending on
the data used.
The prestd is available by Octave for standardization which syntax can be found at
http://dali.feld.cvut.cz/ucebna/matlab/toolbox/nnet/prestd.html?cmdname=prestd
Exercise 4
Standardize the input values of iris data you have loaded.
Check the result for correctness.
Creating MLP neural networks
The MLP NN implemented by Octave is very limited. It only support the
Levenberg-Marquardt (LM) backpropagation training algorithm, not the gradient
descent method discussed in the class.
See
http://nopr.niscair.res.in/bitstream/123456789/8460/1/IJEMS%2012(5)%20434-
442.pdf
for LM training method.
Syntax for creating MLP NN
Training will stop once one of the stopping criteria is met (see next slides).
Training neural network (continue)
The training parameters are stored in the neural network trainParam struct.
Default values for trainParam are:
net.trainParam.epochs = 100; #number of epochs
net.trainParam.goal = 0; #minimum means square error to achieve
net.trainParam.max_fail = 5;
net.trainParam.min_grad = 1.0000e-010; #gradient of the mse graph
net.trainParam.show = 50; #show mse every 50 epochs
net.trainParam.time = Inf; #maximum training time in seconds
net.show = 50; #how frequent the mse is displayed in training progress
graph?
max_fail: Validation vectors are used to stop training early if the network
performance on the validation vectors fails to improve or remains the same for
max_fail epochs in a row.
Training neural networks (continue)
Training stops when any of these conditions occurs:
The maximum number of epochs (repetitions) is reached.
The maximum amount of time is exceeded.
Performance is minimized to the goal.
The performance gradient falls below min_grad.
Validation performance has increased more than max_fail times since the last time
it decreased (when using validation).
Training Neural Networks (continue)
You should change the trainParam before using the train function to be effective.
E.g.:
MLPNet.trainParam.epochs = 500; #change maximum epochs to 500
MLPNet.trainParam.goal = 0.01; #stop training if mse is <= 0.01
trainednet = train(MLPNet, trainsubset, traintarget, [], [], VV);
Test trained neural networks
To test the trained neural network use the sim function
Syntax: