# What is the correct partial derivative of $Y^c$ with respect to $A_{ij}^{kc}$?

I have a question about the Grad-CAM++ paper. I do not understand how the following equation (10) for the alphas is obtained: $$\alpha_{ij}^{kc} = \frac{\frac{\partial^2 Y^c}{(\partial A_{ij}^k)^2}} {2\frac{\partial^2 Y^c}{(\partial A_{ij}^k)^2} + \sum_{ab} A_{ab}^k \{ \frac{\partial^3 Y^c}{(\partial A_{ij}^k)^3} \}} \qquad (10)$$ I found various issues with the derivation, here I will focus on the step from equation (7) to (8).

Equation (7) without the relu function is: $$Y^c = \sum_k \Bigl( \Bigl\{ \sum_{a,b} \alpha_{ab}^{kc} \cdot \frac{\partial Y^c}{\partial A_{ab}^k} \Bigr\} \Bigl[ \sum_{i,j} A_{ij}^k \Bigr] \Bigr) \qquad (7)$$ Here $$Y^c$$ is supposed to be a function of the $$A_{ij}^k$$, and $$\alpha_{ab}^{kc}$$ are unknowns to be determined.

The next step consists of computing the partial derivative of (7) w.r.t. $$A_{ij}^{kc}$$, which according to the paper yields equation (8): $$\frac{\partial Y^c}{\partial A_{jk}^k} = \sum_{a,b} \alpha_{ab}^{kc} \cdot \frac{\partial Y^c}{\partial A_{ab}^k} + \sum_{a,b} A_{ab}^k \Bigl\{ \alpha_{ij}^{kc} \cdot \frac{\partial^2 Y^c}{(\partial A_{jk}^k)^2} \Bigr\} \qquad (8)$$ However, when I did the computation myself I got the following: $$\frac{\partial Y^c}{\partial A_{ij}^k} = \sum_{a,b} \alpha_{ab}^{kc} \cdot \frac{\partial Y^c}{\partial A_{ab}^k} + \sum_l \Bigl(\Bigl[\sum_{u,v} A_{uv}^l \Bigr] \Bigl\{ \sum_{a,b} \alpha_{ab}^{lc} \cdot \frac{\partial^2 Y^c}{\partial A_{ij}^k \partial A_{ab}^l} \Bigr\} \Bigr) \qquad (8')$$ Note the extra sum, and the cross-derivatives.

What is right, (8) or (8')?

After some reflection I noticed that the actual final expression should contain derivatives of the alphas w.r.t. $$A_{ij}^k$$ too, because the alphas cannot be constants that do not depend on $$A_{ij}^k$$. So, the equation becomes: $$\frac{\partial Y^c}{\partial A_{ij}^k} = \sum_{a,b} \alpha_{ab}^{kc} \cdot \frac{\partial Y^c}{\partial A_{ab}^k} + \sum_l \Bigl(\Bigl[\sum_{u,v} A_{uv}^l \Bigr] \Bigl\{ \sum_{a,b} \alpha_{ab}^{lc} \cdot \frac{\partial^2 Y^c}{\partial A_{ij}^k \partial A_{ab}^l} \Bigr\} \Bigr) + \sum_l \Bigl( \Bigl[\sum_{u,v} A_{uv}^l\Bigr] \Bigl\{ \sum_{a,b} \frac{\partial \alpha_{ab}^{lc}}{\partial A_{ij}^k} \cdot \frac{\partial Y^c}{\partial A_{ab}^l} \Bigr\} \Bigr)$$ More details in the appendix of this document.