本文整理了Java中org.nd4j.linalg.factory.Nd4j.getRandom()
方法的一些代码示例,展示了Nd4j.getRandom()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getRandom()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getRandom
[英]Get the current random generator
[中]获取当前随机生成器
代码示例来源:origin: deeplearning4j/nd4j
public LogNormalDistribution(INDArray mean, double std) {
this.means = mean;
this.standardDeviation = std;
this.random = Nd4j.getRandom();
}
代码示例来源:origin: deeplearning4j/nd4j
public NormalDistribution(INDArray mean, double std) {
this.means = mean;
this.standardDeviation = std;
this.random = Nd4j.getRandom();
}
代码示例来源:origin: deeplearning4j/nd4j
public BinomialDistribution(int n, INDArray p) {
this.random = Nd4j.getRandom();
this.numberOfTrials = n;
this.p = p;
}
代码示例来源:origin: deeplearning4j/nd4j
public ConstantDistribution(double value) {
this.value = value;
this.random = Nd4j.getRandom();
}
/*
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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});
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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());
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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());
}
代码示例来源:origin: deeplearning4j/nd4j
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)"));
}
代码示例来源:origin: deeplearning4j/nd4j
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)"));
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* 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());
}
代码示例来源:origin: deeplearning4j/nd4j
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)"));
}
代码示例来源:origin: deeplearning4j/nd4j
@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);
}
代码示例来源:origin: deeplearning4j/nd4j
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)"));
}
代码示例来源:origin: deeplearning4j/nd4j
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)"));
}
代码示例来源:origin: deeplearning4j/nd4j
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 + ")");
}
代码示例来源:origin: deeplearning4j/nd4j
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 + ")");
}
代码示例来源:origin: deeplearning4j/nd4j
@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);
}
代码示例来源:origin: deeplearning4j/nd4j
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 + ")");
}
内容来源于网络,如有侵权,请联系作者删除!