Layer 'fc1': Invalid input data for fully connected layer. The input data must not have both spatial and temporal dimensions.
17 次查看(过去 30 天)
显示 更早的评论
My network:
Layers = [ ...
sequenceInputLayer([50,1,3],'Name','retina');
reluLayer('Name','relu1');
fullyConnectedLayer(400,'Name','fc1')
reluLayer('Name','relu2');
fullyConnectedLayer(200,'Name','fc2')
reluLayer('Name','relu3');
fullyConnectedLayer(100,'Name','fc3')
reluLayer('Name','relu4');
fullyConnectedLayer(64);
regressionLayer('Name','output')];
The first fully connected layers seems to think its input contains both spatial and temporal numbers:
[net,netinfo] = trainNetwork(trainInput,trainTarget,Layers,options);
Caused by:
Layer 'fc1': Invalid input data for fully connected layer. The input
data must not have both spatial and temporal dimensions.
Which is not true. It is only spatial and with three "spectral" instances per spatial point (50 in total)
How is MATLAB able to judge this?
How to fix it?
0 个评论
回答(1 个)
Sanjana
2023-6-5
Hi Mads,
I understand that you are encountering some difficulties with using the "fully connected layer". The error message you encountered indicates that the input to a fully connected layer should be a 1D vector, rather than a matrix or grid. The purpose of a fully connected layer is to learn weights for each input feature and combine them to produce meaningful output.
One possible solution to solve this problem is to use a “flatten layer” before the fully connected layer, as the “flatten layer” flattens the input into a 1D vector. This allows the fully connected layer to receive the flattened input and perform its computations effectively.
Please refer to the following link, for further information on “flatten layer”,
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!