MiniBatch Error for GAN training

17 vues (au cours des 30 derniers jours)
Candy Lau
Candy Lau le 1 Mai 2023
When I was following the provided code GAN MATLAB, and I was executed the code in MATLABR2023a. I found that the below code is having the mini batch error. I have installed the Deep Learning Toolbox in my MATLAB. Please help me to solve it. Thanks in advance!
augimds.MiniBatchSize = miniBatchSize;
mbq = minibatchqueue(augimds, ...
MiniBatchSize=miniBatchSize, ...
PartialMiniBatch="discard", ...
MiniBatchFcn=@preprocessMiniBatch, ...
MiniBatchFormat="SSCB");
Error using minibatchqueue>iValidateMiniBatchFcn
Invalid value for 'MiniBatchFcn'. Unable to find function 'preprocessMiniBatch'.
Error in minibatchqueue>iParseInputs (line 695)
iValidateMiniBatchFcn(options.MiniBatchFcn, numVariables, options.NumOutputs);
Error in minibatchqueue (line 291)
options = iParseInputs(numVariables, varargin{:});
Error in gangan (line 83)
mbq = minibatchqueue(augimds, ...

Réponses (1)

Sugandhi
Sugandhi le 14 Mai 2023
Hi Candy Lau,
I understand that you are receiving error while executing GAN MATLABi n MATLAB R2023a.
The error message indicates that MATLAB cannot find the `preprocessMiniBatch` function, which is used as input to the `MiniBatchFcn` argument of the `minibatchqueue` function. This error can occur if the function is not defined in the current workspace or on the MATLAB path.
To resolve this error, one of the possible workaround can be to define the `preprocessMiniBatch` function in a separate file or script in the same folder or on the MATLAB path.
Once you have defined the `preprocessMiniBatch` function, save it to a separate file or script, and make sure that the file is on the MATLAB path. Then, modify the `mbq` initialization code in your script to the following:
mbq = minibatchqueue(augimds, ...
'MiniBatchSize', miniBatchSize, ...
'PartialMiniBatch', 'discard', ...
'MiniBatchFcn', @preprocessMiniBatch, ...
'MiniBatchFormat', 'SSCB');
This should properly initialize the `mbq` object with your custom `preprocessMiniBatch` function and resolve the error you are seeing.

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by