how i can save the output of hidden layer of neural network
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ahmed almansory
el 12 de Abr. de 2013
Comentada: manel
el 21 de Abr. de 2014
after i complete my program,i want to save the output,weight and bias of hidden layer of neural network, can any one help me to do this? thanks
0 comentarios
Respuesta aceptada
Greg Heath
el 15 de Abr. de 2013
close all, clear all, clc, plt=0;
delete h.mat
delete LW.mat
delete b2.mat
delete tsettings.mat
[ x, t ] = simplefit_dataset;
net = fitnet;
rng(4151941)
[ net tr y0 ] = train( net, x, t);
plt=plt+1,figure(plt) % figure 1
hold on
plot(x,t,'b--','LineWidth',2)
plot(x,y0,'r.','LineWidth',2)
legend('TARGET','NN OUTPUT')
xlabel('INPUT')
ylabel('TARGETAND NN OUTPUT')
title('SIMPLEFIT DATASET')
%Create tsettings, h, LW, b2
[xn xsettings] = mapminmax(x);
[tn tsettings] = mapminmax(t); % SAVE tsettings
b1 = cell2mat(net.b(1))
IW = cell2mat(net.IW)
[ I N ] = size(xn)
B1 = b1*ones(1,N);
% B1 = repmat(b,1,N); % Alternate
h = tanh(B1+IW*xn); % SAVE h
LW = cell2mat(net.LW) % SAVE LW
b2 = cell2mat(net.b(2)) % SAVE b2
clc
whos h LW b2 tsettings
dir
% save FILENAME ... is the command form of the syntax
% for convenient saving from the command line. With
% command syntax, you do not need to enclose strings in
% single quotation marks. Separate inputs with spaces
% instead of commas. Do not use command syntax if
% inputs such as FILENAME are variables.
save h
save LW
save b2
save tsettings
dir
whos N h LW b2 tsettings
disp('BEFORE CLEARING SAVED HIDDEN VARIABLES')
disp('ENTER TO CONTINUE')
pause
dir
clear h LW b2 tsettings
whos N h LW b2 tsettings
disp('AFTER CLEARING SAVED HIDDEN VARIABLES')
disp('ENTER TO CONTINUE')
pause
load h.mat
load LW b2 tsettings
whos N h LW b2 tsettings
disp('AFTER RELOADING SAVED HIDDEN VARIABLES')
disp('ENTER TO CONTINUE')
pause
yn = b2 + LW*h;
y = mapminmax('reverse',yn,tsettings);
reloadingerror = max(abs(y-y0))
break
% Hope this helps
Thank you for formally accepting my answer
Greg
Más respuestas (1)
Greg Heath
el 13 de Abr. de 2013
Editada: Greg Heath
el 13 de Abr. de 2013
clear all, clc
[ x, t ] = simplefit_dataset;
net0 = fitnet( 10 );
[ net0 tr0 y0 ] = train( net0, x, t);
whos
%You can save the output and net
save y0 net0
%Delete them
clear y0 net0
whos
%and retrieve them
load y0 net0
whos
%or save, delete and and retrieve the weights
W0 = getwb(net0)
save y0 W0
whos
clear y0 W0
whos
load y0 W0
whos
Hope this helps.
Thank you for formally accepting my answer
Greg
2 comentarios
manel
el 21 de Abr. de 2014
hi ; I have the same problem ; if you have solve it can you pleez say me what you have done. thanks in advance
Ver también
Categorías
Más información sobre Define Shallow Neural Network Architectures en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!