MiniBatch Error for GAN training

19 次查看(过去 30 天)
Candy Lau
Candy Lau 2023-5-1
回答: Sugandhi 2023-5-14
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, ...

回答(1 个)

Sugandhi
Sugandhi 2023-5-14
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.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by