matlab read input command

9 visualizaciones (últimos 30 días)
PALI SAHU
PALI SAHU el 13 de Mzo. de 2019
Respondida: Krishna el 9 de Jul. de 2024
I am working on NN and trying to code for 2:4:1 structure, please help me out in read input command as i am not able to give that command.
Thanks in Advance.
  2 comentarios
KSSV
KSSV el 13 de Mzo. de 2019
Show us what you have tried.....
PALI SAHU
PALI SAHU el 18 de Mzo. de 2019
loadfile='samplefile.txt';
net=network;
net.numInputs= 2;
net.numLayers= 2;
net.layers{1}.size= 4;
net.layers{2}.size= 1;
net.inputconnect(1,2)= 2;
net.IW{1,1};
net.LW{2,1};
net.b{1};
net.b{2};
net.layerConnect = [0 0; 1 0];
net.biasConnect = [1;1];
net.outputConnect = [0 1];
% Setup Division of Data for Training, Validation, Testing
%net.divideParam.trainRatio = 70/100;
%net.divideParam.valRatio = 15/100;
%net.divideParam.testRatio = 15/100;
net.divideFcn = 'dividerand';
% Define transfer Function for each layer
net.layers{1}.transferFcn = 'purelin';
net.layers{2}.transferFcn = 'logsig';
% train the network
net.trainFcn= 'trainlm';

Iniciar sesión para comentar.

Respuestas (1)

Krishna
Krishna el 9 de Jul. de 2024
Hi Pali,
I understand you want to code a neural network structure with 2 inputs, 1 hidden layer with 4 neurons, and 1 output using shallow networks. You can use the feedforwardnet function for this. Here's an example:
net = feedforwardnet([4], 'trainlm');
In this code, 'trainlm' is the optimizer, and 4 is the number of neurons in the hidden layer.
Next, format your dataset to have 2 inputs and 1 output. Then, use the ‘train’ function to train the neural network according to the required specifications.
Please go through the following documentation to learn more,
Also, apart from this MATLAB has dlnetworks which provide more flexibility on neural network design you can also try that.
Please look at this documentation to learn more about dlnetworks,
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by