Search in sources :

Example 1 with Min

use of org.nd4j.linalg.api.ops.impl.accum.Min in project nd4j by deeplearning4j.

the class CudaAccumTests method testDimensionMax.

@Test
public void testDimensionMax() {
    INDArray linspace = Nd4j.linspace(1, 6, 6).reshape('f', 2, 3);
    int axis = 0;
    INDArray row = linspace.slice(axis);
    System.out.println("Linspace: " + linspace);
    System.out.println("Row: " + row);
    System.out.println("Row shapeInfo: " + row.shapeInfoDataBuffer());
    Max max = new Max(row);
    double max2 = Nd4j.getExecutioner().execAndReturn(max).getFinalResult().doubleValue();
    assertEquals(5.0, max2, 1e-1);
    Min min = new Min(row);
    double min2 = Nd4j.getExecutioner().execAndReturn(min).getFinalResult().doubleValue();
    assertEquals(1.0, min2, 1e-1);
}
Also used : Min(org.nd4j.linalg.api.ops.impl.accum.Min) INDArray(org.nd4j.linalg.api.ndarray.INDArray) Max(org.nd4j.linalg.api.ops.impl.accum.Max) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 INDArray (org.nd4j.linalg.api.ndarray.INDArray)1 Max (org.nd4j.linalg.api.ops.impl.accum.Max)1 Min (org.nd4j.linalg.api.ops.impl.accum.Min)1