1 introduction to matlab neural network toolbox jeen-shing wang yu-liang hsu department of...

15
1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October 13, 2014 Static Neural Networks

Upload: alexandra-underwood

Post on 26-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

1

Introduction to MATLAB Neural Network Toolbox

Jeen-Shing WangYu-Liang Hsu

Department of Electrical EngineeringNational Cheng Kung University

October 13, 2014

Static Neural Networks

Page 2: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

2

Step 1: Data collection Create training and testing data

Step 2: Network creation Static networks Dynamic networks

Step 3: Network parameter setting No. of hidden layer, neurons, activation function,

…Step 4: Learning algorithm selection Backpropagation, … Learning rate

Step 5: Learning condition setting Learning epochs, error, …

Step 6: Network learningStep 7: Data testing

Basic Conceptu y

System

Training Procedure

Testing Procedure

w1

w2

wn

x1

x2

xn Synaptic weights

Activation function (Cell body)

Axon

Output

DesiredOutput

Page 3: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

3

Neural Network Models

1. Perceptron

2. Linear Filters

3. Backpropagation

4. Radial Basis Networks

5. Competitive Networks

6. Learning Vector Quantization Network

7. Recurrent Networks

8. NARX Networks

Page 4: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

4

Transfer Function Graphs

Page 5: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

5

Learning Algorithms

Page 6: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

6

Feedforward Neural Networks

P (r×N): Input data (r: No. of input elements, N: No. of input patterns)Y (m×N): Output data (m: No. of output elements)n: nth layer, including the hidden and output layersIWk, l: Input weight matrix (lth input set to kth layer)LWk, l: Layer weight matrix (lth layer to kth layer)

Scalar: a, b, c; Vector: a, b, c; Matrix: A, B, C;

Page 7: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

7

Feedforward Neural Networks

Page 8: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

8

Feedforward Neural Networks

Syntax: newff

net = newff(P, T, [S1 … S(n-1)], {TF1 … TFn}, BTF)

Si: Size of ith layer, for N-1 layers. (Default = [].)

TFi: Transfer function of ith layer. (Default = ‘tansig’ for hidden layers and ‘purelin’ for output layer.)BTF: Backpropagation network training function (Default = ‘trainlm’)

Page 9: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

9

Feedforward Neural Networks

Example 1: t = abs(p)Training input data: P = [0 -1 2 -3 4 -5 6 -7 8 -9 10];Training output data: T = [0 1 2 3 4 5 6 7 8 9 10];

>>clc; clear all; close all;>>% Collect data>>P = [0 -1 2 -3 4 -5 6 -7 8 -9 10];>>T = [0 1 2 3 4 5 6 7 8 9 10];>>% Create network>>net = newff(P,T,10);>>net>>% Training>>net = train(net, P, T);>>% Testing>>y = sim(net,P);>>% Error>>error = mse(y-T)

60%

60%20%20%

Page 10: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

10

Feedforward Neural Networks

Page 11: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

11

Train Feedforward Neural Networks

Set training parameter values: net.trainParam>>net.trainParam.epochs = 100;>>net.trainParam.lr = 0.01;>>net.trainParam.goal = 0;

Train the network>>net = train(net, P, T);

Simulate or test the network>>y = sim(net, Pt);

Testing input data: Pt = [0 1 -2 3 -4 5 -6 7 -8 9 -10];Testing output data: Tt = [0 1 2 3 4 5 6 7 8 9 10];

Page 12: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

12

Train Feedforward Neural Networks

>>net = train(net, P, T,[],[],[],[]);

Page 13: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

13

Graph User Interface (GUI)

>>nntool

Page 14: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

14

Pattern Recognition

>>Tc = ind2vec(T_for_PNN);>>pnnnet = newpnn(P, Tc);>>Yc = sim(pnnnet, test_letter);>>test_index>>Y = vec2ind(Yc)

The training/testing data are available on the course website (http://140.116.215.51)

Page 15: 1 Introduction to MATLAB Neural Network Toolbox Jeen-Shing Wang Yu-Liang Hsu Department of Electrical Engineering National Cheng Kung University October

15

Thanks for your attention !!

Any Question?