Simple neural network (for electricity price prediction) training problem

5 views (last 30 days)
I'm trying to train the following neural network, it has an input matrix of 26 variables and 6999 samples (I imported the dataset from excel and saved it as a numeric matrix). The output is 1x6999. It is a large data set (I attach it in the message) and using the app Neural Net Fitting the training takes 16 minutes approximately, but when I use my own designed network the training just goes for 6 seconds (and therefore, the results aren't good enough when I test it). I assume I'm not training it correctly, but I don't know where the problem is. I have already tried to change number of maxEpochs, MinitBatchsize or even increasing the number of hidden layers (the training keeps being too short). I know that I should use validation during the training but I guess this is not the problem.
Thank you in advance.
CODE:
X_train=INPUTSP12TRAIN;
Y_train=OUTPUTSP1TRAIN;
X_test=INPUTSP12TEST;
Y_test=OUTPUTSP1TEST;
layers = [
sequenceInputLayer(26,"Name","sequence","Normalization","zscore")
fullyConnectedLayer(200,"Name","fc_1")
reluLayer("Name","relu")
fullyConnectedLayer(1,"Name","fc_2")
regressionLayer("Name","regressionoutput")];
maxEpochs = 50;
miniBatchSize = 20;
options = trainingOptions('adam', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.01, ...
'GradientThreshold',1, ...
'Shuffle','every-epoch', ...
'Plots','training-progress',...
'Verbose',0);
net = trainNetwork(X_train,Y_train,layers,options);
Y_pred = predict(net,X_test,'MiniBatchSize',1);

Accepted Answer

Image Analyst
Image Analyst on 31 Mar 2022
Maybe it's okay. Compare the predictions against the ground truth and see how big the differences are.
I usually run for a few thousand epochs over 30 minutes to a full day, but that's for images.
  3 Comments
Image Analyst
Image Analyst on 31 Mar 2022
I know you see the RMSE going down to what you see as a small amount but my colleague said that sometime it goes down, then up, then down again (like yours). Since your down/up/down section was so close to the end of your training, I'm not sure it's the best it could be. Plus, like I said, I always do thousands of epochs. Since you did only 50, and it was so fast, it couldn't hurt to try a few thousand epochs.
I know you said that the predictions were already acceptable, but why not try letting it go further -- they may get more acceptable.
You might also try the Regression Learner app. It's on the Apps tab of the tool ribbon if you have the Statistics and Machine Learning Toolbox. There are dozens of models in there and it's possible that one of those standard models will be a better predictor than your deep learning model. The default deep learning models in there are fairly simple I think but I've never encountered a case where it said the Neural Network model was the best one. Usually I find that one of the GPR models is best, but sometimes it's a tree model.
Gonzalo Postigo Omeñaca
Gonzalo Postigo Omeñaca on 31 Mar 2022
Following your recommendations, I've just trained the network using a thousand of epochs and the results have significally improved. I have also included a validation set to prevent overfitting/underfitting. In addition, I used "zscore" normalization for the first script, but I've reached the conclusion that my model performs much better without normalization. I'll try the Regression Learner app in case I find a better predictor model too.
My question is totally answered with your guidelines, thank you again.
Best regards.

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!