Looking for a similar type of function np.round_(in_array, decimals = 2) which can operate on INDArray in java. Basically want to round off all the digits in INDArray up to some precision.
Ex : Given an array
in_array = [.5538, 1.33354, .71445]
When i round it off to two-digit I am expecting the output as
array([0.55, 1.33, 0.71])
Nd4j has a normal round function but not for a specified number of decimals. If you want that just for formatting purposes we can do the following:
yourPrecision is the number of decimal places you want eg: 2,3. For your example:
Edit: since it appears we need them rounded in the actual function itself you'll have to use a custom java function and iterate over the array manually. Something like:
Just be cautious of the data type when doing this.
Credit to: https://www.studytonight.com/java-examples/how-to-round-a-number-to-n-decimal-places-in-java
which gives a fairly good explanation with caveats. Your custom rounder could be something like: