I have a set of image data and I'm trying to train a neural network to predict a value in degrees as an output inside a range of [-180. 180)
. I don't like the idea of the large discontinuity between -180 and 180 (or equivalently 0 and 360) for essentially the same value, and I do not want to use categorization to solve this problem (like used here - although note that I am NOT doing image orientation correction) as this is a somewhat precise bearing angle.
One idea I had is to map the value in degrees onto trigonometric functions like sine and cosine that are continuous around 0 degrees. However, arcsine and arccosine are only defined between -90 and 90 degrees, so the inverse won't work for all angles. I could use some combination of arcsine and arccosine to get all possible degree values that could make sine or cosine output a certain value in my desired range, but then I would need to project onto both sine and cosine to uniquely identify my desired value in degrees as there are two possibilities for each.
This method seems like too much effort for a conceptually simple problem. Is there a better way that I can preprocess my values in degrees to make them more suitable for regression?
I'm using Python, so if there's some library function that can do this that's great, but the problem is more general.