How to re-load MatLab's feedforwardnet to Workspace?

1 visualización (últimos 30 días)
Cheng Zhang
Cheng Zhang el 25 de Abr. de 2021
Comentada: Jon Cherrie el 26 de Abr. de 2021
I create a feed-forward neural network 100 times, each time with different input and target. The trained model is saved into "FFNN_trained_sum" each time.
FFNN_trained_sum = []
for iteration = 1:100;
FFNN = feedforwardnet(20);
x = ...; t = ...; % assign the input "x" and target "t" with different datasets.
FFNN_trained = train(FFNN,x,t);
FFNN_trained_sum = [FFNN_trained_sum, FFNN_trained]
end
So after 100 times, the "FFNN_trained_sum" is a 1x100 network. How can I load the 37th network into MatLab Workspace? I tried the below but got error.
>> FFNN_trained_sum(37)
Scalar structure required for this assignment.
Error in network/sim (line 141)
net.trainFcn = ''; % Disable training related setup
Error in network/subsref (line 15)
otherwise, v = sim(vin,subs{:});

Respuesta aceptada

Jon Cherrie
Jon Cherrie el 26 de Abr. de 2021
I recommend using a cell array rather than a regular array for this case, e.g.,
FFNN_trained_sum = {}; % Use {} here, not []
for iteration = 1:100;
FFNN = feedforwardnet(20);
x = ...;
t = ...;
FFNN_trained = train(FFNN,x,t);
FFNN_trained_sum{end+1} = FFNN_trained; % append the new network at the end
end
You can then access the 37th network via FFNN_trained_sum{37}
  2 comentarios
Cheng Zhang
Cheng Zhang el 26 de Abr. de 2021
Sure, is there a way to convert the regular array to a cell array?
Jon Cherrie
Jon Cherrie el 26 de Abr. de 2021
If you already have that array of networks, and want the 37th one, you could try this:
s = struct(FFNN_trained_sum);
FFNN_trained_37 = network(s(37));
To convert the array to a cell array, this seems to work:
cellOfNetworks = {};
s = struct(FFNN_trained_sum);
for i = 1:length(s)
cellOfNetworks{end+1} = network(s(i));
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by