Output equation of fitnet
6 ビュー (過去 30 日間)
古いコメントを表示
I have trained my neural networks as follows
hiddenLayerSize=[20];
net=fitnet(hiddenLayerSize, 'trainlm');
net.divideParam.trainRatio=90/100;
net.divideParam.valRatio=5/100;
net.divideParam.testRatio=5/100;
[net, tr, Y, E, Xf, Af]=train(net,train_input_hz,train_output_hz);
net.trainParam.epochs = 100;
b1 = net.b{1};
b2 = net.b{2};
IW = net.IW{1,1};
LW = net.LW{2,1};
And I did find from various post that the output for the network is given as follows
%% Test the network
x_ref = [0.5 0.5 0.5];
y2_ref = b2 + LW*tanh(b1+IW*x_ref')
y_ref = net(x_ref')
while the reults of this do not match:
y2_ref = -0.2391
y_ref = 1.4543e+03
Is there a mistake in y2_ref = b2 + LW*tanh(b1+IW*x_ref') ? while y_ref is correct
0 件のコメント
回答 (1 件)
Ayush Aniket
2024 年 12 月 26 日
The reason behind the discrepancy between the output of the trained neural network and the analytical equation you are using is that the "net” object used by the “fitnet” neural network function in MATLAB uses pre-processing and post-processing functions to process the input and output data. You should add the following lines of code to apply the same process functions:
normalized_x_ref' = mapminmax('apply', x_ref', net.inputs{1}.processSettings{1}); %we are applying the same pre-processing as in the feedforwardnet
y2_ref = mapminmax('reverse', y2_ref, net.outputs{2}.processSettings{1});%we are applying the same post-processing as in the feedforwardnet
Refer to the following documentation page to read more about the process functions:
Additionally, take care of any non-linearity function used before the output layer.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!