A problem about "embedAndReshapeLayer"

8 visualizaciones (últimos 30 días)
Yang Liu
Yang Liu el 14 de Mzo. de 2024
Respondida: Yang Liu el 16 de Mzo. de 2024
My matlab version is: '9.13.0.2399474 (R2022b) Update 7'
I try to copy a code section from the official example about the conditional GAN with the link below (the code section is listed behind):
Two problems occurred:
1. Seems to be a grammar issue related to layer "projectAndReshapeLayer" definition. The command window indicates:
'Error using projectAndReshapeLayer
projectAndReshapeLayer(projectionSize,numLatentInputs,'proj');
Invalid argument at position 2. A name is expected.
Error in untitled (line 11)
projectAndReshapeLayer(projectionSize,numLatentInputs,'proj');
2. I tried to adjust the above issued statement by keeping projectionSize but deleting numLatentInputs. This statement is all good but another error occured in the command window:
'embedAndReshapeLayer' is used in Generate Synthetic Signals Using Conditional GAN.
Error in untitled (line 32)
embedAndReshapeLayer(projectionSize(1:2),embeddingDimension,numClasses,'emb')];
Do I have to construct the whole GAN (Generator and Discriminator) to solve this error? Instead, I just want to loop more in depth about the data size variation in the generator network.
% Generator Network
numFilters = 64;
numLatentInputs = 100;
projectionSize = [4 1 1024];
numClasses = 2;
embeddingDimension = 100;
layersGenerator = [
imageInputLayer([1 1 numLatentInputs],'Normalization','none','Name','in')
projectAndReshapeLayer(projectionSize,numLatentInputs,'proj');
concatenationLayer(3,2,'Name','cat');
transposedConv2dLayer([5 1],8*numFilters,'Name','tconv1')
batchNormalizationLayer('Name','bn1','Epsilon',5e-5)
reluLayer('Name','relu1')
transposedConv2dLayer([10 1],4*numFilters,'Stride',4,'Cropping',[1 0],'Name','tconv2')
batchNormalizationLayer('Name','bn2','Epsilon',5e-5)
reluLayer('Name','relu2')
transposedConv2dLayer([12 1],2*numFilters,'Stride',4,'Cropping',[1 0],'Name','tconv3')
batchNormalizationLayer('Name','bn3','Epsilon',5e-5)
reluLayer('Name','relu3')
transposedConv2dLayer([5 1],numFilters,'Stride',4,'Cropping',[1 0],'Name','tconv4')
batchNormalizationLayer('Name','bn4','Epsilon',5e-5)
reluLayer('Name','relu4')
transposedConv2dLayer([7 1],1,'Stride',2,'Cropping',[1 0],'Name','tconv5')
];
'projectAndReshapeLayer' is used in the following examples:
Generate Synthetic Signals Using Conditional GAN
Train Variational Autoencoder (VAE) to Generate Images
Include Custom Layer in Network
Train Generative Adversarial Network (GAN)
Train Wasserstein GAN with Gradient Penalty (WGAN-GP)
lgraphGenerator = layerGraph(layersGenerator);
layers = [
imageInputLayer([1 1],'Name','labels','Normalization','none')
embedAndReshapeLayer(projectionSize(1:2),embeddingDimension,numClasses,'emb')];
lgraphGenerator = addLayers(lgraphGenerator,layers);
lgraphGenerator = connectLayers(lgraphGenerator,'emb','cat/in2');

Respuesta aceptada

Yang Liu
Yang Liu el 16 de Mzo. de 2024
I know how to solve the problem now. Just copy the folder "GenerateSyntheticPumpSignalsUsingCGANExample" from the path:
\MATLAB\Examples\R2023b\deeplearning_shared\GenerateSyntheticPumpSignalsUsingCGANExample
to the current working directory and add this folder to path.
One can also just add the related function to path, but in case there may be more to use, copy the whole folder and add it to path will be more time-saving.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by