Answers.Body: <p>we start with  </p>
  
  <p><span class="math-container">$\frac{\partial}{\partial \theta} \mathbb E_{q(\mathbf w\mid\theta)}[f(\mathbf w, \theta)]$</span></p>
  
  <p>using definition of expectation for continuous case:  </p>
  
  <p><span class="math-container">$\mathbb E[X] = \int xp(x) dx$</span>  </p>
  
  <p>for the first equation we get:  </p>
  
  <p><span class="math-container">$\frac{\partial}{\partial \theta} \int f(\mathbf w, \theta)q(\mathbf w \mid \theta) d\mathbf w$</span>  </p>
  
  <p>we swap <span class="math-container">$q(\mathbf w \mid \theta) d\mathbf w$</span> for <span class="math-container">$q(\epsilon)d\epsilon$</span> and we get:  </p>
  
  <p><span class="math-container">$\frac{\partial}{\partial \theta} \int f(\mathbf w, \theta)q(\epsilon)d\epsilon$</span>  </p>
  
  <p>using definition of expectation again we have:  </p>
  
  <p><span class="math-container">$\frac{\partial}{\partial \theta} \mathbb E_{q(\epsilon)}[f(\mathbf w,\theta)]$</span>  </p>
  
  <p>i believe dominant convergence theorem let's us interchange expectation and derivative and we have:  </p>
  
  <p><span class="math-container">$\mathbb E_{q(\epsilon)}[\frac{\partial}{\partial \theta}f(\mathbf w,\theta)]$</span>  </p>
  
  <p>we have a function <span class="math-container">$f$</span> that depends on two variables <span class="math-container">$\mathbf w$</span> and <span class="math-container">$\theta$</span>. In order to get a full derivative of such function we need to take derivative of <span class="math-container">$f$</span> with respect to both variables. We have:  </p>
  
  <p><span class="math-container">$\mathbb E_{q(\epsilon)}[\frac{\partial f(\mathbf w,\theta)}{\partial \theta} + \frac{\partial f(\mathbf w,\theta)}{\partial \mathbf w} \frac{\partial \mathbf w}{\partial \theta}]$</span>  </p>
  
  <p>First term inside expectation is derivative of function <span class="math-container">$f$</span> with respect to <span class="math-container">$\theta$</span> directly, and in the second term <span class="math-container">$f$</span> is derivated with respect to <span class="math-container">$\mathbf w$</span>, but we need to apply chain rule to get full derivative with respect to <span class="math-container">$\theta$</span> </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T13:52:08.527Z
Answers.Text: Thank you for your answer. This solves it. I stared at this for a while but did not take into account that $\textbf{w}$ is a function of $\theta$.
Answers.UserDisplayName: TimvanSch
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T12:54:29.510Z
Answers.LastActivityDate: 2019-02-22T13:02:14.230Z
Answers.LastEditDate: 2019-02-22T13:02:14.230Z
Answers.UserDisplayName: Brale
Body: <p>I'm going through the paper <a href="https://arxiv.org/pdf/1505.05424.pdf" rel="nofollow noreferrer"><em>Weight Uncertainty in Neural Networks</em></a> by Google Deepmind. In the final line of the proof of proposition 1, the integral and the derivative are swapped. Then the derivative is taken. But this somehow yields 2 derivatives of <span class="math-container">$f$</span> with respect to <span class="math-container">$\theta$</span>. I thought that this was the result of a product rule applied to <span class="math-container">$q(\epsilon)$</span> and <span class="math-container">$f(w,\theta)$</span> and then the chain rule. But that does not yield the same outcome as <span class="math-container">$\frac{\partial q(\epsilon)}{\partial \theta} = 0 $</span>. My question is: does anyone understand how the equation in the last line comes about?</p>
  
  <p><a href="https://i.sstatic.net/U7BeO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/U7BeO.png" alt="Proposition 1"></a></p>
  
Tags: <neural-networks><bayesian-networks><expectation>
Title: Problem with Proposition 1 of Google Deepmind's 'Weight uncertainty in Neural Networks'
UserDisplayName: TimvanSch
ThreadText: # Problem with Proposition 1 of Google Deepmind's 'Weight uncertainty in Neural Networks'
  
  (Asked by: username_0 on 2019-02-22)
  
  I'm going through the paper [*Weight Uncertainty in Neural Networks*](https://arxiv.org/pdf/1505.05424.pdf) by Google Deepmind. In the final line of the proof of proposition 1, the integral and the derivative are swapped. Then the derivative is taken. But this somehow yields 2 derivatives of $f$ with respect to $\theta$. I thought that this was the result of a product rule applied to $q(\epsilon)$ and $f(w,\theta)$ and then the chain rule. But that does not yield the same outcome as $\frac{\partial q(\epsilon)}{\partial \theta} = 0 $. My question is: does anyone understand how the equation in the last line comes about?
  
  [![Proposition 1](https://i.sstatic.net/U7BeO.png)](https://i.sstatic.net/U7BeO.png)
  
  **Tags:** neural-networks, bayesian-networks, expectation
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-22. Score: 2
  
  we start with
  
  $\frac{\partial}{\partial \theta} \mathbb E\_{q(\mathbf w\mid\theta)}[f(\mathbf w, \theta)]$
  
  using definition of expectation for continuous case:
  
  $\mathbb E[X] = \int xp(x) dx$
  
  for the first equation we get:
  
  $\frac{\partial}{\partial \theta} \int f(\mathbf w, \theta)q(\mathbf w \mid \theta) d\mathbf w$
  
  we swap $q(\mathbf w \mid \theta) d\mathbf w$ for $q(\epsilon)d\epsilon$ and we get:
  
  $\frac{\partial}{\partial \theta} \int f(\mathbf w, \theta)q(\epsilon)d\epsilon$
  
  using definition of expectation again we have:
  
  $\frac{\partial}{\partial \theta} \mathbb E\_{q(\epsilon)}[f(\mathbf w,\theta)]$
  
  i believe dominant convergence theorem let's us interchange expectation and derivative and we have:
  
  $\mathbb E\_{q(\epsilon)}[\frac{\partial}{\partial \theta}f(\mathbf w,\theta)]$
  
  we have a function $f$ that depends on two variables $\mathbf w$ and $\theta$. In order to get a full derivative of such function we need to take derivative of $f$ with respect to both variables. We have:
  
  $\mathbb E\_{q(\epsilon)}[\frac{\partial f(\mathbf w,\theta)}{\partial \theta} + \frac{\partial f(\mathbf w,\theta)}{\partial \mathbf w} \frac{\partial \mathbf w}{\partial \theta}]$
  
  First term inside expectation is derivative of function $f$ with respect to $\theta$ directly, and in the second term $f$ is derivated with respect to $\mathbf w$, but we need to apply chain rule to get full derivative with respect to $\theta$
  
  > **Comments:**
  > **username_0**: Thank you for your answer. This solves it. I stared at this for a while but did not take into account that $\textbf{w}$ is a function of $\theta$.  
  
  ---
  
  