Skip to content

Commit 1cd700d

Browse files
authored
Fix bug in LRN operator. (#9124)
1 parent b5a16dc commit 1cd700d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

paddle/fluid/operators/lrn_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct LRNFunctor<platform::CPUDeviceContext, T> {
3636
auto e_x = framework::EigenTensor<T, 4>::From(input);
3737
for (int m = 0; m < N; m++) {
3838
for (int i = 0; i < C; i++) {
39-
for (int c = start; c <= end; c++) {
39+
for (int c = start; c < end; c++) {
4040
int ch = i + c;
4141
if (ch >= 0 && ch < C) {
4242
auto s = e_mid.slice(Eigen::array<int, 4>({{m, i, 0, 0}}),
@@ -92,7 +92,7 @@ struct LRNGradFunctor<platform::CPUDeviceContext, T> {
9292
Eigen::array<int, 4>({{1, 1, H, W}}));
9393

9494
i_x_g = i_mid.pow(-beta) * i_out_g;
95-
for (int c = start; c <= end; c++) {
95+
for (int c = start; c < end; c++) {
9696
int ch = i + c;
9797
if (ch < 0 || ch >= C) {
9898
continue;

python/paddle/fluid/tests/unittests/test_lrn_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_out(self):
4141
mid.fill(self.k)
4242
for m in range(0, self.N):
4343
for i in range(0, self.C):
44-
for c in range(start, end + 1):
44+
for c in range(start, end):
4545
ch = i + c
4646
if ch < 0 or ch >= self.C:
4747
continue

0 commit comments

Comments
 (0)