Skip to content

Conversation

@gramalingam
Copy link
Contributor

@anirudhacharya there seems to be an off-by-one error in the LRN test-case also (or parenthesization error).

@gramalingam gramalingam requested a review from linkerzhang June 8, 2018 19:54
for n, c, h, w in np.ndindex(x.shape):
square_sum[n, c, h, w] = sum(x[n,
max(0, c - int(math.floor((nsize - 1) / 2))):min(4, c + int(math.ceil((nsize - 1) / 2)) + 1),
max(0, c - int(math.floor((nsize - 1) / 2))):min(5, c + int(math.ceil((nsize - 1) / 2)) + 1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I tested this on both numpy and with mxnet as backend. here 5 is the size of the array and 4 is the index. infact having 5 here will give ArrayIndexOutOfBoundsException.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, numpy indexing is upper-bound exclusive. You mentioned previously that the "test case has a +1 because numpy indexing is upper-bound exclusive." The +1 appears only in the second argument of "min". Shouldn't you either move the +1 outside the min or, equivalently, have a +1 for both arguments of "min"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run this modified version, it works fine for me. If I use the original value of 4, I get incorrect results. Is it possible that you have different parenthesization in your mxnet version (with +1 outside min) than in the above file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @gramalingam, since the upper bound is exclusive, we should use C (i.e., 5) instead of C-1 in this case. I locally tested the script, it worked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gramalingam yes in my test example, I had the +1 outside the parentheses.

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gramalingam also update the generated input and output data (.pb files) please.

Copy link
Contributor

@anirudhacharya anirudhacharya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

for n, c, h, w in np.ndindex(x.shape):
square_sum[n, c, h, w] = sum(x[n,
max(0, c - int(math.floor((nsize - 1) / 2))):min(4, c + int(math.ceil((nsize - 1) / 2)) + 1),
max(0, c - int(math.floor((nsize - 1) / 2))):min(5, c + int(math.ceil((nsize - 1) / 2)) + 1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gramalingam yes in my test example, I had the +1 outside the parentheses.

@anirudhacharya
Copy link
Contributor

the window size parameter for LRN is supposed to take only odd values. Could you please update the spec?

@houseroad
Copy link
Member

@anirudhacharya I think there is no need to forbid even values.

@houseroad houseroad merged commit c647994 into onnx:master Jun 15, 2018
onnxbot added a commit to onnx/onnx-coreml that referenced this pull request Jun 15, 2018
onnxbot added a commit to pytorch/pytorch that referenced this pull request Jun 15, 2018
Ac2zoom pushed a commit to Ac2zoom/onnx that referenced this pull request Jun 21, 2018
* fix upper-bound for local-region in lrn test case

* generate lrn test data output

* Update the docs
@gramalingam gramalingam deleted the lrn-test-case-fix branch November 30, 2018 18:56
jcwchen pushed a commit to jcwchen/onnx that referenced this pull request Sep 23, 2020
* fix upper-bound for local-region in lrn test case

* generate lrn test data output

* Update the docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants