Answers.Body: <blockquote>
  <p>If the gradients are noisy (does this mean that in some dimension we have small and in some high curvature or that error noise differs for very similar values of w?)</p>
  </blockquote>
  <p>Gradients being noisy means that they are &quot;inconsistent&quot; across different epochs / training steps. With that I mean that they'll sometimes point in one direction, later in a different (maybe the opposite) direction, etc., that the gradients at different time steps give inconsistent/conflicting information, that we don't consistently keep following the same direction through gradient descent but keep jumping all over the place. Note that this is <strong>across epochs</strong>, it's <strong>not across different dimensions within the same epoch</strong>.</p>
  <p>So, for example, we might have a vector of gradients that looks like <span class="math-container">$[1, 1, 1, \dots, 1]$</span> at one time step (i.e., positive gradients in all dimensions), and the next training step get a gradient more like <span class="math-container">$[-1, -1, -1, \dots, -1]$</span> (this example is pretty much the &quot;most extreme&quot; kind of noise you can have, completely conflicting directions, in reality it'd generally be less extreme).</p>
  <p>Such &quot;noisy gradients&quot; can exist because, in practice, we almost always use <strong>estimates</strong> of the gradient of our loss function, rather than the <strong>true</strong> gradients (which we'll generally not even be able to compute). For example, if we have a very large training dataset in a supervised learning setting, we'd ideally use the gradient of the loss function computed across the complete dataset. That tends to be computationally expensive (requires forwards and backwards passes for every single instance in the dataset), so in practice we'll often only use a small minibatch to estimate the gradient; this can result in widely different estimates of the gradient for different minibatches. <em>(note: there can also be different reasons for using minibatches rather than full dataset, such as avoiding overfitting, but that's not too important to consider for this specific question)</em></p>
  <p>A different example of a setting where we can have noisy gradients is in Deep Reinforcement Learning. There, computing the loss function itself is often rather noisy (in the sense that our own predictions, which tend to still be incorrect during the training phase, are a component of the targets that we're updating towards), so our estimates of the gradients will also be noisy.</p>
  <hr />
  <p>Derivation for your second question, about the gradient of the loss with respect to <span class="math-container">$\mathbf{v}$</span>:</p>
  <p>We start with the following, from Equation (3) in the paper (this gradient you understand, right?):</p>
  <p><span class="math-container">$$\nabla_{\mathbf{v}} L = \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g \nabla_g L}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v}$$</span></p>
  <p>Note that Equation (3) also gives:</p>
  <p><span class="math-container">$$\nabla_{g} L = \frac{\nabla_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}$$</span></p>
  <p>If we plug that into the previous Equation we get:</p>
  <p><span class="math-container">\begin{aligned}
  \nabla_{\mathbf{v}} L &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g \frac{\nabla_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v} \\
  &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g \nabla_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert^3} \mathbf{v} \\
  \end{aligned}</span></p>
  <p>The <span class="math-container">$\frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L$</span> term that shows up before the minus can also be isolated in the term after the minus:</p>
  <p><span class="math-container">\begin{aligned}
  \nabla_{\mathbf{v}} L &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v} \\
  &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert} \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert} \\
  \end{aligned}</span></p>
  <p>Equation (2) tells us that <span class="math-container">$\mathbf{w} = \frac{g}{\vert \vert \mathbf{v} \vert \vert} \mathbf{v}$</span>, which means that <span class="math-container">$\frac{\mathbf{w}}{g} = \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}$</span>. Plugging this into the above leads to:</p>
  <p><span class="math-container">\begin{aligned}
  \nabla_{\mathbf{v}} L &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \frac{\mathbf{w}}{g} \cdot \frac{\mathbf{w}}{g} \\
  \end{aligned}</span></p>
  <p>Below Equation (2), they also explain that <span class="math-container">$\vert \vert \mathbf{w} \vert \vert = g$</span>, so we can rewrite the above to:</p>
  <p><span class="math-container">\begin{aligned}
  \nabla_{\mathbf{v}} L &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \frac{\mathbf{w}}{\vert \vert \mathbf{w} \vert \vert} \cdot \frac{\mathbf{w}}{\vert \vert \mathbf{w} \vert \vert} \\
  &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \frac{\mathbf{w} \mathbf{w}'}{\vert \vert \mathbf{w} \vert \vert^2} \\
  \end{aligned}</span></p>
  <p>In that last step, the <span class="math-container">$'$</span> symbol in <span class="math-container">$\mathbf{w}'$</span> denotes that we transpose that vector.</p>
  <p>Finally, because we have that common <span class="math-container">$\frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L$</span> before and after the minus symbol, we can pull it out, multiplying it once by the identity matrix <span class="math-container">$\mathbf{I}$</span>, and once by the remaining negated term. This is very similar to how you would simplify something like <span class="math-container">$a - ax$</span> to <span class="math-container">$a (1 - x)$</span> in &quot;standard&quot; algebra; the identity matrix <span class="math-container">$\mathbf{I}$</span> plays a very similar role here to the number <span class="math-container">$1$</span> in &quot;standard&quot; algebra:</p>
  <p><span class="math-container">\begin{aligned}
  \nabla_{\mathbf{v}} L &amp;= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla_{\mathbf{w}} L \cdot \left( \mathbf{I} - \frac{\mathbf{w} \mathbf{w}'}{\vert \vert \mathbf{w} \vert \vert^2} \right) \\
  \end{aligned}</span></p>
  <p><strong>Note</strong>: in all of the above, I kind of neglected to pay attention to order of matrix/vector multiplications and their dimensions. Probably the <span class="math-container">$\nabla_{\mathbf{w}} L$</span> term should by now already have been moved to after those large brackets, instead of being before those brackets. In this case, it should work out fine regardless because <span class="math-container">$\mathbf{I}$</span> as well as <span class="math-container">$\mathbf{w} \mathbf{w}'$</span> are square <strong>and</strong> symmetric matrices. The only resulting difference is in whether you get a row or a column vector out at the end.</p>
  <p>This can now finally be rewritten as the Equation you mentioned that you didn't understand yet, Equation (4) in the paper.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-03T18:25:48.903Z
Answers.Text: Hi Dennis, that's it! Thank you for the explanation, now I understand what was meant in the paper! It seems that I really need to work on my math and ml basics. Thank you again for the explanation!
Answers.UserDisplayName: Grumpy C
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-03T19:08:51.243Z
Answers.Text: @GrumpyC Well, that depends on what you want to do exactly. The ability to reproduce these kinds of math details is very different from the ability to implement the ideas and/or roughly understand the intuition. It's definitely useful to have a good basis in Linear Algebra though.
Answers.UserDisplayName: Dennis Soemers
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-03T21:09:58.250Z
Answers.Text: Hi Dennis, I think that both is necessary, intuition is probably enough for most of the practicioners, but I cannot but admire silent elegance of mathematics, in describing the world. Well I should properly read and practice! :D Thank you again!
Answers.UserDisplayName: Grumpy C
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-03T18:03:24.430Z
Answers.LastActivityDate: 2020-07-06T23:12:15.373Z
Answers.LastEditDate: 2020-07-06T23:12:15.373Z
Answers.UserDisplayName: Dennis Soemers
Body: <p>I am trying to dissect the paper <a href="https://papers.nips.cc/paper/6114-weight-normalization-a-simple-reparameterization-to-accelerate-training-of-deep-neural-networks.pdf" rel="nofollow noreferrer">Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks</a>.</p>
  <p>Unfortunately, because my math is a little bit rusty, I got a little bit stuck with the proof. Could you provide me with some clarification about proof of the topic?</p>
  <p>What I understand is that we introduce, instead of the weight vector <span class="math-container">$w$</span> a scalar <span class="math-container">$g$</span> (magnitude of original <span class="math-container">$w$</span>?) and <span class="math-container">$\frac{v}{\|v\|}$</span> (direction of original <span class="math-container">$w$</span>?) of the vector.</p>
  <p><span class="math-container">$$\nabla_{g} L=\frac{\nabla_{\mathbf{w}} L \cdot \mathbf{v}}{\|\mathbf{v}\|}$$</span></p>
  <p>and</p>
  <p><span class="math-container">$$\nabla_{\mathbf{v}} L=\frac{g}{\|\mathbf{v}\|} \nabla_{\mathbf{w}} L-\frac{g \nabla_{g} L}{\|\mathbf{v}\|^{2}} \mathbf{v}$$</span></p>
  <p>What I am not really sure about is:</p>
  <p>If the gradients are noisy (does this mean that in some dimension we have small and in some high curvature or that error noise differs for very similar values of <span class="math-container">$w$</span>?) the value will quickly increase here and effectively limit the speed of descent by decreasing value of (<span class="math-container">$\frac{g}{\|v\|}$</span>). This means that we can choose larger learning rates and it will somehow adjust the effect of the learning rate during the training.</p>
  <p>And what I completely miss is:</p>
  <p><span class="math-container">$$\nabla_{\mathbf{v}} L=\frac{g}{\|\mathbf{v}\|} M_{\mathbf{w}} \nabla_{\mathbf{w}} L$$</span></p>
  <p>with</p>
  <p><span class="math-container">$$\mathrm{M}_{\mathrm{w}}=\mathrm{I}-\frac{\mathrm{w} \mathrm{w}^{\prime}}{\|\mathrm{w}\|^{2}}$$</span></p>
  <p>It should somehow explain the reasoning behind the idea of the final effects. Unfortunately, I don't really understand this part of the paper, I probably lack some knowledge about Linear Algebra.</p>
  <p>Can you verify that my understanding of the paper is correct?</p>
  <p>Can you recommend some sources (books/videos) to help me to understand the second part of proof (related to the second set of formulas?)</p>
  
Tags: <neural-networks><deep-learning><math><papers><weight-normalization>
Title: Can you help me understand how weight normalization works?
UserDisplayName: Grumpy C
ThreadText: # Can you help me understand how weight normalization works?
  
  (Asked by: username_0 on 2018-10-03)
  
  I am trying to dissect the paper [Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks](https://papers.nips.cc/paper/6114-weight-normalization-a-simple-reparameterization-to-accelerate-training-of-deep-neural-networks.pdf).
  
  Unfortunately, because my math is a little bit rusty, I got a little bit stuck with the proof. Could you provide me with some clarification about proof of the topic?
  
  What I understand is that we introduce, instead of the weight vector $w$ a scalar $g$ (magnitude of original $w$?) and $\frac{v}{\|v\|}$ (direction of original $w$?) of the vector.
  
  $$\nabla\_{g} L=\frac{\nabla\_{\mathbf{w}} L \cdot \mathbf{v}}{\|\mathbf{v}\|}$$
  
  and
  
  $$\nabla\_{\mathbf{v}} L=\frac{g}{\|\mathbf{v}\|} \nabla\_{\mathbf{w}} L-\frac{g \nabla\_{g} L}{\|\mathbf{v}\|^{2}} \mathbf{v}$$
  
  What I am not really sure about is:
  
  If the gradients are noisy (does this mean that in some dimension we have small and in some high curvature or that error noise differs for very similar values of $w$?) the value will quickly increase here and effectively limit the speed of descent by decreasing value of ($\frac{g}{\|v\|}$). This means that we can choose larger learning rates and it will somehow adjust the effect of the learning rate during the training.
  
  And what I completely miss is:
  
  $$\nabla\_{\mathbf{v}} L=\frac{g}{\|\mathbf{v}\|} M\_{\mathbf{w}} \nabla\_{\mathbf{w}} L$$
  
  with
  
  $$\mathrm{M}\_{\mathrm{w}}=\mathrm{I}-\frac{\mathrm{w} \mathrm{w}^{\prime}}{\|\mathrm{w}\|^{2}}$$
  
  It should somehow explain the reasoning behind the idea of the final effects. Unfortunately, I don't really understand this part of the paper, I probably lack some knowledge about Linear Algebra.
  
  Can you verify that my understanding of the paper is correct?
  
  Can you recommend some sources (books/videos) to help me to understand the second part of proof (related to the second set of formulas?)
  
  **Tags:** neural-networks, deep-learning, math, papers, weight-normalization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-03. Score: 2 | Accepted answer
  
  > If the gradients are noisy (does this mean that in some dimension we have small and in some high curvature or that error noise differs for very similar values of w?)
  
  Gradients being noisy means that they are "inconsistent" across different epochs / training steps. With that I mean that they'll sometimes point in one direction, later in a different (maybe the opposite) direction, etc., that the gradients at different time steps give inconsistent/conflicting information, that we don't consistently keep following the same direction through gradient descent but keep jumping all over the place. Note that this is **across epochs**, it's **not across different dimensions within the same epoch**.
  
  So, for example, we might have a vector of gradients that looks like $[1, 1, 1, \dots, 1]$ at one time step (i.e., positive gradients in all dimensions), and the next training step get a gradient more like $[-1, -1, -1, \dots, -1]$ (this example is pretty much the "most extreme" kind of noise you can have, completely conflicting directions, in reality it'd generally be less extreme).
  
  Such "noisy gradients" can exist because, in practice, we almost always use **estimates** of the gradient of our loss function, rather than the **true** gradients (which we'll generally not even be able to compute). For example, if we have a very large training dataset in a supervised learning setting, we'd ideally use the gradient of the loss function computed across the complete dataset. That tends to be computationally expensive (requires forwards and backwards passes for every single instance in the dataset), so in practice we'll often only use a small minibatch to estimate the gradient; this can result in widely different estimates of the gradient for different minibatches. *(note: there can also be different reasons for using minibatches rather than full dataset, such as avoiding overfitting, but that's not too important to consider for this specific question)*
  
  A different example of a setting where we can have noisy gradients is in Deep Reinforcement Learning. There, computing the loss function itself is often rather noisy (in the sense that our own predictions, which tend to still be incorrect during the training phase, are a component of the targets that we're updating towards), so our estimates of the gradients will also be noisy.
  
  ---
  
  Derivation for your second question, about the gradient of the loss with respect to $\mathbf{v}$:
  
  We start with the following, from Equation (3) in the paper (this gradient you understand, right?):
  
  $$\nabla\_{\mathbf{v}} L = \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g \nabla\_g L}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v}$$
  
  Note that Equation (3) also gives:
  
  $$\nabla\_{g} L = \frac{\nabla\_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}$$
  
  If we plug that into the previous Equation we get:
  
  \begin{aligned}
  \nabla\_{\mathbf{v}} L &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g \frac{\nabla\_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v} \\
  &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g \nabla\_{\mathbf{w}} L \cdot \mathbf{v}}{\vert \vert \mathbf{v} \vert \vert^3} \mathbf{v} \\
  \end{aligned}
  
  The $\frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L$ term that shows up before the minus can also be isolated in the term after the minus:
  
  \begin{aligned}
  \nabla\_{\mathbf{v}} L &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert^2} \mathbf{v} \\
  &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert} \cdot \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert} \\
  \end{aligned}
  
  Equation (2) tells us that $\mathbf{w} = \frac{g}{\vert \vert \mathbf{v} \vert \vert} \mathbf{v}$, which means that $\frac{\mathbf{w}}{g} = \frac{\mathbf{v}}{\vert \vert \mathbf{v} \vert \vert}$. Plugging this into the above leads to:
  
  \begin{aligned}
  \nabla\_{\mathbf{v}} L &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \frac{\mathbf{w}}{g} \cdot \frac{\mathbf{w}}{g} \\
  \end{aligned}
  
  Below Equation (2), they also explain that $\vert \vert \mathbf{w} \vert \vert = g$, so we can rewrite the above to:
  
  \begin{aligned}
  \nabla\_{\mathbf{v}} L &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \frac{\mathbf{w}}{\vert \vert \mathbf{w} \vert \vert} \cdot \frac{\mathbf{w}}{\vert \vert \mathbf{w} \vert \vert} \\
  &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L - \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \frac{\mathbf{w} \mathbf{w}'}{\vert \vert \mathbf{w} \vert \vert^2} \\
  \end{aligned}
  
  In that last step, the $'$ symbol in $\mathbf{w}'$ denotes that we transpose that vector.
  
  Finally, because we have that common $\frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L$ before and after the minus symbol, we can pull it out, multiplying it once by the identity matrix $\mathbf{I}$, and once by the remaining negated term. This is very similar to how you would simplify something like $a - ax$ to $a (1 - x)$ in "standard" algebra; the identity matrix $\mathbf{I}$ plays a very similar role here to the number $1$ in "standard" algebra:
  
  \begin{aligned}
  \nabla\_{\mathbf{v}} L &= \frac{g}{\vert \vert \mathbf{v} \vert \vert} \nabla\_{\mathbf{w}} L \cdot \left( \mathbf{I} - \frac{\mathbf{w} \mathbf{w}'}{\vert \vert \mathbf{w} \vert \vert^2} \right) \\
  \end{aligned}
  
  **Note**: in all of the above, I kind of neglected to pay attention to order of matrix/vector multiplications and their dimensions. Probably the $\nabla\_{\mathbf{w}} L$ term should by now already have been moved to after those large brackets, instead of being before those brackets. In this case, it should work out fine regardless because $\mathbf{I}$ as well as $\mathbf{w} \mathbf{w}'$ are square **and** symmetric matrices. The only resulting difference is in whether you get a row or a column vector out at the end.
  
  This can now finally be rewritten as the Equation you mentioned that you didn't understand yet, Equation (4) in the paper.
  
  > **Comments:**
  > **username_0**: Hi username_1, that's it! Thank you for the explanation, now I understand what was meant in the paper! It seems that I really need to work on my math and ml basics. Thank you again for the explanation!  
  > **username_1**: @username_0 Well, that depends on what you want to do exactly. The ability to reproduce these kinds of math details is very different from the ability to implement the ideas and/or roughly understand the intuition. It's definitely useful to have a good basis in Linear Algebra though.  
  > **username_0**: Hi username_1, I think that both is necessary, intuition is probably enough for most of the practicioners, but I cannot but admire silent elegance of mathematics, in describing the world. Well I should properly read and practice! :D Thank you again!  
  
  ---
  
  