/** * In place addition of a column vector * * @param rowVector the row vector to add * @return the result of the addition */ @Override public INDArray subRowVector(INDArray rowVector) { return dup().subiRowVector(rowVector); }
/** * Normalize data to zero mean and unit variance * substract by the mean and divide by the standard deviation * * @param toNormalize the ndarray to normalize * @return the normalized ndarray */ public static INDArray normalizeZeroMeanAndUnitVariance(INDArray toNormalize) { INDArray columnMeans = toNormalize.mean(0); INDArray columnStds = toNormalize.std(0); toNormalize.subiRowVector(columnMeans); //padding for non zero columnStds.addi(Nd4j.EPS_THRESHOLD); toNormalize.diviRowVector(columnStds); return toNormalize; }
public static void normalizeMatrix(INDArray toNormalize) { INDArray columnMeans = toNormalize.mean(0); toNormalize.subiRowVector(columnMeans); INDArray std = toNormalize.std(0); std.addi(Nd4j.scalar(1e-12)); toNormalize.diviRowVector(std); }
/** * @Deprecated * Subtract by the column means and divide by the standard deviation */ @Deprecated @Override public void normalizeZeroMeanZeroUnitVariance() { INDArray columnMeans = getFeatures().mean(0); INDArray columnStds = getFeatureMatrix().std(0); setFeatures(getFeatures().subiRowVector(columnMeans)); columnStds.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD)); setFeatures(getFeatures().diviRowVector(columnStds)); }
/** * Normalize a data array * * @param array the data to normalize * @param stats statistics of the data population */ @Override public void preProcess(INDArray array, INDArray maskArray, DistributionStats stats) { if (array.rank() <= 2) { array.subiRowVector(stats.getMean()); array.diviRowVector(filteredStd(stats)); } // if array Rank is 3 (time series) samplesxfeaturesxtimesteps // if array Rank is 4 (images) samplesxchannelsxrowsxcols // both cases operations should be carried out in dimension 1 else { Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array, stats.getMean(), array, 1)); Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array, filteredStd(stats), array, 1)); } if (maskArray != null) { DataSetUtil.setMaskedValuesToZero(array, maskArray); } }
/** * Normalize a data array * * @param array the data to normalize * @param stats statistics of the data population */ @Override public void preProcess(INDArray array, INDArray maskArray, MinMaxStats stats) { if (array.rank() <= 2) { array.subiRowVector(stats.getLower()); array.diviRowVector(stats.getRange()); } // if feature Rank is 3 (time series) samplesxfeaturesxtimesteps // if feature Rank is 4 (images) samplesxchannelsxrowsxcols // both cases operations should be carried out in dimension 1 else { Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array, stats.getLower(), array, 1)); Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array, stats.getRange(), array, 1)); } // Scale by target range array.muli(maxRange - minRange); // Add target range minimum values array.addi(minRange); if (maskArray != null) { DataSetUtil.setMaskedValuesToZero(array, maskArray); } }
/** * In place addition of a column vector * * @param rowVector the row vector to add * @return the result of the addition */ @Override public INDArray subRowVector(INDArray rowVector) { return dup().subiRowVector(rowVector); }
@Override public INDArray preProcess(INDArray input, int miniBatchSize) { INDArray columnMeans = input.mean(0); input.subiRowVector(columnMeans); return input; }
@Override public INDArray preProcess(INDArray input, int miniBatchSize) { INDArray columnMeans = input.mean(0); INDArray columnStds = input.std(0); input.subiRowVector(columnMeans); columnStds.addi(Nd4j.EPS_THRESHOLD); input.diviRowVector(columnStds); return input; }
/** * Normalize data to zero mean and unit variance * substract by the mean and divide by the standard deviation * * @param toNormalize the ndarray to normalize * @return the normalized ndarray */ public static INDArray normalizeZeroMeanAndUnitVariance(INDArray toNormalize) { INDArray columnMeans = toNormalize.mean(0); INDArray columnStds = toNormalize.std(0); toNormalize.subiRowVector(columnMeans); //padding for non zero columnStds.addi(Nd4j.EPS_THRESHOLD); toNormalize.diviRowVector(columnStds); return toNormalize; }
public static void normalizeMatrix(INDArray toNormalize) { INDArray columnMeans = toNormalize.mean(0); toNormalize.subiRowVector(columnMeans); INDArray std = toNormalize.std(0); std.addi(Nd4j.scalar(1e-12)); toNormalize.diviRowVector(std); }
/** * @Deprecated * Subtract by the column means and divide by the standard deviation */ @Deprecated @Override public void normalizeZeroMeanZeroUnitVariance() { INDArray columnMeans = getFeatures().mean(0); INDArray columnStds = getFeatureMatrix().std(0); setFeatures(getFeatures().subiRowVector(columnMeans)); columnStds.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD)); setFeatures(getFeatures().diviRowVector(columnStds)); }
/** * Normalize a data array * * @param array the data to normalize * @param stats statistics of the data population */ @Override public void preProcess(INDArray array, INDArray maskArray, DistributionStats stats) { if (array.rank() <= 2) { array.subiRowVector(stats.getMean()); array.diviRowVector(filteredStd(stats)); } // if array Rank is 3 (time series) samplesxfeaturesxtimesteps // if array Rank is 4 (images) samplesxchannelsxrowsxcols // both cases operations should be carried out in dimension 1 else { Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array, stats.getMean(), array, 1)); Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array, filteredStd(stats), array, 1)); } if (maskArray != null) { DataSetUtil.setMaskedValuesToZero(array, maskArray); } }
/** * Normalize a data array * * @param array the data to normalize * @param stats statistics of the data population */ @Override public void preProcess(INDArray array, INDArray maskArray, MinMaxStats stats) { if (array.rank() <= 2) { array.subiRowVector(stats.getLower()); array.diviRowVector(stats.getRange()); } // if feature Rank is 3 (time series) samplesxfeaturesxtimesteps // if feature Rank is 4 (images) samplesxchannelsxrowsxcols // both cases operations should be carried out in dimension 1 else { Nd4j.getExecutioner().execAndReturn(new BroadcastSubOp(array, stats.getLower(), array, 1)); Nd4j.getExecutioner().execAndReturn(new BroadcastDivOp(array, stats.getRange(), array, 1)); } // Scale by target range array.muli(maxRange - minRange); // Add target range minimum values array.addi(minRange); if (maskArray != null) { DataSetUtil.setMaskedValuesToZero(array, maskArray); } }
X.subi(X.min(Integer.MAX_VALUE)); X = X.divi(X.max(Integer.MAX_VALUE)); X = X.subiRowVector(X.mean(0));
X.subi(X.min(Integer.MAX_VALUE)); X = X.divi(X.max(Integer.MAX_VALUE)); X = X.subiRowVector(X.mean(0));