Hi Zimo!



 ZimoNitrome:

Can a model instead output a modular value?


Rather than outputting a single value that is your angle, I think it makes
more geometric sense to output two values, x and y, on the ray that
defines your angle.  Then regulate your x and y by pushing them
towards (but not constraining them to lie on) the unit circle with a term
like loss_reg = (1.0 - (x**2 + y**2))**2.
You do now have the redundancy of using two values to represent a
single angle, but geometrically this representation is “unbiased,” so
I think this outweighs any disadvantage of the redundancy.
If, at some point, you need an actual angle, you can use
theta = torch.atan2 (y, x), but I would avoid converting
x and y to an angle until you actually need to.
Best.
K. Frank