Skip to content

Commit 7333fe8

Browse files
committed
add math formula for exclusive/inclusive mode in avg pool. test=develop
1 parent 8f1e398 commit 7333fe8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

paddle/fluid/operators/pool_op.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,23 @@ The input(X) size and output(Out) size may be different.
242242
W_{out} = \\frac{(W_{in} - ksize[1] + 2 * paddings[1] + strides[1] - 1)}{strides[1]} + 1
243243
$$
244244
245+
For exclusive = true:
246+
$$
247+
hstart = i * strides[0] - paddings[0]
248+
hend = hstart + ksize[0]
249+
wstart = j * strides[1] - paddings[1]
250+
wend = wstart + ksize[1]
251+
Output(i ,j) = \\frac{sum(Input[hstart:hend, wstart:wend])}{ksize[0] * ksize[1]}
252+
$$
253+
For exclusive = false:
254+
$$
255+
hstart = max(0, i * strides[0] - paddings[0])
256+
hend = min(H, hstart + ksize[0])
257+
wstart = max(0, j * strides[1] - paddings[1])
258+
wend = min(W, wstart + ksize[1])
259+
Output(i ,j) = \\frac{sum(Input[hstart:hend, wstart:wend])}{(hend - hstart) * (wend - wstart)}
260+
$$
261+
245262
)DOC");
246263
}
247264

0 commit comments

Comments
 (0)