public LogNormalDistribution(INDArray mean, double std) { this.means = mean; this.standardDeviation = std; this.random = Nd4j.getRandom(); }
public NormalDistribution(INDArray mean, double std) { this.means = mean; this.standardDeviation = std; this.random = Nd4j.getRandom(); }
public BinomialDistribution(int n, INDArray p) { this.random = Nd4j.getRandom(); this.numberOfTrials = n; this.p = p; }
public ConstantDistribution(double value) { this.value = value; this.random = Nd4j.getRandom(); } /*
/** * Sample without replacement and a random rng * * @param numSamples the number of samples to getFromOrigin * @return a sample data transform without replacement */ @Override public DataSet sample(int numSamples) { return sample(numSamples, Nd4j.getRandom()); }
/** * Generate a random normal N(0,1) with the specified order and shape * @param order Order of the output array * @param rows the number of rows in the matrix * @param columns the number of columns in the matrix * @return */ @Override public INDArray randn(char order, long rows, long columns) { return Nd4j.getRandom().nextGaussian(order, new long[] {rows, columns}); }
/** * 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 */ @Override public INDArray randn(long rows, long columns, long seed) { Nd4j.getRandom().setSeed(seed); return randn(new long[] {rows, columns}, Nd4j.getRandom()); }
/** * Random normal using the current time stamp * as the seed * * @param shape the shape of the ndarray * @return */ @Override public INDArray randn(char order, int[] shape) { return Nd4j.getRandom().nextGaussian(order, shape); }
/** * This method executes specified RandomOp using default RNG available via Nd4j.getRandom() * * @param op */ @Override public INDArray exec(RandomOp op) { return exec(op, Nd4j.getRandom()); }
public static List<Pair<INDArray, String>> get4dPermutedWithShape(int seed, int... shape) { Nd4j.getRandom().setSeed(seed); int[] createdShape = {shape[1], shape[3], shape[2], shape[0]}; INDArray arr = Nd4j.rand(createdShape); INDArray permuted = arr.permute(3, 0, 2, 1); return Collections.singletonList(new Pair<>(permuted, "get4dPermutedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
public static List<Pair<INDArray, String>> get6dPermutedWithShape(int seed, int... shape) { Nd4j.getRandom().setSeed(seed); int[] createdShape = {shape[1], shape[4], shape[5], shape[3], shape[2], shape[0]}; INDArray arr = Nd4j.rand(createdShape); INDArray permuted = arr.permute(5, 0, 4, 3, 1, 2); return Collections.singletonList(new Pair<>(permuted, "get6dPermutedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
/** * Fill the given ndarray with random numbers drawn from a uniform distribution * * @param target target array * @return the given target array */ public static INDArray rand(INDArray target) { return getExecutioner().exec(new UniformDistribution(target), Nd4j.getRandom()); }
public static List<Pair<INDArray, String>> get6dReshapedWithShape(int seed, int... shape) { Nd4j.getRandom().setSeed(seed); int[] shape3d = {shape[0] * shape[2], shape[4] * shape[5], shape[1] * shape[3]}; INDArray array3d = Nd4j.rand(shape3d); INDArray array6d = array3d.reshape(ArrayUtil.toLongArray(shape)); return Collections.singletonList(new Pair<>(array6d, "get6dReshapedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
@Override public INDArray rand(long rows, long columns, double min, double max, org.nd4j.linalg.api.rng.Random rng) { Nd4j.getRandom().setSeed(rng.getSeed()); return rand(new long[] {rows, columns}, min, max, rng); }
public static List<Pair<INDArray, String>> get3dPermutedWithShape(long seed, long... shape) { Nd4j.getRandom().setSeed(seed); long[] createdShape = {shape[1], shape[2], shape[0]}; int lencreatedShape = ArrayUtil.prod(createdShape); INDArray arr = Nd4j.linspace(1, lencreatedShape, lencreatedShape).reshape(createdShape); INDArray permuted = arr.permute(2, 0, 1); return Collections.singletonList(new Pair<>(permuted, "get3dPermutedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
public static List<Pair<INDArray, String>> get3dReshapedWithShape(long seed, long... shape) { Nd4j.getRandom().setSeed(seed); long[] shape2d = {shape[0] * shape[2], shape[1]}; int lenshape2d = ArrayUtil.prod(shape2d); INDArray array2d = Nd4j.linspace(1, lenshape2d, lenshape2d).reshape(shape2d); INDArray array3d = array2d.reshape(shape); return Collections.singletonList(new Pair<>(array3d, "get3dReshapedWithShape(" + seed + "," + Arrays.toString(shape) + ").get(0)")); }
public static Pair<INDArray, String> getTransposedMatrixWithShape(char ordering, int rows, int cols, int seed) { Nd4j.getRandom().setSeed(seed); INDArray out = Nd4j.linspace(1, rows * cols, rows * cols).reshape(ordering, cols, rows); return new Pair<>(out.transpose(), "getTransposedMatrixWithShape(" + rows + "," + cols + "," + seed + ")"); }
public static Pair<INDArray, String> getPermutedWithShape(char ordering, long rows, long cols, long seed) { Nd4j.getRandom().setSeed(seed); long len = rows * cols; INDArray arr = Nd4j.linspace(1, len, len).reshape(cols, rows); return new Pair<>(arr.permute(1, 0), "getPermutedWithShape(" + rows + "," + cols + "," + seed + ")"); }
@Override public INDArray rand(int[] shape, double min, double max, org.nd4j.linalg.api.rng.Random rng) { Nd4j.getRandom().setSeed(rng.getSeed()); return Nd4j.getDistributions().createUniform(min, max).sample(shape); }
public static Pair<INDArray, String> getTransposedMatrixWithShape(long rows, long cols, long seed) { Nd4j.getRandom().setSeed(seed); INDArray out = Nd4j.linspace(1, rows * cols, rows * cols).reshape(cols, rows); return new Pair<>(out.transpose(), "getTransposedMatrixWithShape(" + rows + "," + cols + "," + seed + ")"); }