Train Generative Adversarial Network (GAN)
3 views (last 30 days)
Show older comments
I played around with the GAN-Example at
and it works without any problems when just running the software.
I now modified the layersGenerator with an additional fullyConnectedLayer just after the imageInputLayer
imageInputLayer([1 1 numLatentInputs],'Normalization','none','Name','in')
fullyConnectedLayer(numLatentInputs,'Name','fc'); % <- this line is new, nothing special
transposedConv2dLayer(filterSize,8*numFilters,'Name','tconv1')
...
even though analyzeNework seems to be fine with it (the outcome also provides a [1 1 100] dimensional array
learning fails with the comment
"Invalid input data. Convolution operation is supported only for 1, 2, or 3 spatial dimensions."
Do you have any ideas or workarounds how to handle this?
0 Comments
Accepted Answer
Raunak Gupta
on 2 Dec 2019
Hi,
The fullyConnectedLayer is generally used at the end of Network for generating single dimension output useful in Classification/Regression problem. As I understand the need of using fullyConnectedLayer in above scenario is to get a mapping from random input to a more complex linear transformation of input. Here, the fullyConnectedLayer will not return a 3-D output needed as input for transposedConv2dLayer that is why invalid input data error is coming.
I suggest defining the custom layer with the following template or using a convolution2dLayer which can return same output as mentioned ([1,1,100]) for this purpose.
0 Comments
More Answers (3)
Bodo Rosenhahn
on 2 Dec 2019
1 Comment
Raunak Gupta
on 2 Dec 2019
Hi,
The FC layer will only generate a single dimension output, you may check by
outputSize = lgraphGenerator.Layers(2).OutputSize
Here Layers(2) represents FC layer. analyzeNetwork will say that its dimension as 1x1x100 but its actually 100. At the end part of Network these single dimension output doesn't cause any error. The FC layer is designed in such way that it is usable only at the end part because its usability. As for the bottleneck layers of Autoencoder, currently we have segnetLayers and unetLayers which does not contain FC Layers in bottleneck part.
That is why I suggested moving to convolution2dLayer to acheive the same functionality.
For dlnetwork it is used so that writing custom loops won't create problems related to dlarrays.
Hope this clarifies some queries.
Bodo Rosenhahn
on 4 Dec 2019
1 Comment
Raunak Gupta
on 5 Dec 2019
Hi,
You have accepted your Answer, It will mislead any user coming to this question as your answer didn't provide any solution. It would be helpful if you unaccept above answer and accept the actual answer if that one worked for you.
MEP
on 23 Jan 2020
Hi, i need to use the GAN but my input data is a matrix of acceleration signals where each row contain the samples of the signal. So in each row i have different signals, how can i put it in input? I can put it as a matrix or i need to separate the matrix in array and put single array? Thanks...
0 Comments
See Also
Categories
Find more on Custom Training Loops in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!