Java Code Examples for org.nd4j.linalg.api.shape.Shape#assertBroadcastable()
The following examples show how to use
org.nd4j.linalg.api.shape.Shape#assertBroadcastable() .
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: BaseDynamicTransformOp.java From nd4j with Apache License 2.0 | 5 votes |
@Override public List<long[]> calculateOutputShape() { val args = args(); if(args.length < 2) { if(args[0] == null || args[0].getShape() == null) { return Collections.emptyList(); } return Arrays.asList(args[0].getShape()); } val firstArgShape = args[0].getShape(); val secondArgShape = args[1].getShape(); if(args[0] == null || args[0].getShape() == null) { return Collections.emptyList(); } if(args[1] == null || args[1].getShape() == null) { return Collections.emptyList(); } if(Arrays.equals(firstArgShape, secondArgShape)){ return Collections.singletonList(firstArgShape); } //Handle broadcast shape: [1,4]+[3,1] = [3,4] Shape.assertBroadcastable(firstArgShape, secondArgShape); val outShape = Shape.broadcastOutputShape(firstArgShape, secondArgShape); return Collections.singletonList(outShape); }
Example 2
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public INDArray divi(INDArray other, INDArray result) { validateNumericalArray("divi", false); Shape.assertBroadcastable("divi", this, other, result); Nd4j.exec(new DivOp(this, other, result)); return result; }
Example 3
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public INDArray muli(INDArray other, INDArray result) { validateNumericalArray("muli", false); Shape.assertBroadcastable("muli", this, other, result); Nd4j.exec(new MulOp(this, other, result)); return result; }
Example 4
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * in place subtraction of two matrices * * @param other the second ndarray to subtract * @param result the result ndarray * @return the result of the subtraction */ @Override public INDArray subi(INDArray other, INDArray result) { validateNumericalArray("subi", false); Shape.assertBroadcastable("subi", this, other, result); Nd4j.exec(new SubOp(this, other, result)); return result; }
Example 5
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public INDArray addi(INDArray other, INDArray result) { validateNumericalArray("addi", false); Shape.assertBroadcastable("addi", this, other, result); Nd4j.exec(new AddOp(this, other, result)); return result; }
Example 6
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public INDArray rdivi(INDArray other, INDArray result) { validateNumericalArray("rdivi", false); Shape.assertBroadcastable("rdivi", this, other, result); Nd4j.exec(new RDivOp(this, other, result)); return result; }
Example 7
Source File: BaseNDArray.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public INDArray rsubi(INDArray other, INDArray result) { validateNumericalArray("rsubi", false); Shape.assertBroadcastable("rsubi", this, other, result); Nd4j.exec(new RSubOp(this, other, result)); return result; }