The output size (100) of the last layer does not match theresponse size (40000).

2 次查看(过去 30 天)
I designed a very simple dnn, whose structure is shown in the figure.
layers = [
%Input Layers
featureInputLayer(40000);
%Hidden Layers
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(256)
reluLayer
% Output Layers
fullyConnectedLayer(100)
regressionLayer];
And the code i used to generate my trainset —— 2D signals and 2D signals affected by noise, I have put this .m file as an attachment. I want to be able to use neural networks to remove noise from the signal.
When I input my training set to train it, the system prompts me that there is an error.
layers = [
%Input Layers
featureInputLayer(40000);
%Hidden Layers
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(256)
reluLayer
% Output Layers
fullyConnectedLayer(100)
regressionLayer];
options = trainingOptions('adam', ...
'InitialLearnRate',0.001,...
'LearnRateSchedule','piecewise',...
'LearnRateDropFactor',0.9,...
'LearnRateDropPeriod',40,...
'ExecutionEnvironment', 'cpu', ...
'MiniBatchSize', 32, ...
'MaxEpochs', 500, ...
'ValidationData',{VaSet_o,VaSet_n},...
'L2Regularization',1.0000e-05,...
'Shuffle', 'every-epoch', ...
'Plots', 'training-progress', ...
'Verbose', false);
net = trainNetwork(TrainSet_n, TrainSet_o, layers, options);
Error using trainNetwork
Invalid validation data. The output size (100) of the last layer does not match the response size (40000).
Error using trainNetwork
Invalid training data. The output size (100) of the last layer does not match theresponse size (40000).
I am quite sure that the response size of my training set is 100 instead of 40000
OK, then I change the output size to 40000 but didn't modify my train set.
And the system the system told me that another error occurred.
The output size (40000) of the last layer does not match the response size (100).
Now how does the response size change back to 100????
WHY??????????
I really hope someone can help me, please.
This is very important to me.
  2 个评论
Matt J
Matt J 2023-2-17
编辑:Matt J 2023-2-17
It does seem strange, but please post your code as formatted text, e.g.,
a=1;
b=2;
instead of as images, so it is easy for us to copy/paste and run it. Also, please attach a subset of your features and response training data in a .mat file so that we can use it to run the code.
承显 郑
承显 郑 2023-2-18
Thank you very much for your answer, I have revised my question, it would be great if you could help me on that basis

请先登录,再进行评论。

采纳的回答

承显 郑
承显 郑 2023-2-18
After the problem was solved, I calmed down and thought about it again. I found that the two inputs in the option as the validation set were backfilled.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel and Cloud 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by