how to create my ownfitnet neural network? i have written code to calculate square root of number, plz help me to find the problem with it.
Show older comments
I have tried to create my own fitnet network to calculate square root of numbers, instead of using the matlab fitnet. the structure of my network is exactly like the fitnet architecture( I analyzed the fitnet architecture by looking at the script and object created of fitnet) but its not getting trained. plz check it and let me know what mistake I m making .
x=rand(1,1000)*150;
t=sqrt(x);
net=network();
net.adaptFcn='adaptwb';
net.numInputs=1;
net.inputs{1}.size=1;
net.numLayers=2;
net.layers{1}.size=10;
net.layers{2}.size=1;
net.inputConnect(1,1)=1;
net.layerConnect(2,1)=1;
net.biasConnect(1)=1;
net.biasConnect(2)=1;
net.biases{1}.learnFcn='learngdm';
net.biases{1}.initFcn='';
net.biases{2}.learnFcn='learngdm';
net.biases{2}.initFcn='';
net.outputConnect(2)=1;
net.layers{1}.transferFcn='tansig';
net.layers{2}.transferFcn = 'purelin';
net.inputweights{1,1}.initFcn='';
net.inputweights{1,1}.learnFcn='learngdm';
net.layerweights{2,1}.initFcn='';
net.layerweights{2,1}.learnFcn='learngdm';
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};
[net,tr] = train(net,x,t);
outputs = net(x);
test=100;
result = sim(net,test);
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox 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!