How to apply an divideFcn 'dividedblock' by a Neural Network?

조회 수: 5 (최근 30일)
Martijn Claes
Martijn Claes 2018년 4월 6일
편집: Martijn Claes 2018년 4월 6일
Hello,
I want try to predict the flow of air in a system. Therefore I take 15 steps in the past to predict 4 steps ahead. For avoiding overfitting I will stop the training when the performance of the validationset isn't consequent with the trainset performance. Normally the dividedFcn divided the input en targets in a train, validation and test set. When I apply this function there is an error. Is somebody know how to solve this? Later I want to extend the model with other inputs, there for I want to work with Cells.
For experimenting there is a script with a know function. In this script are al the 'features' implemented en tested. But the divideFcn doesn't work.
clear all
close all
clc
% parameters model
Input_Delays = 15;
Targets = 4;
Numeber_Neurons = 20;
epochs=100;
trainFcn = 'trainlm';
%%make train & validationi data
t_Train = 1:200;
x_Train = 10.*sin(t_Train)+t_Train.*t_Train./100;
%%independent test data
t_Test = 201:300;
x_Test = 10.*sin(t_Test )+t_Test .*t_Test ./100;
%%Prepare Train & Validation DATA
for i = 1:length(x_Train)-Input_Delays-Targets
% load prepariation
X_Seq_Input_Train{:,i} = x_Train(i:i+Input_Delays-1)';
T_Seq_Target_Train{:,i} =
x_Train(i+Input_Delays:i+Input_Delays+Targets-1)';
Time_Targets_Train{:,i} =
t_Train(i+Input_Delays:i+Input_Delays+Targets-1)';
end
%%Prepaere Test DATA
for i = 1:length(x_Test)-Input_Delays-Targets
% load prepariation
X_Seq_Input_Test{:,i} = x_Test(i:i+Input_Delays-1)';
T_Seq_Target_Test{:,i}=
x_Test(i+Input_Delays:i+Input_Delays+Targets-1)';
Time_Targets_Test{:,i} =
t_Test(i+Input_Delays:i+Input_Delays+Targets-1)';
end
% make forwardnet
net= feedforwardnet(Numeber_Neurons);
net.Inputs{1}.name= 'Timestamps'; % name of input
net.Inputs{1}.size =Input_Delays ; % number of inputs
net.Layers{1}.size = Numeber_Neurons; % Number of neurons
% split Dataset Train
Here is the problem
net.divideFcn ='divideblock' ;
net.divideParam.trainRatio=0.8;
net.divideParam.valRatio =0.2;
net.divideParam.testRatio =0.0;
% %tempory setting but doensn't effect the training process
% net.divideFcn = 'dividerand';
% net.divideMode = 'sample';
% net.divideParam.trainRatio = 70/100;
% net.divideParam.valRatio = 15/100;
% net.divideParam.testRatio = 15/100;
% net.trainParam.showWindow = false;
net.trainFcn = trainFcn;
net.trainParam.epochs = epochs;
%net.trainParam.showWindow = false;
%%train
[net,tr] = train(net,X_Seq_Input_Train,T_Seq_Target_Train,'useParallel','no');
%%Simulate on train
[A_Train] = sim(net,X_Seq_Input_Train);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by