Basic question
Is the some existing mathematical notation to mean "treat this term as a constant when differentiating"? This would be the equivalent of detach
in pytorch or stop_gradient
in tensorflow and jax.
When I asked this on twitter a helpful suggestion was that $\bot$ (\bot
) had been used in one paper (https://arxiv.org/abs/1802.05098), and sg
in another (https://arxiv.org/abs/1711.00937). I'll use $\bot$ in the examples below.
I'd like to know if there is a well known notation for this in some literature.
Trivial example for basic question
If $x$ is a function of $t$ we could express $\frac{\partial}{\partial t} f(x,t)$ as $\frac{d}{dt} f(\bot x, t)$.
Extended question
It would be nice to have notation meaning "treat as a constant when differentiating with respect to a particular variable, but otherwise treat as normal" e.g. $\bot_\phi$
Real example covering extended question
In a variational inference derivation I've defined:
$$\mathcal{K}(\phi_1, \phi_2) = E[ \log \pi(\theta_1, \theta_2) + \log f(y_1 | \theta_1) + \log f(y_2 | \theta_1, \theta_2) - \log q_1(\theta_1; \phi_1) - \log q_2(\theta_2 | \theta_1; \phi_2)]. $$
I'd like to calculate $\nabla_{\phi_1} \mathcal{K}$ zeroing out certain terms, but $\nabla_{\phi_2} \mathcal{K}$ without zeroing out anything. It would be nice to write this by defining: $$\mathcal{K}(\phi_1, \phi_2) = E[ \log \pi(\theta_1, \theta_2) + \log f(y_1 | \theta_1) + \bot_{\phi_1}[\log f(y_2 | \theta_1, \theta_2)] - \log q_1(\theta_1; \phi_1) - \bot_{\phi_1}[\log q_2(\theta_2 | \theta_1; \phi_2)]]. $$
For completeness, here's the details of the other notation used in this example:
- $\pi(\theta_1, \theta_2)$ is a prior density for the parameters.
- $f(y_1, \theta_1)$ and $f(y_2 | \theta_1, \theta_2)$ are densities for two observations.
- The generative definition of the approximate posterior is: $$ \theta_1 = g(\epsilon_1, \phi_1), \theta_2 = g(\theta_1, \epsilon_2, \phi_2), \epsilon_1 \sim N(0,I), \epsilon_2 \sim N(0,I). $$ so that the expectation in the defintion of $\mathcal{K}$ is over $\epsilon_1$ and $\epsilon_2$
- The densities for the approximate posterior are $q(\theta_1; \phi_1), q(\theta_2 | \theta_1; \phi_2)$.
stop gradient
would need to go in the code - I'll need to go back to my derivation and think about this. Definitely a good option! $\endgroup$