public static INDArray std(INDArray compute, int dimension) { return compute.std(dimension); }
INDArray sumAlong0 = originalArray.sum(0); INDArray avgAlong0 = originalArray.mean(0); INDArray stdevAlong0 = originalArray.std(0);
public static INDArray std(INDArray compute) { return compute.std(Integer.MAX_VALUE); }
/** * 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 void fit(DataSet dataSet) { mean = dataSet.getFeatureMatrix().mean(0); std = dataSet.getFeatureMatrix().std(0); std.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD)); if (std.min(1) == Nd4j.scalar(Nd4j.EPS_THRESHOLD)) logger.info("API_INFO: Std deviation found to be zero. Transform will round upto epsilon to avoid nans."); }
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)); }
std = (batchCount == 1) ? Nd4j.zeros(mean.shape()) : Transforms.pow(next.getFeatureMatrix().std(0), 2); std.muli(batchCount); } else { INDArray deltaSqScaled = deltaSq.mul(((float) runningTotal - batchCount) * batchCount / (float) runningTotal); INDArray mtwoB = Transforms.pow(next.getFeatureMatrix().std(0), 2); mtwoB.muli(batchCount); std = std.add(mtwoB);
public static INDArray std(INDArray compute) { return compute.std(Integer.MAX_VALUE); }
public static INDArray std(INDArray compute, int dimension) { return compute.std(dimension); }
@Override public INDArray preProcess(INDArray input, int miniBatchSize) { columnStds = input.std(0); columnStds.addi(Nd4j.EPS_THRESHOLD); input.diviRowVector(columnStds); 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); }
public void fit(DataSet dataSet) { mean = dataSet.getFeatureMatrix().mean(0); std = dataSet.getFeatureMatrix().std(0); std.addi(Nd4j.scalar(Nd4j.EPS_THRESHOLD)); if (std.min(1) == Nd4j.scalar(Nd4j.EPS_THRESHOLD)) logger.info("API_INFO: Std deviation found to be zero. Transform will round upto epsilon to avoid nans."); }
/** * @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)); }
std = (batchCount == 1) ? Nd4j.zeros(mean.shape()) : Transforms.pow(next.getFeatureMatrix().std(0), 2); std.muli(batchCount); } else { INDArray deltaSqScaled = deltaSq.mul(((float) runningTotal - batchCount) * batchCount / (float) runningTotal); INDArray mtwoB = Transforms.pow(next.getFeatureMatrix().std(0), 2); mtwoB.muli(batchCount); std = std.add(mtwoB);