我想使用Matlab深度学习工具箱创建自定义CNN网络,但显示以下错误。图层定义良好,但是net = layerGraph(layers);
命令显示错误。
Gr=128; Gt=32;
vecInput = imageInputLayer([Gr,Gt,3], 'Name', 'input');
Conv2d1 = convolution2dLayer(3,16,'Padding','same'); %size: 128*32*16
BN1 = batchNormalizationLayer('Name','BN1');
relu1 = reluLayer('Name','relu1');
pool1 = averagePooling2dLayer(2,'Stride',2,'Name','pool1'); %size: 64*16*16
Conv2d2 = convolution2dLayer(3,32,'Padding','same'); %size: 64*16*32
BN2 = batchNormalizationLayer('Name','BN2');
relu2 = reluLayer('Name','relu2');
pool2 = averagePooling2dLayer(3,'Stride',2,'Name','pool2'); %size: 32*8*32
Conv2d3 = convolution2dLayer(3,2,'Padding','same'); %size: 32*8*2
BN3 = batchNormalizationLayer('Name','BN2');
relu3 = reluLayer('Name','relu3');
fc1 = fullyConnectedLayer(1024,'Name','fc1');
relu4 = reluLayer('Name','relu4');
fc2 = fullyConnectedLayer(4096,'Name','fc2');
relu5 = reluLayer('Name','relu5');
reglayer = regressionLayer('Name','output');
layers = [
vecInput
Conv2d1
BN1
relu1
pool1
Conv2d2
BN2
relu2
pool2
Conv2d3
BN3
relu3
fc1
relu4
fc2
relu5
reglayer];
net = layerGraph(layers); %This command is showing error
错误消息:
Error using nnet.internal.cnn.util.validateLayersForLayerGraph>iAssertUniqueAndNonEmptyLayerNames
(line 87)
Layer names in layer array must be nonempty.
Error in nnet.internal.cnn.util.validateLayersForLayerGraph (line 48)
iAssertUniqueAndNonEmptyLayerNames(larray, existingLayers);
Error in layerGraph>iPostProcessParsingResultsForConstructor (line 90)
inputArguments.Layers = nnet.internal.cnn.util.validateLayersForLayerGraph(results.Layers);
Error in layerGraph (line 46)
inputArguments = iPostProcessParsingResultsForConstructor(parser.Results);
Error in test_builnet (line 45)
net = layerGraph(layers);