@@ -72,13 +72,13 @@ class GradCAM(_GradCAM):
7272 The localization map is computed as follows:
7373
7474 .. math::
75- L^{(c)}_{Grad-CAM}(x, y) = ReLU\\ Big(\\ sum\\ limits_k w_k^{(c)} A_k(x, y)\ \Big)
75+ L^{(c)}_{Grad-CAM}(x, y) = ReLU\Big(\sum\limits_k w_k^{(c)} A_k(x, y)\Big)
7676
7777 with the coefficient :math:`w_k^{(c)}` being defined as:
7878
7979 .. math::
80- w_k^{(c)} = \\ frac{1}{H \\ cdot W} \\ sum\\ limits_{i=1}^H \\ sum\ \limits_{j=1}^W
81- \\ frac{\\ partial Y^{(c)}}{\ \partial A_k(i, j)}
80+ w_k^{(c)} = \frac{1}{H \cdot W} \sum\limits_{i=1}^H \sum\limits_{j=1}^W
81+ \frac{\partial Y^{(c)}}{\partial A_k(i, j)}
8282
8383 where :math:`A_k(x, y)` is the activation of node :math:`k` in the target layer of the model at
8484 position :math:`(x, y)`,
@@ -114,26 +114,26 @@ class GradCAMpp(_GradCAM):
114114 The localization map is computed as follows:
115115
116116 .. math::
117- L^{(c)}_{Grad-CAM++}(x, y) = \\ sum\ \limits_k w_k^{(c)} A_k(x, y)
117+ L^{(c)}_{Grad-CAM++}(x, y) = \sum\limits_k w_k^{(c)} A_k(x, y)
118118
119119 with the coefficient :math:`w_k^{(c)}` being defined as:
120120
121121 .. math::
122- w_k^{(c)} = \\ sum\\ limits_{i=1}^H \\ sum\\ limits_{j=1}^W \\ alpha_k^{(c)}(i, j) \ \cdot
123- ReLU\\ Big(\\ frac{\\ partial Y^{(c)}}{\\ partial A_k(i, j)}\ \Big)
122+ w_k^{(c)} = \sum\limits_{i=1}^H \sum\limits_{j=1}^W \alpha_k^{(c)}(i, j) \cdot
123+ ReLU\Big(\frac{\partial Y^{(c)}}{\partial A_k(i, j)}\Big)
124124
125125 where :math:`A_k(x, y)` is the activation of node :math:`k` in the target layer of the model at
126126 position :math:`(x, y)`,
127127 :math:`Y^{(c)}` is the model output score for class :math:`c` before softmax,
128- and :math:`\\ alpha_k^{(c)}(i, j)` being defined as:
128+ and :math:`\alpha_k^{(c)}(i, j)` being defined as:
129129
130130 .. math::
131- \\ alpha_k^{(c)}(i, j) = \\ frac{1}{\\ sum\\ limits_{i, j} \\ frac{\\ partial Y^{(c)}}{\ \partial A_k(i, j)}}
132- = \\ frac{\\ frac{\\ partial^2 Y^{(c)}}{(\\ partial A_k(i,j))^2}}{2 \ \cdot
133- \\ frac{\\ partial^2 Y^{(c)}}{(\\ partial A_k(i,j))^2} + \\ sum\\ limits_{a,b} A_k (a,b) \ \cdot
134- \\ frac{\\ partial^3 Y^{(c)}}{(\ \partial A_k(i,j))^3}}
131+ \alpha_k^{(c)}(i, j) = \frac{1}{\sum\limits_{i, j} \frac{\partial Y^{(c)}}{\partial A_k(i, j)}}
132+ = \frac{\frac{\partial^2 Y^{(c)}}{(\partial A_k(i,j))^2}}{2 \cdot
133+ \frac{\partial^2 Y^{(c)}}{(\partial A_k(i,j))^2} + \sum\limits_{a,b} A_k (a,b) \cdot
134+ \frac{\partial^3 Y^{(c)}}{(\partial A_k(i,j))^3}}
135135
136- if :math:`\\ frac{\\ partial Y^{(c)}}{\ \partial A_k(i, j)} = 1` else :math:`0`.
136+ if :math:`\frac{\partial Y^{(c)}}{\partial A_k(i, j)} = 1` else :math:`0`.
137137
138138 Example::
139139 >>> from torchvision.models import resnet18
@@ -183,34 +183,34 @@ class SmoothGradCAMpp(_GradCAM):
183183 The localization map is computed as follows:
184184
185185 .. math::
186- L^{(c)}_{Smooth Grad-CAM++}(x, y) = \\ sum\ \limits_k w_k^{(c)} A_k(x, y)
186+ L^{(c)}_{Smooth Grad-CAM++}(x, y) = \sum\limits_k w_k^{(c)} A_k(x, y)
187187
188188 with the coefficient :math:`w_k^{(c)}` being defined as:
189189
190190 .. math::
191- w_k^{(c)} = \\ sum\\ limits_{i=1}^H \\ sum\\ limits_{j=1}^W \\ alpha_k^{(c)}(i, j) \ \cdot
192- ReLU\\ Big(\\ frac{\\ partial Y^{(c)}}{\\ partial A_k(i, j)}\ \Big)
191+ w_k^{(c)} = \sum\limits_{i=1}^H \sum\limits_{j=1}^W \alpha_k^{(c)}(i, j) \cdot
192+ ReLU\Big(\frac{\partial Y^{(c)}}{\partial A_k(i, j)}\Big)
193193
194194 where :math:`A_k(x, y)` is the activation of node :math:`k` in the target layer of the model at
195195 position :math:`(x, y)`,
196196 :math:`Y^{(c)}` is the model output score for class :math:`c` before softmax,
197- and :math:`\\ alpha_k^{(c)}(i, j)` being defined as:
197+ and :math:`\alpha_k^{(c)}(i, j)` being defined as:
198198
199199 .. math::
200- \\ alpha_k^{(c)}(i, j)
201- = \\ frac{\\ frac{\\ partial^2 Y^{(c)}}{(\\ partial A_k(i,j))^2}}{2 \ \cdot
202- \\ frac{\\ partial^2 Y^{(c)}}{(\\ partial A_k(i,j))^2} + \\ sum\\ limits_{a,b} A_k (a,b) \ \cdot
203- \\ frac{\\ partial^3 Y^{(c)}}{(\ \partial A_k(i,j))^3}}
204- = \\ frac{\\ frac{1}{n} \\ sum\ \limits_{m=1}^n D^{(c, 2)}_k(i, j)}{
205- \\ frac{2}{n} \\ sum\\ limits_{m=1}^n D^{(c, 2)}_k(i, j) + \\ sum\\ limits_{a,b} A_k (a,b) \ \cdot
206- \\ frac{1}{n} \\ sum\ \limits_{m=1}^n D^{(c, 3)}_k(i, j)}
207-
208- if :math:`\\ frac{\\ partial Y^{(c)}}{\ \partial A_k(i, j)} = 1` else :math:`0`. Here :math:`D^{(c, p)}_k(i, j)`
200+ \alpha_k^{(c)}(i, j)
201+ = \frac{\frac{\partial^2 Y^{(c)}}{(\partial A_k(i,j))^2}}{2 \cdot
202+ \frac{\partial^2 Y^{(c)}}{(\partial A_k(i,j))^2} + \sum\limits_{a,b} A_k (a,b) \cdot
203+ \frac{\partial^3 Y^{(c)}}{(\partial A_k(i,j))^3}}
204+ = \frac{\frac{1}{n} \sum\limits_{m=1}^n D^{(c, 2)}_k(i, j)}{
205+ \frac{2}{n} \sum\limits_{m=1}^n D^{(c, 2)}_k(i, j) + \sum\limits_{a,b} A_k (a,b) \cdot
206+ \frac{1}{n} \sum\limits_{m=1}^n D^{(c, 3)}_k(i, j)}
207+
208+ if :math:`\frac{\partial Y^{(c)}}{\partial A_k(i, j)} = 1` else :math:`0`. Here :math:`D^{(c, p)}_k(i, j)`
209209 refers to the p-th partial derivative of the class score of class :math:`c` relatively to the activation in layer
210210 :math:`k` at position :math:`(i, j)`, and :math:`n` is the number of samples used to get the gradient estimate.
211211
212- Please note the difference in the numerator of :math:`\\ alpha_k^{(c)}(i, j)`,
213- which is actually :math:`\\ frac{1}{n} \\ sum\ \limits_{k=1}^n D^{(c, 1)}_k(i,j)` in the paper.
212+ Please note the difference in the numerator of :math:`\alpha_k^{(c)}(i, j)`,
213+ which is actually :math:`\frac{1}{n} \sum\limits_{k=1}^n D^{(c, 1)}_k(i,j)` in the paper.
214214
215215 Example::
216216 >>> from torchvision.models import resnet18
@@ -311,14 +311,14 @@ class XGradCAM(_GradCAM):
311311 The localization map is computed as follows:
312312
313313 .. math::
314- L^{(c)}_{XGrad-CAM}(x, y) = ReLU\\ Big(\\ sum\\ limits_k w_k^{(c)} A_k(x, y)\ \Big)
314+ L^{(c)}_{XGrad-CAM}(x, y) = ReLU\Big(\sum\limits_k w_k^{(c)} A_k(x, y)\Big)
315315
316316 with the coefficient :math:`w_k^{(c)}` being defined as:
317317
318318 .. math::
319- w_k^{(c)} = \\ sum\\ limits_{i=1}^H \\ sum\ \limits_{j=1}^W
320- \\ Big( \\ frac{\\ partial Y^{(c)}}{\\ partial A_k(i, j)} \ \cdot
321- \\ frac{A_k(i, j)}{\\ sum\\ limits_{m=1}^H \\ sum\\ limits_{n=1}^W A_k(m, n)} \ \Big)
319+ w_k^{(c)} = \sum\limits_{i=1}^H \sum\limits_{j=1}^W
320+ \Big( \frac{\partial Y^{(c)}}{\partial A_k(i, j)} \cdot
321+ \frac{A_k(i, j)}{\sum\limits_{m=1}^H \sum\limits_{n=1}^W A_k(m, n)} \Big)
322322
323323 where :math:`A_k(x, y)` is the activation of node :math:`k` in the target layer of the model at
324324 position :math:`(x, y)`,
@@ -357,12 +357,12 @@ class LayerCAM(_GradCAM):
357357 The localization map is computed as follows:
358358
359359 .. math::
360- L^{(c)}_{Layer-CAM}(x, y) = ReLU\\ Big(\\ sum\\ limits_k w_k^{(c)}(x, y) \\ cdot A_k(x, y)\ \Big)
360+ L^{(c)}_{Layer-CAM}(x, y) = ReLU\Big(\sum\limits_k w_k^{(c)}(x, y) \cdot A_k(x, y)\Big)
361361
362362 with the coefficient :math:`w_k^{(c)}(x, y)` being defined as:
363363
364364 .. math::
365- w_k^{(c)}(x, y) = ReLU\\ Big(\\ frac{\\ partial Y^{(c)}}{\\ partial A_k(i, j)}(x, y)\ \Big)
365+ w_k^{(c)}(x, y) = ReLU\Big(\frac{\partial Y^{(c)}}{\partial A_k(i, j)}(x, y)\Big)
366366
367367 where :math:`A_k(x, y)` is the activation of node :math:`k` in the target layer of the model at
368368 position :math:`(x, y)`,
0 commit comments