How to make regression results to be integers？ I am working on a regression task, using cnn for feature extraction and fully-connected layers for generating regression values.
However, the target value of each input data is an integer. There are five possible target values: 1 representing 'hate',  2 representing 'dislike', ... , and the final target value 5 representing 'love'. (I know the task can also be considered as a classification task, but I need to implement it as a regression task.)
The evaluation metrics are rmse and mae. I want to make the DNN generate intergers as regression results, which can make the evaluation metrics better. At present, the DNN network will generate for example 4.012 for target value 4.
(Is there any other method than threshold? Or any method for learning the threshold automatically at the same time?. I am thinking about adding a classification layer connected to the second hidden layer to help the network learn the interger constraint.)
 A: What you’re doing is an ordinal regression task, which TensorFlow seems to support, and I recommend looking into this approach. At the same time, remember Box’s famous quote.

All models are wrong, but some are useful.

Perhaps you can get a useful model by forcing this into the wrong approach.
Once you accept that you’re forcing the problem into the wrong machinery to solve it, the easiest way to predict one of your ordinal levels is to force your data into a standard regression problem and round the predictions to the nearest integer, constrained to your range. TensorFlow allows for custom loss functions. This article seems to explain it decently. I would write the loss function to first round the prediction to the nearest integer, then use an if statement to constrain that rounded value to 1-5. Then write something for square or absolute loss, based on the rounded and constrained prediction.
Alternatively, you may prefer to use a continuous loss function that already exists in your software, such as MSE or MAE, and then just evaluate the rounded and constrained predictions.
