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

Extend/improve Preconditions class #6451

AlexDBlack opened this issue Sep 17, 2018 · 1 comment · Fixed by #6470


Copy link

commented Sep 17, 2018

It would be quite helpful to extend the capabilities of the preconditions class to be able to do things like:

INDArray x = ...
Preconditions.checkState(x.rank() == 2, "Expected rank 2 - got array with rank %ndRank and shape %ndShape", x, x);

I'm finding that some of the types of preconditions I would like to write cannot be done using Preconditions without object creation for the non-error case (like an INDArray.shape() call).
Of course, they can be done with an if statement and IllegalArgumentException, but that's more verbose to write.

Edit: some useful NDArray formatting values could potentially be:

  • %ndRank
  • %ndShape
  • %ndStride
  • %ndLength
  • %ndDataType
  • %ndShapeInfo
  • %ndValues[10]

Edit 2: class names would also be useful. For example, Class.getSimpleName() results in object creation on each call.

@AlexDBlack AlexDBlack self-assigned this Sep 20, 2018

AlexDBlack added a commit that referenced this issue Sep 20, 2018
AlexDBlack added a commit that referenced this issue Sep 21, 2018
AlexDBlack added a commit that referenced this issue Sep 23, 2018
DL4J/ND4J Misc fixes (#6470)
* #6431 SimpleRNN respect biasInit config value

* #6457 FileSplit android compatibility

* #6451 Improve preconditions class

* Fix pad op mapping

* #6471 Check for OutputLayer as first step in MultiLayerNetwork.computeGradientAndScore()

* Fix Reverse op mapping; map HistogramFixedWidth

* Fix HistogramfixedWidth mapping

* Fix DeConv2DTF op import mapping

* Fix unsorted op mapping

* HistogramFixedWidth fix; map DynamicPartitionBp

* Conv3d and OneHot test fixes

* More test fixes/re-enabling

* Restore ReverseV2 op

* Test tweaks

This comment has been minimized.

Copy link

commented Oct 24, 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 24, 2018

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