Train a GAN example difficulty

21 ビュー (過去 30 日間)
mark palmer
mark palmer 2020 年 5 月 22 日
コメント済み: zahoor m 2023 年 12 月 12 日
I am working through the example for using a GAN given here:
https://www.mathworks.com/help/deeplearning/ug/train-generative-adversarial-network.html
And I get an error at the point where it says projectAndReshapeLayer.
Undefined function 'projectAndReshapeLayer' for input arguments of type
'double'.
When I click on the word projectAndReshapeLayer, I get this:
You clicked a link that corresponds to this MATLAB command:
edit(fullfile(matlabroot,'examples','nnet','main','projectAndReshapeLayer.m'))
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
So when I paste this link into the Command Window, it simply creates a blank projectAndReshapeLayer.m file and the error persists.
What am I doing wrong?
To project and reshape the noise input, use the custom layer projectAndReshapeLayer, attached to this example as a supporting file. The projectAndReshapeLayer layer upscales the input using a fully connected operation and reshapes the output to the specified size.
filterSize = 5;
numFilters = 64;
numLatentInputs = 100;
projectionSize = [4 4 512];
layersGenerator = [
imageInputLayer([1 1 numLatentInputs],'Normalization','none','Name','in')
projectAndReshapeLayer(projectionSize,numLatentInputs,'proj');
transposedConv2dLayer(filterSize,4*numFilters,'Name','tconv1')
batchNormalizationLayer('Name','bnorm1')
reluLayer('Name','relu1')
transposedConv2dLayer(filterSize,2*numFilters,'Stride',2,'Cropping','same','Name','tconv2')
batchNormalizationLayer('Name','bnorm2')
reluLayer('Name','relu2')
transposedConv2dLayer(filterSize,numFilters,'Stride',2,'Cropping','same','Name','tconv3')
batchNormalizationLayer('Name','bnorm3')
reluLayer('Name','relu3')
transposedConv2dLayer(filterSize,3,'Stride',2,'Cropping','same','Name','tconv4')
tanhLayer('Name','tanh')];
lgraphGenerator = layerGraph(layersGenerator);
  8 件のコメント
Rahul Gowtham Poola
Rahul Gowtham Poola 2023 年 2 月 5 日
Error using dlnetwork/validateForwardInputs
Layer 'in': Invalid input data. Invalid number of spatial dimensions. Layer expects 2 but received 0.
zahoor m
zahoor m 2023 年 12 月 12 日
Layer 'input': Invalid input data. Invalid number of spatial dimensions. Layer expects 2 but received
0.

サインインしてコメントする。

採用された回答

Xiangxue Wang
Xiangxue Wang 2020 年 6 月 4 日
Trying to add the projectAndReshapeLayer path to your matlab searching path. By default, the deep learning example are not in 2020 path.
Hope this will work for you
>> fullfile(matlabroot,'examples','nnet','main','projectAndReshapeLayer.m')
ans =
'C:\Program Files\MATLAB\R2020a\examples\nnet\main\projectAndReshapeLayer.m'
% so adding path to by:
addpath('C:\Program Files\MATLAB\R2020a\examples\nnet\main')

その他の回答 (3 件)

soliya
soliya 2020 年 6 月 11 日
  1 件のコメント
Yonglei GUI
Yonglei GUI 2021 年 2 月 21 日
Hello, my matlab has no the file minibatchqueue.m, so may you give me a URL like this? or you can send email narutomst@163.com. Thank you very much!

サインインしてコメントする。


Ieuan Evans
Ieuan Evans 2020 年 6 月 25 日
編集済み: Ieuan Evans 2020 年 6 月 25 日
This example was updated in R2020a to use this custom layer. If you use the command openExample('nnet/TrainGenerativeAdversarialNetworkGANExample') in MATLAB, then it will open the correct version of this example for your version of MATLAB.
Hope this helps.

Ramyakrishna
Ramyakrishna 2022 年 10 月 24 日
Replace the line with the below line
projectAndReshapeLayer(projectionSize,numLatentInputs,Name='proj')

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by