Hi Vladislav,
To reduce the error in closed-loop mode, you can try the following steps:
- Increase the training data by providing a large diverse dataset that can improve the model’s ability to generalise. Also, allowing the network to train for more epochs can reduce the error obtained.
- Optimize the network parameters by modifying the network layer size, delays and the training function. While ‘trainlm’ is a good choice, other functions like ‘trainbr’ (Bayesian Regularization) or ‘trainscg’ (Scaled conjugate gradient) might yield better results.
- Perform data normalization and regularization to avoid overfitting which becomes significant in closed-loops.
To address the output consistency with different inputs, refer the following steps:
- Ensure that the network is properly initialized each time you test with new inputs. Random initialization of weights can sometimes lead to unexpected results.
- Double-check that the new input data (‘input3’) is being prepared correctly and matches the format of the training data. Ensure that the variables ‘entrada’ and ‘saida’ are properly aligned and preprocessed.
- In closed-loop mode, the network uses its own predictions as inputs for future predictions. Ensure that this feedback mechanism is correctly set up and that the network isn't stuck in a loop with constant output due to feedback issues.
- If the network output is saturated (e.g., due to activation function limits), this could cause constant outputs. Consider changing the activation functions if necessary.
You can also visualize immediate outputs, perform verbose training and experiment with the hyperparameters by using grid search to debug the network better and find the best network configuration. By carefully examining these areas, you should be able to improve the closed-loop performance and resolve the issue with constant outputs. For more information regarding the NARX networks, refer the following documentations:
- Narxnet Multistep forecast within the time series: https://www.mathworks.com/matlabcentral/answers/279654-narxnet-multistep-forecast-within-the-time-series
- Multi Step Ahead Prediction: https://www.mathworks.com/matlabcentral/answers/14970-neural-network-multi-step-ahead-prediction
- NARX Feedback neural networks: https://www.mathworks.com/help/deeplearning/ug/design-time-series-narx-feedback-neural-networks.html
- trainbr: https://www.mathworks.com/help/deeplearning/ref/trainbr.html
- trainscg: https://www.mathworks.com/help/deeplearning/ref/trainscg.html
Hope this helps!