Calculating t-SNE gradient (a mistake in the original t-SNE paper) This is specific to the way the gradient of the KL divergence Loss function was derived in the original paper Visualizing Data using tSNE.
In the Appendix A (Page 21), where they derive the gradient, the Equation (27) is given as
$$
\frac{\partial C}{\partial d_{ij}} = -  \sum_{k \neq l} p_{kl}  \bigg ( \frac{1}{q_{kl}Z} \frac{\partial ((1+d_{kl}^2)^{-1})}{\partial d_{ij}} -
 \frac{1}{Z} \frac{\partial Z}{\partial d_{ij}} \bigg )
$$
Evaluating the partial differentials specifically for $q_{ij}$ (which is the only dependent factor), we get
$$
\frac{\partial C}{\partial d_{ij}} = 2 \frac{p_{ij}}{q_{ij}Z} (1 + d_{ij}^2)^{-2}d_{ij} - 2 \sum_{k \neq l} p_{kl} \frac{(1 + d_{ij}^2)^{-2}d_{ij}}{Z}
$$
But in their equation (28), there is no extra $d_{ij}$ term. What am I missing here? 
 A: I just signed up for this forum due to your question :)
Nice question! It shows someone is indeed trying to follow & derive the nitty gritty. Your question is totally valid, (28) is indeed missing the $d_{ij}$, but then (24) is missing a $d_{ij}^{-1}$, you can see that from (21) via $\frac{\partial d_{ij}}{\partial y_i}$, taking into account that $$\frac{\partial \lVert\mathbf x\rVert}{\partial x_i} = \frac{x_i}{\lVert\mathbf x\rVert}.$$
So at the end everything is correct again! :P
A: Let our cost function be $C=KL(P||Q)=\sum_k\sum_{l\neq k}p_{kl}\log(p_{kl})-p_{kl}\log(q_{kl})$, so that we are trying to find the gradient $\frac{\partial C}{\partial y_i}$.
We will define some intermediate terms to try and simplify the notation; let $d_{ij}=||y_i-y_j||=d_{ji}$, and let $W=\sum_{k\neq l}(1+d_{kl}^2)^{-1}$.
With that, lets now think about what terms are important to $C$ when we change just $y_i$.
Notice that the only terms in $C$ that depend on $y_i$ are $d_{ij}$ and $d_{ji}$ for all of the $j$'s.
Using the chain rule, and the symmetry of $d_{ij}=d_{ji}$, this gives us:
$$
\frac{\partial C}{\partial y_{i}} =2\sum_j\frac{\partial C}{\partial d_{ij}}\frac{\partial d_{ij}}{\partial y_i}\\\\
\text{Where} \frac{\partial d_{ij}}{y_{ij}}=\frac{y_i-y_j}{||y_i-y_j||}=\frac{y_i-y_j}{d_{ij}}\\\\
\frac{\partial C}{\partial y_{i}}=2\sum_j\frac{\partial C}{\partial d_{ij}}\frac{y_i-y_j}{d_{ij}}\\\\
$$
The first step is to find $\frac{\partial C}{\partial d_{ij}}$; we get:
$$
\frac{\partial C}{\partial d_{ij}}= \frac{\partial}{\partial d_{ij}}\sum_k\sum_{l\neq k}p_{kl}\log(p_{kl})-p_{kl}\log(q_{kl})\\\\\
= -\sum_k\sum_{l\neq k}p_{kl}\frac{\partial}{\partial d_{ij}}\log\left(\frac{(1+d_{kl}^2)^{-1}}{W}\right)\\\\
= -\sum_k\sum_{l\neq k}p_{kl}\left(-\frac{\partial}{\partial d_{ij}}\log(W) -\frac{\partial}{\partial d_{ij}}\log(1+d_{kl}^2)\right)\\\\
= -\sum_k\sum_{l\neq k}p_{kl}\left(-\frac{1}{W}\frac{\partial}{\partial d_{ij}}(W) - \frac{1}{1+d_{kl}^2}\frac{\partial}{\partial  d_{ij}}(1+d_{kl}^2)\right)\\\\
=\sum_k\sum_{l\neq k}\frac{p_{kl}}{1+d_{kl}^2}\frac{\partial}{\partial d_{ij}}(1+d_{kl}^2) + \sum_k\sum_{l\neq k}\frac{p_{kl}}{W}\frac{\partial}{\partial d_{ij}}W\\\\
$$
Lets start with the first summations which has the term $\frac{\partial}{\partial d_{ij}}(1+d_{kl}^2)$.
Notice that this is 0 except when $k=i$ and $l=j$.
And when $k=i,l=j$, we get $\frac{\partial}{\partial d_{ij}}(1+d_{kl}^2) = 2d_{ij}$.
This makes:
$$\sum_k\sum_{l\neq k}\frac{p_{kl}}{1+d_{kl}^2}\frac{\partial}{\partial d_{ij}}(1+d_{kl}^2)=\frac{2d_{ij}p_{ij}}{1+d_{ij}^2}
$$
Lets now look at the second double sum term which has $\frac{1}{W}\frac{\partial}{\partial d_{ij}}W$.
Recall that $W=\sum_{k\neq l}(1+d_{kl}^2)^{-1}$, which means $\frac{\partial W}{\partial d_{ij}}$ is 0 when $k\neq i$ or $l\neq j$.
So the only non-zero term is when $k=i, l=j$, and we get $\frac{1}{W}\frac{\partial W}{\partial d_{ij}}=\frac{-2d_{ij}(1+d_{ij}^2)^{-2}}{W}$.
Also notice that $q_{ij}=\frac{(1+d_{ij}^2)^{-1}}{W}$; this makes:
$$\sum_k\sum_{l\neq k}\frac{p_{kl}}{W}\frac{\partial W}{\partial d_{ij}}=-2\sum_k\sum_{l\neq k}\frac{p_{kl}d_{ij}(1+d_{ij}^2)^{-2}}{W}\\\\
= -2d_{ij}q_{ij}(1+d_{ij}^2)^{-1}\sum_k\sum_{l\neq k}p_{kl}\\\\
\text{Notice that} \sum_k\sum_{l\neq k}p_{kl}=1\text{, so...}\\\\
=-2d_{ij}q_{ij}(1+d_{ij}^2)^{-1}\\
$$
Stitching this all back together, we get:
$$\frac{\partial C}{\partial d_{ij}}=\sum_k\sum_{l\neq k}\frac{p_{kl}}{1+d_{kl}^2}\frac{\partial}{\partial d_{ij}}(1+d_{kl}^2) + \sum_k\sum_{l\neq k}\frac{p_{kl}}{W}\frac{\partial W}{\partial d_{ij}}\\\\
=2d_{ij}p_{ij}(1+d_{ij}^2)^{-1} - 2d_{ij}1_{ij}(1+d_{ij}^2)^{-1}\\\\
= 2d_{ij}(1+d_{ij}^2)^{-1}(p_{ij}-1_{ij})\\\\
$$
Now that we have $\frac{\partial C}{\partial d_{ij}}$, we can plug this back in to $\frac{\partial C}{\partial y_i}$, to get:
$$\frac{\partial C}{\partial y_i}=2\sum_j\frac{\partial C}{\partial d_{ij}}\frac{(y_i-y_j)}{d_{ij}}\\\\
=2\sum_j2d_{ij}(1+d_{ij}^2)^{-1}(p_{ij}-1_{ij})\frac{(y_i-y_j)}{d_{ij}}\\\\
=4\sum_j(p_{ij}-q_{ij})(1+d_{ij}^2)^{-1}(y_i-y_j)\\\\
\frac{\partial C}{\partial d_{ij}}= 4\sum_j(p_{ij}-q_{ij})(1+||y_i-y_j||^2)^{-1}(y_i-y_j)
$$
