how to design custom ANN using Deep Network designer app MATLAB
1 view (last 30 days)
Show older comments
Hello Everyone, I Hope you are doing well.
I want to create a simple ANN using Deep network Designer app or using code.
ANN contain input layer, 10 neurons in hidden layer with sigmoid activation and output layer with classifciaton and softmax layer
I have the dataset of shape 250x1000. I have attached the dataset below. which contain label as well.
I also want to be label in catogorical form . Like 1 name as 'Class1'
How can i do it in MATLAB
Accepted Answer
yanqi liu
on 1 Mar 2022
clc; clear all; close all;
load Datasetn
layers = [
imageInputLayer([1000 1 1])
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(5)
softmaxLayer
classificationLayer];
opts = trainingOptions('adam', ...
'MaxEpochs',200, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'ExecutionEnvironment', 'cpu', ...
'ValidationPatience',Inf);
xc = reshape(dataset', [1000,1,1,250]);
% 'Class1'
yc = [];
for i = 1 : length(label)
yc{i,1} = ['Class' num2str(double(label(i)))];
end
yc = categorical(yc);
disp(yc)
net = trainNetwork(xc,yc,layers,opts);
2 Comments
yanqi liu
on 1 Mar 2022
yes,sir
clc; clear all; close all;
load Datasetn
idx = randperm(length(label)) ;
dataset = dataset(idx,:);
label = label(idx,:);
m = round(length(label)*0.8) ;
dataset1 = dataset(1:m,:); label1 = label(1:m,:);
dataset2 = dataset(1+m:end,:); label2 = label(1+m:end,:);
layers = [
imageInputLayer([1000 1 1])
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(5)
softmaxLayer
classificationLayer];
opts = trainingOptions('adam', ...
'MaxEpochs',200, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'ExecutionEnvironment', 'cpu', ...
'ValidationPatience',Inf);
xc = reshape(dataset1', [1000,1,1,m]);
% 'Class1'
yc = [];
for i = 1 : length(label1)
yc{i,1} = ['Class' num2str(double(label1(i)))];
end
yc = categorical(yc);
disp(yc)
net = trainNetwork(xc,yc,layers,opts);
More Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!