Answers.Body: <p>Approaches I have seen/used: </p>
  
  <p><strong>Scenario 1:</strong> The angle is in between 2 vectors of some form, in which case, <span class="math-container">$[-\pi, 0)$</span> and <span class="math-container">$[0, \pi)$</span> are equivalent. (In vector space there always exists two angles between vectors: <span class="math-container">$\theta$</span> and <span class="math-container">$1-\theta$</span> )  </p>
  
  <ol>
  <li>Use the sigmoid <span class="math-container">$\sigma$</span> function to put it between 0 and 1, and then scale to <span class="math-container">$[0, \pi)$</span>. Since you arent modeling the whole rotation in this case, this works decently because the 2 ends dont have to be modeled as equivalent  </li>
  <li>Use cosine similarity, learn 2 vector representations and use <span class="math-container">$cos\ \theta = \frac{v_1^T v_2}{||v_1||*||v_2||}$</span> and then you could use the arccos.  </li>
  </ol>
  
  <p><strong>Scenario 2:</strong> Wanting to learn an angle on the unit circle, meaning <span class="math-container">$\theta$</span> vs <span class="math-container">$1-\theta$</span> is very important and so your bound is <span class="math-container">$[-\pi, \pi)$</span>  </p>
  
  <ol>
  <li>Use a sinusoidal activation and multiply by <span class="math-container">$\pi$</span> (ex: <span class="math-container">$z=\pi*sin(x)$</span>) This way you model the periodic nature of circling the unit circle (the activation eventually roates backs to itself continuously)</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-31T19:13:48.063Z
Answers.LastActivityDate: 2019-07-31T19:13:48.063Z
Answers.UserDisplayName: mshlis
Answers.Body: <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-31T07:50:07.317Z
Answers.LastActivityDate: 2019-07-31T07:50:07.317Z
Answers.UserDisplayName: David
Body: <p>I am building a model which predicts angles as output. What are the different kinds of outputs that can be used to predict angles?</p>
  
  <p>For example,</p>
  
  <ol>
  <li>output the angle in radians
  
  <ul>
  <li>cyclic nature of the angles is not captured</li>
  <li>output might be outside <span class="math-container">$\left[-\pi, \pi \right)$</span></li>
  </ul></li>
  <li>output the sine and the cosine of the angle
  
  <ul>
  <li>outputs might not satisfy <span class="math-container">$\sin^2 \theta + \cos^2 \theta = 1$</span></li>
  </ul></li>
  </ol>
  
  <p>What are the pros and cons of different methods?</p>
  
Tags: <deep-learning><deep-neural-networks><network-design>
Title: What kind of output should be used for predicting angles in DNNs?
UserDisplayName: Yashas
ThreadText: # What kind of output should be used for predicting angles in DNNs?
  
  (Asked by: username_0 on 2019-07-31)
  
  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?
  
  **Tags:** deep-learning, deep-neural-networks, network-design
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-07-31. Score: 1
  
  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)
  
  
  ---
  
  ### Answer by username_2 on 2019-07-31. Score: 1
  
  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.
  
  
  ---
  
  