Customized cost function for trainlm fitnet Matlab 2018b or newer

I would like to use the following function as the cost funcion insted of the built in cost function for trainlm, mse, msereg, and sse:
where J is the new cost function I want to use, and n is the total number of training samples.
The reason for such function, however, is to incentivize network to fit small values. Since the values of (y predict - y target) sometimes have a huge variance eventhough the training data is normalized and scaled between -1 and 1. I'm using netfit, trainlm as a training algorithm, and tansig as a transfer function in my model.
Please let me know if it is possible to use the above function as a cost function with trainlm in netfit function and if it is possible how it can be implemented?
Thank you

Answers (0)

Asked:

on 2 Dec 2019

Edited:

on 2 Dec 2019

Community Treasure Hunt

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

Start Hunting!