How to fix the error using minibatchqueue while using GAN?

조회 수: 15 (최근 30일)
Hello mathworks team,
I have tried to implement "TrainGenerativeAdversarialNetworkGANExample" using my dataset, which consists of 3 classes (.png images) with total of 1426 images, and each images size is 417*532*3. I am getting an error like as shown below.
I didn't understand how to fix this error. I tried with inbuilt matlab example using "flowers datset", it is working fine. Please help me in this regard.
  댓글 수: 3
Rohit
Rohit 2023년 8월 28일
Hi Santhosh,
Could you share your code and dataset with me, so that I can perform the operations on my end and provide you with further assistance?
santhosh kumar buddepu
santhosh kumar buddepu 2023년 8월 28일
Thank you for reply sir,
I have used the expample given by Matlab
Instead of flower dataset, I have given my dataset named as 'ground_truth'
imds = imageDatastore('ground_truth', ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
remaining is same, and Iam getting above error.
Herewith I have attached part of my dataset due to size issues. It contains 3 classes.

댓글을 달려면 로그인하십시오.

채택된 답변

Milan Bansal
Milan Bansal 2023년 9월 5일
Hi,
I understand that you getting an error when running the "minibatchqueue" function of Deep-Learning Toolbox while implemetenting "TrainGenerativeAdversarialNetworkGANExample" with your data set.
In "minibatchqueue" function the number of mini-batch variables must be less than or equal to the number of outputs returned by the "MiniBatchFcn". In this case the "MiniBatchFcn" is the custom preprocessing function defined at the end of the script.
function X = preprocessMiniBatch(data)
% Concatenate mini-batch
X = cat(4,data{:});
% Rescale the images in the range [-1 1].
X = rescale(X,-1,1,InputMin=0,InputMax=255);
end
This function returns only 1 output i.e. "X", whereas the number of mini-batch variables in the "minibatchqueue" is 2.
Add the optional argument numOutputs in the "minibatchqueue" and set its value as 1 to resolve the issue.
mbq = minibatchqueue(augimds, ...
MiniBatchSize=miniBatchSize, ...
PartialMiniBatch="discard", ...
MiniBatchFcn=@preprocessMiniBatch, ...
MiniBatchFormat="SSCB",numOutputs = 1);
Refer to documentation link to know more about "minibatchqueue" function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by