Error in using sequenceFoldingLayer
이전 댓글 표시
I am trying to input a sequence of array into a convolution + LSTM neural network. The input data is 128x1 in 30744x1 cells. The neural network architecture is as followed:
layers = [ ...
sequenceInputLayer([128 1 1],'Name','input') %Sequence input with 1 dimension
sequenceFoldingLayer('Name','fold')
convolution2dLayer([3 1],16,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
maxPooling2dLayer([2 1],'Stride',1,'Name','maxpool1')
convolution2dLayer([3 1],32,'Name','conv2')
batchNormalizationLayer('Name','bn1')
reluLayer('Name','relu1')
maxPooling2dLayer([2 1],'Stride',1, 'Name','maxpool2')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
bilstmLayer(128,'OutputMode','last','Name','bilstm') %Number of layers
fullyConnectedLayer(256, 'Name','fc')
dropoutLayer(0.5, 'Name','do')
fullyConnectedLayer(128, 'Name','fc2')
dropoutLayer(0.5, 'Name','do2')
fullyConnectedLayer(4, 'Name','fc3') %()the number of the input/output
dropoutLayer(0.5, 'Name','do3')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification') %Classify the data into corresponding group
]
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
The error message poped up stated this is an invalid network
Caused by:
Layer 'fold': Unconnected output. Each layer output must be connected to the input of another layer.
Detected unconnected outputs:
output 'miniBatchSize'
Layer 'unfold': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'miniBatchSize'
I read through the documentation about sequenceFoldingLayer. The example inside only mention I should connect the layers with these
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
댓글 수: 1
Anshika Chaurasia
2021년 9월 17일
Hi,
I ran your code on R2021a and it's not giving any error.
답변 (1개)
Boban Sazdic-Jotic
2022년 5월 31일
Helo,
I had the same problem, however I managed to solve this in the following way:
- this is the network code :
layers = [ ...
sequenceInputLayer(inputSize,'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(filterSize,numFilters,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','last','Name','lstm')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
- this is the code for training:
netTransfer = trainNetwork(augimdsTrain,lgraph,options);
All the best
Boban
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!