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$ )
- 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
- 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)$
- 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)