Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpecifiedIndex causes INDArray#get(INDArrayIndex[]) to remove dimensions with a single element. #6341

DrChainsaw opened this issue Sep 2, 2018 · 1 comment


Copy link

commented Sep 2, 2018

The testcase below fails (second assert) on windows 10 using beta 2 (both CPU and CUDA 9.2). Removing specified index or using NDArrayIndex#interval causes testcase to pass.

   public void testSpecifiedIndexArraySize1() {
       final long[] shapeOk = {2, 2, 2, 2};
       final long[] shapeNok = {1, 2, 2, 1};

       final INDArray ok = Nd4j.create(shapeOk);
       final INDArrayIndex[] noChange = IntStream.range(0, shapeOk.length).mapToObj(dummy -> NDArrayIndex.all()).toArray(INDArrayIndex[]::new);
       noChange[1] = new SpecifiedIndex(IntStream.range(0, (int) shapeOk[1]).toArray());
       assertArrayEquals("Incorrect shape!", ok.shape(), ok.get(noChange).shape());

       final INDArray nok = Nd4j.create(shapeNok);
       final INDArrayIndex[] noChangeAgain = IntStream.range(0, shapeOk.length).mapToObj(dummy -> NDArrayIndex.all()).toArray(INDArrayIndex[]::new);

       // Comment line below to make testcase pass
       noChangeAgain[1] = new SpecifiedIndex(IntStream.range(0, (int) shapeNok[1]).toArray());

       // Uncomment line below to make testcase pass
       // noChangeAgain[1] = NDArrayIndex.interval(0, shapeNok[1]);
       assertArrayEquals("Incorrect shape!", nok.shape(), nok.get(noChangeAgain).shape());

@AlexDBlack AlexDBlack self-assigned this Sep 3, 2018

AlexDBlack added a commit that referenced this issue Sep 4, 2018
ND4J indexing fixes + DL4J fix (#6353)
* #6327 INDArray.put with SpecifiedIndex

* #6341 - SpecifiedIndex with single value no longer collapses dimensions

* Another indexing fix

* #6343 TransferLearning nOutReplace fix

This comment has been minimized.

Copy link

commented Oct 4, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Oct 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
2 participants
You can’t perform that action at this time.