# What kind of output should be used for predicting angles in DNNs?

I am building a model which predicts angles as output. What are the different kinds of outputs that can be used to predict angles?

For example,

1. output the angle in radians
• cyclic nature of the angles is not captured
• output might be outside $$\left[-\pi, \pi \right)$$
2. output the sine and the cosine of the angle
• outputs might not satisfy $$\sin^2 \theta + \cos^2 \theta = 1$$

What are the pros and cons of different methods?

As you said, the first option is not very suitable due to the cyclic nature of the angles. However, if you don't mind discretizing the values, you could represent the output as a binary vector.

A variant of the second option seems perfect to me. You may output a 2D vector and use that vector's angle as output. You'll probably need a regularizer for the vector's norm, but that's it.

Approaches I have seen/used:

Scenario 1: The angle is in between 2 vectors of some form, in which case, $$[-\pi, 0)$$ and $$[0, \pi)$$ are equivalent. (In vector space there always exists two angles between vectors: $$\theta$$ and $$1-\theta$$ )

1. Use the sigmoid $$\sigma$$ function to put it between 0 and 1, and then scale to $$[0, \pi)$$. Since you arent modeling the whole rotation in this case, this works decently because the 2 ends dont have to be modeled as equivalent
2. Use cosine similarity, learn 2 vector representations and use $$cos\ \theta = \frac{v_1^T v_2}{||v_1||*||v_2||}$$ and then you could use the arccos.

Scenario 2: Wanting to learn an angle on the unit circle, meaning $$\theta$$ vs $$1-\theta$$ is very important and so your bound is $$[-\pi, \pi)$$

1. Use a sinusoidal activation and multiply by $$\pi$$ (ex: $$z=\pi*sin(x)$$) This way you model the periodic nature of circling the unit circle (the activation eventually roates backs to itself continuously)