Java Code Examples for org.nd4j.linalg.factory.Nd4j#accumulate()

The following examples show how to use org.nd4j.linalg.factory.Nd4j#accumulate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AveragingTests.java    From nd4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testAccumulation3() {
    // we want to ensure that cuda backend is able to launch this op on cpu
    Nd4j.getAffinityManager().allowCrossDeviceAccess(false);

    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray target = Nd4j.create(100);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(target, new INDArray[] {array1, array2, array3});

    assertEquals(exp, accum);
    assertTrue(accum == target);

    Nd4j.getAffinityManager().allowCrossDeviceAccess(true);
}
 
Example 2
Source File: AveragingTests.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testAccumulation3() {
    // we want to ensure that cuda backend is able to launch this op on cpu
    Nd4j.getAffinityManager().allowCrossDeviceAccess(false);

    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray target = Nd4j.create(100);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(target, new INDArray[] {array1, array2, array3});

    assertEquals(exp, accum);
    assertTrue(accum == target);

    Nd4j.getAffinityManager().allowCrossDeviceAccess(true);
}
 
Example 3
Source File: AveragingTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAccumulation1() {
    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(new INDArray[] {array1, array2, array3});

    assertEquals(exp, accum);
}
 
Example 4
Source File: AveragingTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAccumulation2() {
    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray target = Nd4j.create(100);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(target, new INDArray[] {array1, array2, array3});

    assertEquals(exp, accum);
    assertTrue(accum == target);
}
 
Example 5
Source File: AveragingTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAccumulation1() {
    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(array1, array2, array3);

    assertEquals(exp, accum);
}
 
Example 6
Source File: AveragingTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAccumulation2() {
    INDArray array1 = Nd4j.create(100).assign(1.0);
    INDArray array2 = Nd4j.create(100).assign(2.0);
    INDArray array3 = Nd4j.create(100).assign(3.0);
    INDArray target = Nd4j.create(100);
    INDArray exp = Nd4j.create(100).assign(6.0);

    INDArray accum = Nd4j.accumulate(target, new INDArray[] {array1, array2, array3});

    assertEquals(exp, accum);
    assertTrue(accum == target);
}