projectionSize = [2 1 63];
embeddingDimension = 100;
imageInputLayer([1 1 numLatentInputs],'Normalization','none','Name','Input_Noise')
projectAndReshapeLayer(projectionSize,numLatentInputs,'ProjReshape');
concatenationLayer(3,2,'Name','Concate1');
transposedConv2dLayer([3 2],8*numFilters,'Stride',1,'Name','TransConv1')
batchNormalizationLayer('Name','BN1','Epsilon',5e-5)
reluLayer('Name','Relu1')
transposedConv2dLayer([5 3],4*numFilters,'Stride',1,'Name','TransConv2')
batchNormalizationLayer('Name','BN2','Epsilon',5e-5)
reluLayer('Name','Relu2')
transposedConv2dLayer([5 3],2*numFilters,'Stride',1,'Name','TransConv3')
batchNormalizationLayer('Name','BN3','Epsilon',5e-5)
reluLayer('Name','Relu3')
transposedConv2dLayer([3 3],numFilters,'Stride',1,'Name','TransConv4')
batchNormalizationLayer('Name','BN4','Epsilon',5e-5)
reluLayer('Name','Relu4')
transposedConv2dLayer([1 1],1,'Stride',1,'Name','TransConv5')
lgraphGenerator = layerGraph(layersGenerator);
imageInputLayer([1 1],'Name','Input_Label','Normalization','none')
embedAndReshapeLayer(projectionSize(1:2),embeddingDimension,numClasses,'EmbedReshape1')];
lgraphGenerator = addLayers(lgraphGenerator,layers);
lgraphGenerator = connectLayers(lgraphGenerator,'EmbedReshape1','Concate1/in2');
dlnetGenerator = dlnetwork(lgraphGenerator);
Input_Num_Feature = [14 8 1];
imageInputLayer(Input_Num_Feature,'Normalization','none','Name','Input_Data')
concatenationLayer(3,2,'Name','Concate2')
convolution2dLayer([3 3],8*numFilters,'Stride',1,'Name','Conv1')
leakyReluLayer(scale,'Name','LeakyRelu1')
convolution2dLayer([3 3],4*numFilters,'Stride',1,'Name','Conv2')
leakyReluLayer(scale,'Name','LeakyRelu2')
convolution2dLayer([3 3],2*numFilters,'Stride',1,'Name','Conv3')
leakyReluLayer(scale,'Name','LeakyRelu3')
convolution2dLayer([3 1],numFilters/2,'Stride',1,'Name','Conv4')
leakyReluLayer(scale,'Name','LeakyRelu4')
convolution2dLayer([3 1],numFilters/2,'Stride',1,'Name','Conv5')
leakyReluLayer(scale,'Name','LeakyRelu5')
convolution2dLayer([3 2],1,'Name','Conv6')
leakyReluLayer(scale,'Name','LeakyRelu6')
convolution2dLayer([2 1],1,'Name','Conv7')
lgraphDiscriminator = layerGraph(layersDiscriminator);
imageInputLayer([1 1],'Name','Input_Label','Normalization','none')
embedAndReshapeLayer(Input_Num_Feature,embeddingDimension,numClasses,'EmbedReshape2')];
lgraphDiscriminator = addLayers(lgraphDiscriminator,layers);
lgraphDiscriminator = connectLayers(lgraphDiscriminator,'EmbedReshape2','Concate2/in2');
plot(lgraphDiscriminator);
dlnetDiscriminator = dlnetwork(lgraphDiscriminator);
params.numLatentInputs = numLatentInputs;
params.numClasses = numClasses;
params.sizeData = [Input_Num_Feature length(Series_Fused_Label)];
params.miniBatchSize = 256;
params.learnRate = 0.0002;
params.gradientDecayFactor = 0.5;
params.squaredGradientDecayFactor = 0.999;
executionEnvironment = "cpu";
params.executionEnvironment = executionEnvironment;
[dlnetGenerator,dlnetDiscriminator] = trainGAN(dlnetGenerator, dlnetDiscriminator,Series_Fused_Expand_Norm_Input,Series_Fused_Label,params);
load(fullfile(tempdir,'PumpSignalGAN','GANModel.mat'))