How to classify data in a hierarchical neural network (training, validation, testing)
1 次查看(过去 30 天)
显示 更早的评论
I don't know how to classify (train, validate, test) data in a hierarchical neural network.
I can classify the data with a double array, but I can't classify it well with a cell array.
net = network; % ネットワーク初期化
net.numInputs = 2; % 入力層の数を指定 (ユニットではなくグループ数)
net.numLayers = 3; % 隠れ層(2)と出力層(1)の数
net.layers{1}.size = 10; % 隠れ層1のユニット数(10)
net.layers{2}.size = 5; % 隠れ層2のユニット数(5)
net.layers{3}.size = 3; % 出力層のユニット数
net.biasConnect = [1;1;1];
net.inputConnect = [1 0;0 1;0 0]; % 入力層から直接接続される隠れ層/出力層設定
net.LayerConnect = [0 0 0;1 0 0;0 1 0]; % 隠れ層同士の接続状況
net.outputConnect = [0 0 1]; % 出力への接続状況
net.trainFcn = 'trainlm'; % 学習関数
% 伝達関数指定
net.layers{1}.transferFcn = 'logsig';
net.layers{2}.transferFcn = 'logsig';
net.layers{3}.transferFcn = 'purelin';
net.plotFcns = {'plotperform','plottrainstate'};
net.initFcn = 'initlay';
net.performFcn = 'mse';
net.divideFcn = 'dividerand';
% 入出力データ設定
X = rand(105,1000);
T = rand(3,1000);
X = con2seq(mat2cell(X,[100 5]))
T = con2seq(T);
% net.initFcn = 'initlay';
% net.performFcn = 'mse';
% net.divideFcn = 'dividerand';
% 学習
% net = feedforwardnet(5);
[net,tr] = train(net,X,T);
outputs = net(X);
errors = gsubtract(T, outputs);
performance = perform(net, T, outputs)
tInd = tr.testInd;
tstOutputs = net(X(:, tInd));
tstPerform = perform(net, T(tInd), tstOutputs)
view(net)
figure, plotperform(tr)
figure, plottrainstate(tr)
figure, plotfit(net,X,T)
figure, plotregression(T,outputs)
figure, ploterrhist(errors)
0 个评论
回答(1 个)
Naoya
2021-5-30
Please change the net.DivideMode value from "sample" to "time".
You can divide the data into three items: training, validation, and testing, for 1000 samples.
net.plotFcns = {'plotperform','plottrainstate'};
net.initFcn = 'initlay';
net.performFcn = 'mse';
net.divideMode = 'time'; % add
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!