How to implement a cost/loss matrix for classifier CNN?

Hi,
I have a CNN to classify data into 9 categories. Because the classes are sequential in nature I would like to weight the results so that misclassifications to a next-door neighbor have less penalty than the other misclassifications. My thinking to do so is to implement a cost or loss matrix to add higher penalty to the misclassifications that are not to a next-door neighbor. However, I cannot seem to find any examples or documentation outside of this: https://www.mathworks.com/help/stats/prediction-using-discriminant-analysis-models.html#bs31mt5 and https://www.mathworks.com/help/stats/classreg.learning.classif.compactclassificationdiscriminant-class.html
Niether of those approaches seem to work with a CNN but instead require discriminant analysis and gaussian methods. I am new to machine learning in matlab and would appreciate any insight into how I can apply a cost matrix to my CNN training or prediction sets. Has anyone been able to implement a cost/loss matrix for a NN?
I would like to improve my outcomes - as seen in this confusion chart:

Answers (0)

Asked:

on 22 Jul 2020

Edited:

on 22 Jul 2020

Community Treasure Hunt

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

Start Hunting!