Created
August 16, 2021 05:44
-
-
Save jaimedantas/04976606bd2762a9a558f35efba4378a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% shufle dataset | |
[D,n] = size(dataset); | |
dsrand = dataset(randperm(D), :); | |
t = dsrand(:,17); | |
x = dsrand(:,1:16); | |
%---------FFNN | |
target_t = []; | |
for i=1:520 | |
if t(i) == 1 | |
target_t = [target_t; 1 0]; % stable | |
else | |
target_t = [target_t; 0 1]; % unstable | |
end | |
end | |
% FFNN for classification with one hidden layer of size 10. | |
net = patternnet([48 32], 'trainscg'); | |
% performance function (loss function) | |
net.performFcn = 'crossentropy'; | |
net.performParam.regularization = 0.01; | |
net.performParam.normalization = 'none'; | |
% training, testing and validation are 0.7, 0.15 and 0.15. | |
net.divideFcn= 'divideind'; % divide the data manually | |
net.divideParam.trainInd= 1:332; % training data indices 80% from training | |
net.divideParam.valInd= 333:416; % validation data indices 20% from training | |
net.divideParam.testInd= 417:520; % testing data indices from testing dataset- 20% of total | |
% transfer function | |
net.layers{1}.transferFcn = 'tansig'; | |
net.layers{2}.transferFcn = 'tansig'; | |
% train | |
net = train(net,x',target_t'); | |
view(net) | |
% targets | |
y = net(x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment