How to save neural network
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have used neural network to the datasets and now if i trained network one time and now i want to apply this network to different datasets then how i can apply? I want to do this because i want to compare how efficient the transferability? I am eager to find solution.
0 comentarios
Respuesta aceptada
Greg Heath
el 14 de Nov. de 2012
Editada: Greg Heath
el 7 de Abr. de 2013
clear all, close all, clc;
[x,t] = simplefit_dataset;
[I N ] = size(x)
[O N ] = size(t)
xtrn = x(1:2:N);
ttrn = t(1:2:N);
MSEtrn00 = var(ttrn',1) % Reference MSEtrn
xval = []; % No val data for Early Stopping
tval = [];
xtst = x(2:2:N); % For post training testing
ttst = t(2:2:N);
MSEtst00 = var(ttst',1) % Reference MSEtst
H = 4 % Minimized by trial & error
net = fitnet(H);
net.divideFcn = ''; % No automatic data division
net.trainParam.goal = 0.01*MSEtrn00; % Want training R^2 >= 0.99
[net tr Ytrn Etrn] = train(net,xtrn,ttrn);
ytrn = net(xtrn);
etrn = ttrn-ytrn;
MSEtrn =mse(etrn)
check1 = max(abs(ytrn - Ytrn))
check2 = max(abs(etrn - Etrn))
check3 = max(abs(MSEtrn - tr.perf(end)))
NMSEtrn = MSEtrn/MSEtrn00 % Normalized
R2trn = 1-NMSEtrn % R^2
% Save for use with other data
net01 = net;
save net01 % Save
whos net net01 % Both in workspace
pause(5)
clear net net01 % Cleared from workspace
whos % Proof
%Retrieve and use
load net01
ytst = net01(xtst);
MSEtst = mse(ttst-ytst)
R2tst = 1-MSEtst/MSEtst00
Hope this helps
Thank you for formally accepting my answer
Greg
3 comentarios
Walter Roberson
el 6 de Abr. de 2013
Greg Heath
el 7 de Abr. de 2013
Close. I had defined a similar function which wasn't quite as general: max(abs(x)) instead of max(abs(x(:))
Más respuestas (0)
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!