parent
6b557f2441
commit
979ef13c0b
|
@ -3098,10 +3098,10 @@ public class Nd4j {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link Nd4j#randn(long, long...)}
|
* @deprecated use {@link Nd4j#randn(long, long[])}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static INDArray randn(int[] shape, long seed) {
|
public static INDArray randn(long seed, int[] shape) {
|
||||||
return randn(seed, ArrayUtil.toLongArray(shape));
|
return randn(seed, ArrayUtil.toLongArray(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3111,60 +3111,11 @@ public class Nd4j {
|
||||||
* @param shape the shape of the array
|
* @param shape the shape of the array
|
||||||
* @return new array with random values
|
* @return new array with random values
|
||||||
*/
|
*/
|
||||||
public static INDArray randn(long seed, @NonNull long... shape) {
|
public static INDArray randn(long seed, @NonNull long[] shape) {
|
||||||
INDArray ret = Nd4j.createUninitialized(shape, order());
|
INDArray ret = Nd4j.createUninitialized(shape, order());
|
||||||
return randn(ret, seed);
|
return randn(ret, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Random normal N(0, 1)
|
|
||||||
*
|
|
||||||
* @param rows the number of rows in the matrix
|
|
||||||
* @param columns the number of columns in the matrix
|
|
||||||
* @return new array with random values
|
|
||||||
*/
|
|
||||||
public static INDArray randn(long rows, long columns) {
|
|
||||||
INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
|
|
||||||
return randn(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
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 new array with random values
|
|
||||||
*/
|
|
||||||
/*public static INDArray randn(long rows, long columns, long seed) {
|
|
||||||
INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
|
|
||||||
return randn(ret, seed);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 new array with random values
|
|
||||||
*/
|
|
||||||
/*public static INDArray randn(long rows, long columns, @NonNull org.nd4j.linalg.api.rng.Random r) {
|
|
||||||
INDArray ret = Nd4j.createUninitialized(new long[]{rows, columns}, order());
|
|
||||||
return randn(ret, r);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link Nd4j#randn(org.nd4j.linalg.api.rng.Random, long...)}
|
* @deprecated use {@link Nd4j#randn(org.nd4j.linalg.api.rng.Random, long...)}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class NormalizerStandardizeLabelsTest extends BaseNd4jTest {
|
||||||
// transform ndarray as X = aA + bB * X
|
// transform ndarray as X = aA + bB * X
|
||||||
INDArray randomFeatures = Nd4j.zeros(nSamples, nFeatures);
|
INDArray randomFeatures = Nd4j.zeros(nSamples, nFeatures);
|
||||||
while (i < nFeatures) {
|
while (i < nFeatures) {
|
||||||
INDArray randomSlice = Nd4j.randn(new int[]{nSamples, 1}, randSeed);
|
INDArray randomSlice = Nd4j.randn(randSeed, new long[]{nSamples, 1});
|
||||||
randomSlice.muli(aA.getScalar(0, i));
|
randomSlice.muli(aA.getScalar(0, i));
|
||||||
randomSlice.addi(bB.getScalar(0, i));
|
randomSlice.addi(bB.getScalar(0, i));
|
||||||
randomFeatures.putColumn(i, randomSlice);
|
randomFeatures.putColumn(i, randomSlice);
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class NormalizerStandardizeTest extends BaseNd4jTest {
|
||||||
INDArray randomFeatures = Nd4j.zeros(nSamples, nFeatures);
|
INDArray randomFeatures = Nd4j.zeros(nSamples, nFeatures);
|
||||||
INDArray randomFeaturesTransform = Nd4j.zeros(nSamples, nFeatures);
|
INDArray randomFeaturesTransform = Nd4j.zeros(nSamples, nFeatures);
|
||||||
while (i < nFeatures) {
|
while (i < nFeatures) {
|
||||||
INDArray randomSlice = Nd4j.randn(new int[]{nSamples, 1}, randSeed);
|
INDArray randomSlice = Nd4j.randn(randSeed, new long[]{nSamples, 1});
|
||||||
randomFeaturesTransform.putColumn(i, randomSlice);
|
randomFeaturesTransform.putColumn(i, randomSlice);
|
||||||
randomSlice.muli(aA.getScalar(0, i));
|
randomSlice.muli(aA.getScalar(0, i));
|
||||||
randomSlice.addi(bB.getScalar(0, i));
|
randomSlice.addi(bB.getScalar(0, i));
|
||||||
|
|
|
@ -906,8 +906,8 @@ public class RandomTests extends BaseNd4jTest {
|
||||||
public void testSignatures1() {
|
public void testSignatures1() {
|
||||||
|
|
||||||
for (int x = 0; x < 100; x++) {
|
for (int x = 0; x < 100; x++) {
|
||||||
INDArray z1 = Nd4j.randn(new int[]{128, 1}, 5325235);
|
INDArray z1 = Nd4j.randn(5325235, new long[]{128, 1});
|
||||||
INDArray z2 = Nd4j.randn(new int[]{128, 1}, 5325235);
|
INDArray z2 = Nd4j.randn(5325235, new long[]{128, 1});
|
||||||
|
|
||||||
assertEquals(z1, z2);
|
assertEquals(z1, z2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue