Error with 1dPooling in dlnetwork
이전 댓글 표시
Hi,
I'm having the following error when trying to initialize my dlnetwork :
Layer 'Attention_D': Input data must have two spatial dimensions only, one spatial dimension and one temporal dimension, or two spatial dimensions and one temporal dimension. Instead, it has 0 spatial dimensions and 0 temporal dimensions.
I have seen the work around proposed in https://www.mathworks.com/matlabcentral/answers/1935274-i-m-having-trouble-with-convolution1dlayer, that recommends to use 2d pooling with a poolsize of [ D 1 ] instead of 1d pooling with size D. However, this work-around requires to replace the FeatureInputLayer by an ImageInputLayer.
My problem is : my network aims to classify sequential data, and as a result uses a SequentialInputLayer.
I can't figure how to use the work around on it. Is it possible to use an ImageInputLayer in my case ? My sequences have more than 1 feature/channel.
Or is there another way to deal with this error ?
FYI, my layers are as follow :
layers = [ ...
sequenceInputLayer(numPredictors, Name="Query")
lstmLayer(numHiddenUnits,OutputMode="last", Name="Encoder")
lstmLayer(numHiddenUnits,OutputMode="sequence", Name="Decoder")
averagePooling2dLayer([poolSizeD,1], Name="Attention_D")
fullyConnectedLayer(numClasses, Name="Classifier")
softmaxLayer];
댓글 수: 1
Matt J
2024년 10월 21일
We need to see the output of,
analyzeNetwork(net,X1,...,Xn)
채택된 답변
추가 답변 (1개)
You can use functionLayers to reformat the activations as the averagePooling layers require, but make sure you set the spatial dimension S to the dimension you intend to pool.
numPredictors=10;
numHiddenUnits=14;
poolSizeD=3;
sequenceLength=20;
numClasses=2;
numBatch=5;
layers = [ ...
sequenceInputLayer(numPredictors, Name="Query")
lstmLayer(numHiddenUnits,OutputMode="last", Name="Encoder")
lstmLayer(numHiddenUnits,OutputMode="sequence", Name="Decoder")
%reformat activation as spatial-batch-channel (SBC)
functionLayer( @(x)dlarray(x, "SBC"), Formattable=true)
averagePooling1dLayer(poolSizeD, Name="Attention_D")
fullyConnectedLayer(numClasses, Name="Classifier")
softmaxLayer];
analyzeNetwork(layers,...
dlarray(rand(sequenceLength,numPredictors,numBatch),'TCB'))

카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
