Is it possible to get expression/formula of Neural Network Toolbox?
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rokas Bondzinskas
le 23 Oct 2014
Commenté : omar alrumayh
le 22 Mai 2019
Hi all,
I have a dependency P(x,y,z), thus, this is 4D function. My goal is to find an analytic expression of P as a function of x,y,z. I used Neural Network Toolbox to analyse my data (train, validated and so on). It seems that it gives very good fit with MSE of 1e-7 and R-square of 0.997. I am wondering if it is possible to get an expression where I could manually plug in x,y,z and get P values.
Best Regards Rokas,
1 commentaire
omar alrumayh
le 22 Mai 2019
I am trying to do the same. However, I could not get the same answer from the function that represent the NN.
x=randi([0 1],10000,1).'; %INPUT
y= (x./2); %OUTPUT
input= {x};
target= {y};
%--------------------------------------
net= fitnet(1);
net= train(net,input,target);
test= net(x);
view(net);
%---------------------------------------Here I want to get the weight and bias from the trained neural network
obtainedIW= cell2mat(net.IW); %input weight
obtainedLW= cell2mat(net.LW); %Layer weight
obtainedb= cell2mat(net.b); %Biases
n=(obtainedIW.*0.5) + obtainedb(1); %My input here is 0.5
yCal= ((tansig(n)*obtainedLW +obtainedb(2))) ;
Réponse acceptée
Greg Heath
le 24 Oct 2014
The equation for fitnet is
y = b2 + LW*tanh(b1+IW*x);
where
b1 = net.b{1};
b2 = net.b{2};
IW = net.IW{1,1};
LW = net.LW{2,1};
Hope this helps.
Thank you for formally accepting my answer
Greg
Plus de réponses (1)
Greg Heath
le 26 Oct 2014
Eliminating statements that assign default values yields
x = input;
t = target; % Reserve the variable name y for the output
MSE00 = mean(var(t',1)) % Reference MSE
net = fitnet; % Uses defaults
% Train the Network
[ net, tr, y0, e ] = train(net, x, t); % e = t-y0
b1 = net.b{1};
b2 = net.b{2};
IW = net.IW{1,1};
LW = net.LW{2,1};
% Test the Network
y = b2 + LW*tanh(b1+IW*x);
diffy = max(abs(y-y0))
performance = mse(e)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
Voir également
Catégories
En savoir plus sur Define Shallow Neural Network Architectures dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!