Java Code Examples for org.nd4j.linalg.api.ndarray.INDArray#addColumnVector()

The following examples show how to use org.nd4j.linalg.api.ndarray.INDArray#addColumnVector() . 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: InputValidationTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidColVectorOp2() {
    INDArray first = Nd4j.create(10, 10);
    INDArray col = Nd4j.create(5, 1);
    try {
        first.addColumnVector(col);
        fail("Should have thrown IllegalStateException");
    } catch (IllegalStateException e) {
        //OK
    }
}
 
Example 2
Source File: OpExecutionerTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddBroadcast() {
    INDArray arr = Nd4j.linspace(1, 6, 6).reshape('f', 2, 3);
    INDArray arrRow = Nd4j.create(new double[] {1, 2, 3});
    INDArray assertion = Nd4j.create(new double[] {2, 3, 5, 6, 8, 9}, new int[] {2, 3}, 'f');
    INDArray add = arr.addRowVector(arrRow);
    assertEquals(assertion, add);

    INDArray colVec = Nd4j.linspace(1, 2, 2).reshape(2, 1);
    INDArray colAssertion = Nd4j.create(new double[] {2, 4, 4, 6, 6, 8}, new int[] {2, 3}, 'f');
    INDArray colTest = arr.addColumnVector(colVec);
    assertEquals(colAssertion, colTest);
}
 
Example 3
Source File: InputValidationTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidColVectorOp2() {
    INDArray first = Nd4j.create(10, 10);
    INDArray col = Nd4j.create(5, 1);
    try {
        first.addColumnVector(col);
        fail("Should have thrown IllegalStateException");
    } catch (IllegalStateException e) {
        //OK
    }
}
 
Example 4
Source File: OpExecutionerTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddBroadcast() {
    INDArray arr = Nd4j.linspace(1, 6, 6, DataType.DOUBLE).reshape('f', 2, 3);
    INDArray arrRow = Nd4j.create(new double[] {1, 2, 3});
    INDArray assertion = Nd4j.create(new double[] {2, 3, 5, 6, 8, 9}, new int[] {2, 3}, 'f');
    INDArray add = arr.addRowVector(arrRow);
    assertEquals(assertion, add);

    INDArray colVec = Nd4j.linspace(1, 2, 2, DataType.DOUBLE).reshape(2, 1);
    INDArray colAssertion = Nd4j.create(new double[] {2, 4, 4, 6, 6, 8}, new int[] {2, 3}, 'f');
    INDArray colTest = arr.addColumnVector(colVec);
    assertEquals(colAssertion, colTest);
}