How to get nonempty layer in GAN deep learning?

1 次查看(过去 30 天)
I have a code. However it is not giver me layers in my deep learning GAN code:
imds = imageDatastore("C:\Users\Sreeraj\Desktop\Me\PhD\Mahindra\DL",'IncludeSubfolders',true,'FileExtensions',(".png"),"LabelSource","foldernames");
augmenter = imageDataAugmenter(RandXReflection=true);
augimds = augmentedImageDatastore([64 64],imds,DataAugmentation=augmenter);
filterSize = 5;
numFilters = 32;
numLatentInputs = 10;
projectionSize = [4 4 512];
layersGenerator = [
featureInputLayer(numLatentInputs)
fullyConnectedLayer(prod(projectionSize))
transposedConv2dLayer(filterSize,4*numFilters)
batchNormalizationLayer
reluLayer
transposedConv2dLayer(filterSize,2*numFilters,Stride=2,Cropping="same")
batchNormalizationLayer
reluLayer
transposedConv2dLayer(filterSize,numFilters,Stride=2,Cropping="same")
batchNormalizationLayer
reluLayer
transposedConv2dLayer(filterSize,3,Stride=2,Cropping="same")
sigmoidLayer];
lgraphGenerator = layerGraph(layersGenerator);
Do I need to add some layer in this structure? I have only 20 images classified equally 10+10.

回答(1 个)

Avadhoot
Avadhoot 2023-11-8
Hi Sreeraj,
I understand that you have built a neural network using the “layerGraph” function. But you are not able to see the layers in your GAN network. This means that there is some issue in the layer construction itself.
Usually the first step after constructing the layers is to run the “analyzeNetwork” function on the layer graph. You can follow the below syntax to do the same:
analyzeGraph(lgraphGenerator);
For your code the output of this command comes out to be the following:
The analysis has come up with 3 errors. The errors are as follows:
  1. The first error occurs in the “transposedConv2dLayer”. The function requires input data which is in the form of [height, width, numChannels]. To resolve this please check the input data for the “transposedConv2dLayer
  2. The missing output layer error occurs because there is an error on the last layer i.esigmoid. You must use a classification layer after the sigmoid layer.
  3. The error on the sigmoid layer states that there is an unconnected output. For this you need to check the dimensions of the input data for sigmoid layer and also check if the sequence of layer is correct.
After resolving the above errors you should see the layers of your network without any problem
Refer to the below documentation to know more about transposedConv2dLayer” and sigmoid layer:
  1. https://www.mathworks.com/help/deeplearning/ref/classificationlayer.html
  2. https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sigmoidlayer.html
  3. https://www.mathworks.com/help/deeplearning/ref/transposedconv2dlayer.html
For more information about “analyzeNetwork” refer to the below documentation:
I hope this helps.

类别

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