Running trainNetwork() starts parallel pool in Matlab 2023b even when options.Ex​ecutionEnv​ironment = 'cpu'

9 visualizaciones (últimos 30 días)
It seems the behaviour of trainNetwork has changed. I have a for loop that performs a grid search of models' hyper-parameters. After updating to version 2023b, parallel pool is being started whenever trainNetwork is invoked. Is this a bug or trainNetwork behaviour changed?
  6 comentarios
Artem Lensky
Artem Lensky el 22 de Sept. de 2023
In function
function executionSettings = setupExecutionEnvironment(options)
there is this if statement
% Validate PCT if needed. It is not needed only when the execution
% environment is set as CPU and dispatch in background is false
if isPoolNeeded || options.ExecutionEnvironment == "gpu"
for some reason even when options.ExecutionEnvironment set to "cpu", isPoolNeeded is set to true, which leads to executing the pool even when there is no need for it.
Artem Lensky
Artem Lensky el 22 de Sept. de 2023
I think I identified the problem, option DispatchInBackground was set to True expcplicitly. Surprisingly, it didn't execute the pool in previous Matlab version.

Iniciar sesión para comentar.

Respuesta aceptada

Artem Lensky
Artem Lensky el 22 de Sept. de 2023
Editada: Artem Lensky el 22 de Sept. de 2023
Whenever option DispatchInBackground set true, trainNetwork executes parallel pool.
If I am not mistaken this behaviour was different in 2023a, I already deleted it so can't verify, but it would be nice if someone at Mathworks would check wherther
function executionSettings = setupExecutionEnvironment( opts, X, precision, networkInfo )
contains these lines
% In DLT if the training datastore is set up for background prefetch,
% enable background prefetch
backgroundPrefetch = iUseBackgroundPrefetch(X) || opts.DispatchInBackground;
  4 comentarios
Joss Knight
Joss Knight el 25 de Sept. de 2023
Experiment Manager can do an parameter sweep in whatever way you like, and the parameters can be anything you like, so rng seeds for instance.
Implementing a specific grid search algorithm (sweeping one parameter at a time) may require more manual intervention I'll admit. But you might still find it saves you time.
Artem Lensky
Artem Lensky el 26 de Sept. de 2023
Thanks for the reply. I might give it another go. I am surprised the grid search hasn't been implemented as an out of the box feature given that it is one of the basic parameter search approaches. Perhaps in 2024 version :)

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Parallel and Cloud 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!

Translated by