neural network regression model error

1 view (last 30 days)
aman hari
aman hari on 14 Jul 2019
Answered: Divya Gaddipati on 17 Jul 2019
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

Answers (1)

Divya Gaddipati
Divya Gaddipati on 17 Jul 2019
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.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!