-
Notifications
You must be signed in to change notification settings - Fork 0
/
trainNN.m
43 lines (31 loc) · 1.18 KB
/
trainNN.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [net] = trainNN(inputNNVector_train,outputNNVector_train)
%Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 04-Aug-2020 17:32:23
%
% This script assumes these variables are defined:
%
% inputNNVector_train - input data.
% outputNNVector_train - target data.
x = inputNNVector_train';
t = outputNNVector_train';
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
% 'traingdx' Variable Learning Rate Gradient Descent.
trainFcn = 'traingdx'; % Variable Learning Rate Gradient Descent.
% Create a Fitting Network
hiddenLayerSize = 7;
net = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 87.25/100;
net.divideParam.valRatio = 12.75/100;
net.divideParam.testRatio = 0/100;
net.trainParam.max_fail=70;
net.trainParam.epochs=2000;
net.trainParam.goal=0;
% Train the Network
[net,tr] = train(net,x,t);
end