/** * Random normal N(0,1) with the specified shape and array order * * @param order the order of the output array * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix */ public static INDArray randn(char order, long rows, long columns) { INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order); logCreationIfNecessary(ret); return randn(ret); }
/** * Random normal N(0,1) with the specified shape and array order * * @param order order of the output ndarray * @param shape the shape of the ndarray */ public static INDArray randn(char order, long[] shape) { INDArray ret = Nd4j.createUninitialized(shape, order); logCreationIfNecessary(ret); return randn(ret); }
/** * Random normal N(0,1) with the specified shape and array order * * @param order order of the output ndarray * @param shape the shape of the ndarray */ public static INDArray randn(char order, int[] shape) { INDArray ret = Nd4j.createUninitialized(shape, order); logCreationIfNecessary(ret); return randn(ret); }
/** * Random normal using the specified seed * * @param shape the shape of the ndarray * @return */ public static INDArray randn(int[] shape, long seed) { INDArray ret = Nd4j.createUninitialized(shape, order()); logCreationIfNecessary(ret); return randn(ret, seed); }
/** * Random normal using the current time stamp * as the seed * * @param shape the shape of the ndarray * @return */ public static INDArray randn(int[] shape) { INDArray ret = Nd4j.createUninitialized(shape, order()); logCreationIfNecessary(ret); return randn(ret); }
/** * Random normal using the specified seed * * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @return */ public static INDArray randn(long rows, long columns, long seed) { INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order()); logCreationIfNecessary(ret); return randn(ret, seed); }
/** * Random normal using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return */ public static INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) { final INDArray ret = Nd4j.createUninitialized(shape, order()); logCreationIfNecessary(ret); return randn(ret, r); }
public static INDArray randn(long[] shape) { INDArray ret = Nd4j.createUninitialized(shape, order()); logCreationIfNecessary(ret); return randn(ret); }
/** * Random normal using the given rng * * @param shape the shape of the ndarray * @param r the random generator to use * @return */ public static INDArray randn(long[] shape, org.nd4j.linalg.api.rng.Random r) { final INDArray ret = Nd4j.createUninitialized(shape, order()); logCreationIfNecessary(ret); return randn(ret, r); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanIn)); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).muli(FastMath.sqrt(2.0 / (fanIn + fanOut))); }
/** * Random normal using the given rng * * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @param r the random generator to use * @return */ public static INDArray randn(long rows, long columns, org.nd4j.linalg.api.rng.Random r) { INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order()); logCreationIfNecessary(ret); return randn(ret, r); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanOut)); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanIn)); }
/** * Random normal using the current time stamp * as the seed * * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @return */ public static INDArray randn(long rows, long columns) { INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order()); logCreationIfNecessary(ret); return randn(ret); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).divi(FastMath.sqrt((fanIn + fanOut) / 2)); }
@Override public INDArray doCreate(long[] shape, INDArray paramsView) { return Nd4j.randn(order(), shape).muli(FastMath.sqrt(2.0 / fanIn)); //N(0, 2/nIn); }
System.out.println("Full precision of random value at position (0,0): " + uniformRandom.getDouble(0,0)); INDArray gaussianMeanZeroUnitVariance = Nd4j.randn(shape); System.out.println("\nN(0,1) random array:"); System.out.println(gaussianMeanZeroUnitVariance);
/** * Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values * as the data set used to initialize the PCA object, with same number of features <i>N</i>. * @param count The number of samples to generate * @return A matrix of size <i>count</i> rows by <i>N</i> columns */ public INDArray generateGaussianSamples(long count) { INDArray samples = Nd4j.randn(new long[] {count, eigenvalues.columns()}); INDArray factors = Transforms.pow(eigenvalues, -0.5, true); samples.muliRowVector(factors); return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean); }
/** * Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values * as the data set used to initialize the PCA object, with same number of features <i>N</i>. * @param count The number of samples to generate * @return A matrix of size <i>count</i> rows by <i>N</i> columns */ public INDArray generateGaussianSamples(int count) { INDArray samples = Nd4j.randn(count, eigenvalues.columns()); INDArray factors = Transforms.pow(eigenvalues, -0.5, true); samples.muliRowVector(factors); return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean); }