org.nd4j.linalg.factory.Nd4j.randn()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.nd4j.linalg.factory.Nd4j.randn()方法的一些代码示例,展示了Nd4j.randn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.randn()方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:randn

Nd4j.randn介绍

[英]Random normal N(0,1) with the specified shape and array order
[中]具有指定形状和数组顺序的随机法线N(0,1)

代码示例

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal N(0,1) with the specified shape and array order
  3. *
  4. * @param order the order of the output array
  5. * @param rows the number of rows in the matrix
  6. * @param columns the number of columns in the matrix
  7. */
  8. public static INDArray randn(char order, long rows, long columns) {
  9. INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order);
  10. logCreationIfNecessary(ret);
  11. return randn(ret);
  12. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal N(0,1) with the specified shape and array order
  3. *
  4. * @param order order of the output ndarray
  5. * @param shape the shape of the ndarray
  6. */
  7. public static INDArray randn(char order, long[] shape) {
  8. INDArray ret = Nd4j.createUninitialized(shape, order);
  9. logCreationIfNecessary(ret);
  10. return randn(ret);
  11. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal N(0,1) with the specified shape and array order
  3. *
  4. * @param order order of the output ndarray
  5. * @param shape the shape of the ndarray
  6. */
  7. public static INDArray randn(char order, int[] shape) {
  8. INDArray ret = Nd4j.createUninitialized(shape, order);
  9. logCreationIfNecessary(ret);
  10. return randn(ret);
  11. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the specified seed
  3. *
  4. * @param shape the shape of the ndarray
  5. * @return
  6. */
  7. public static INDArray randn(int[] shape, long seed) {
  8. INDArray ret = Nd4j.createUninitialized(shape, order());
  9. logCreationIfNecessary(ret);
  10. return randn(ret, seed);
  11. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the current time stamp
  3. * as the seed
  4. *
  5. * @param shape the shape of the ndarray
  6. * @return
  7. */
  8. public static INDArray randn(int[] shape) {
  9. INDArray ret = Nd4j.createUninitialized(shape, order());
  10. logCreationIfNecessary(ret);
  11. return randn(ret);
  12. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the specified seed
  3. *
  4. * @param rows the number of rows in the matrix
  5. * @param columns the number of columns in the matrix
  6. * @return
  7. */
  8. public static INDArray randn(long rows, long columns, long seed) {
  9. INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
  10. logCreationIfNecessary(ret);
  11. return randn(ret, seed);
  12. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the given rng
  3. *
  4. * @param shape the shape of the ndarray
  5. * @param r the random generator to use
  6. * @return
  7. */
  8. public static INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) {
  9. final INDArray ret = Nd4j.createUninitialized(shape, order());
  10. logCreationIfNecessary(ret);
  11. return randn(ret, r);
  12. }

代码示例来源:origin: deeplearning4j/nd4j

  1. public static INDArray randn(long[] shape) {
  2. INDArray ret = Nd4j.createUninitialized(shape, order());
  3. logCreationIfNecessary(ret);
  4. return randn(ret);
  5. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the given rng
  3. *
  4. * @param shape the shape of the ndarray
  5. * @param r the random generator to use
  6. * @return
  7. */
  8. public static INDArray randn(long[] shape, org.nd4j.linalg.api.rng.Random r) {
  9. final INDArray ret = Nd4j.createUninitialized(shape, order());
  10. logCreationIfNecessary(ret);
  11. return randn(ret, r);
  12. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanIn));
  4. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).muli(FastMath.sqrt(2.0 / (fanIn + fanOut)));
  4. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the given rng
  3. *
  4. * @param rows the number of rows in the matrix
  5. * @param columns the number of columns in the matrix
  6. * @param r the random generator to use
  7. * @return
  8. */
  9. public static INDArray randn(long rows, long columns, org.nd4j.linalg.api.rng.Random r) {
  10. INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
  11. logCreationIfNecessary(ret);
  12. return randn(ret, r);
  13. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanOut));
  4. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).divi(FastMath.sqrt(fanIn));
  4. }

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Random normal using the current time stamp
  3. * as the seed
  4. *
  5. * @param rows the number of rows in the matrix
  6. * @param columns the number of columns in the matrix
  7. * @return
  8. */
  9. public static INDArray randn(long rows, long columns) {
  10. INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
  11. logCreationIfNecessary(ret);
  12. return randn(ret);
  13. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).divi(FastMath.sqrt((fanIn + fanOut) / 2));
  4. }

代码示例来源:origin: deeplearning4j/nd4j

  1. @Override
  2. public INDArray doCreate(long[] shape, INDArray paramsView) {
  3. return Nd4j.randn(order(), shape).muli(FastMath.sqrt(2.0 / fanIn)); //N(0, 2/nIn);
  4. }

代码示例来源:origin: deeplearning4j/dl4j-examples

  1. System.out.println("Full precision of random value at position (0,0): " + uniformRandom.getDouble(0,0));
  2. INDArray gaussianMeanZeroUnitVariance = Nd4j.randn(shape);
  3. System.out.println("\nN(0,1) random array:");
  4. System.out.println(gaussianMeanZeroUnitVariance);

代码示例来源:origin: deeplearning4j/nd4j

  1. /**
  2. * Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values
  3. * as the data set used to initialize the PCA object, with same number of features <i>N</i>.
  4. * @param count The number of samples to generate
  5. * @return A matrix of size <i>count</i> rows by <i>N</i> columns
  6. */
  7. public INDArray generateGaussianSamples(long count) {
  8. INDArray samples = Nd4j.randn(new long[] {count, eigenvalues.columns()});
  9. INDArray factors = Transforms.pow(eigenvalues, -0.5, true);
  10. samples.muliRowVector(factors);
  11. return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
  12. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. /**
  2. * Generates a set of <i>count</i> random samples with the same variance and mean and eigenvector/values
  3. * as the data set used to initialize the PCA object, with same number of features <i>N</i>.
  4. * @param count The number of samples to generate
  5. * @return A matrix of size <i>count</i> rows by <i>N</i> columns
  6. */
  7. public INDArray generateGaussianSamples(int count) {
  8. INDArray samples = Nd4j.randn(count, eigenvalues.columns());
  9. INDArray factors = Transforms.pow(eigenvalues, -0.5, true);
  10. samples.muliRowVector(factors);
  11. return Nd4j.tensorMmul(eigenvectors, samples, new int[][] {{1}, {1}}).transposei().addiRowVector(mean);
  12. }

相关文章