use of org.nd4j.linalg.api.ops.impl.broadcast.BroadcastMulOp in project nd4j by deeplearning4j.
the class StandardizeStrategy method revert.
/**
* Denormalize a data array
*
* @param array the data to denormalize
* @param stats statistics of the data population
*/
@Override
public void revert(INDArray array, INDArray maskArray, DistributionStats stats) {
if (array.rank() <= 2) {
array.muliRowVector(filteredStd(stats));
array.addiRowVector(stats.getMean());
} else {
Nd4j.getExecutioner().execAndReturn(new BroadcastMulOp(array, filteredStd(stats), array, 1));
Nd4j.getExecutioner().execAndReturn(new BroadcastAddOp(array, stats.getMean(), array, 1));
}
if (maskArray != null) {
DataSetUtil.setMaskedValuesToZero(array, maskArray);
}
}
use of org.nd4j.linalg.api.ops.impl.broadcast.BroadcastMulOp in project nd4j by deeplearning4j.
the class MinMaxStrategy method revert.
/**
* Denormalize a data array
*
* @param array the data to denormalize
* @param stats statistics of the data population
*/
@Override
public void revert(INDArray array, INDArray maskArray, MinMaxStats stats) {
// Subtract target range minimum value
array.subi(minRange);
// Scale by target range
array.divi(maxRange - minRange);
if (array.rank() <= 2) {
array.muliRowVector(stats.getRange());
array.addiRowVector(stats.getLower());
} else {
Nd4j.getExecutioner().execAndReturn(new BroadcastMulOp(array, stats.getRange(), array, 1));
Nd4j.getExecutioner().execAndReturn(new BroadcastAddOp(array, stats.getLower(), array, 1));
}
if (maskArray != null) {
DataSetUtil.setMaskedValuesToZero(array, maskArray);
}
}
use of org.nd4j.linalg.api.ops.impl.broadcast.BroadcastMulOp in project nd4j by deeplearning4j.
the class OpExecutionerTestsC method testBroadcastMultiDim.
@Test
public void testBroadcastMultiDim() {
INDArray data = Nd4j.linspace(1, 30, 30).reshape(2, 3, 5);
System.out.println(data);
INDArray mask = Nd4j.create(new double[][] { { 1.00, 1.00, 1.00, 1.00, 1.00 }, { 1.00, 1.00, 1.00, 0.00, 0.00 } });
Nd4j.getExecutioner().exec(new BroadcastMulOp(data, mask, data, 0, 2));
INDArray assertion = Nd4j.create(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 0.0, 0.0, 21.0, 22.0, 23.0, 0.0, 0.0, 26.0, 27.0, 28.0, 0.0, 0.0 }).reshape(2, 3, 5);
assertEquals(assertion, data);
}
Aggregations