neural network regression model error

1 次查看(过去 30 天)
i used the following data to generate a dataset nd to train the network as shown but is getting the following error can someone help why this error comes
x = rand(1000,1);
y = sin(x)
options = trainingOptions('adam','Plots','training-progress','MaxEpochs',100)
net = trainNetwork(transpose(x),transpose(y),layers_1,options);
ERROR:
Training on single CPU.
|========================================================================================|
| Epoch | Iteration | Time Elapsed | Mini-batch | Mini-batch | Base Learning |
| | | (hh:mm:ss) | RMSE | Loss | Rate |
|========================================================================================|
Error using trainNetwork (line 165)
To RESHAPE the number of elements must not change.
Caused by:
Error using reshape
To RESHAPE the number of elements must not change.
Network MODEL:
Capture.JPG

回答(1 个)

Divya Gaddipati
Divya Gaddipati 2019-7-17
As I understand, your input dataset, “x” has size 1000 x 1 and the output, “y” has size 1000 x 1 and you are defining a regression model for predicting “y”.
In your model, the number of neurons in the last FC layer should match the dimension of “y”. Since, your output is 1-dimensional, the output size of the last Fully Connected (FC) layer used should also be 1. In case, your output “y” is of size 1000 x 2, then the output size of the FC layer should be 2.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by