本文整理了Java中org.nd4j.linalg.factory.Nd4j.createUninitialized()
方法的一些代码示例,展示了Nd4j.createUninitialized()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.createUninitialized()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:createUninitialized
[英]This method creates an uninitialized ndarray of specified length and default ordering. PLEASE NOTE: Do not use this method unless you're 100% sure why you use it.
[中]此方法创建指定长度和默认顺序的未初始化数据数组。请注意:除非你100%确定为什么要使用这种方法,否则不要使用这种方法。
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextGaussian(char order, int[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
GaussianDistribution op = new GaussianDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextGaussian(char order, long[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
GaussianDistribution op = new GaussianDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextDouble(char order, int[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
UniformDistribution op = new UniformDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextFloat(char order, long[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
UniformDistribution op = new UniformDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextFloat(char order, int[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
UniformDistribution op = new UniformDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public INDArray nextDouble(char order, long[] shape) {
INDArray array = Nd4j.createUninitialized(shape, order);
UniformDistribution op = new UniformDistribution(array, 0.0, 1.0);
Nd4j.getExecutioner().exec(op, this);
return array;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Atan2 operation, new INDArray instance will be returned
* Note the order of x and y parameters is opposite to that of java.lang.Math.atan2
*
* @param x the abscissa coordinate
* @param y the ordinate coordinate
* @return the theta from point (r, theta) when converting (x,y) from to cartesian to polar coordinates
*/
public static INDArray atan2(@NonNull INDArray x, @NonNull INDArray y) {
return Nd4j.getExecutioner()
.execAndReturn(new OldAtan2Op(x, y, Nd4j.createUninitialized(x.shape(), x.ordering())));
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray and(INDArray x, INDArray y) {
INDArray z = Nd4j.createUninitialized(x.shape(), x.ordering());
Nd4j.getExecutioner().exec(new And(x, y, z, 0.0));
return z;
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray not(INDArray x) {
INDArray z = Nd4j.createUninitialized(x.shape(), x.ordering());
Nd4j.getExecutioner().exec(new Not(x, z, 0.0));
return z;
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray xor(INDArray x, INDArray y) {
INDArray z = Nd4j.createUninitialized(x.shape(), x.ordering());
Nd4j.getExecutioner().exec(new Xor(x, y, z, 0.0));
return z;
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray or(INDArray x, INDArray y) {
INDArray z = Nd4j.createUninitialized(x.shape(), x.ordering());
Nd4j.getExecutioner().exec(new Or(x, y, z, 0.0));
return z;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Negate each element.
*/
@Override
public INDArray neg() {
return Nd4j.getExecutioner().exec(new Negative(this, Nd4j.createUninitialized(this.shape(), this.ordering())))
.z();
}
代码示例来源:origin: deeplearning4j/nd4j
public static INDArray reverse(INDArray x, boolean dup) {
return Nd4j.getExecutioner().exec(new OldReverse(x, dup ? Nd4j.createUninitialized(x.shape(), x.ordering()) : x))
.z();
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Like the scipy function tri.
* From the scipy documentation:
* An array with ones at and below the given diagonal and zeros elsewhere.
* @param n number of rows in the array
* @param m number of columns in the array ( can be just equal to n)
* @param k The sub-diagonal at and below which the array is filled.
`k` = 0 is the main diagonal, while `k` < 0 is below it,
and `k` > 0 is above. The default is 0.
* @return
*/
public static INDArray tri(int n,int m,int k) {
/*
INDArray mRet = Transforms.greaterThanOrEqual(arange(n),arange(-k,m - k));
return mRet;
*/
INDArray ret = Nd4j.createUninitialized(n, m);
val op = DynamicCustomOp.builder("tri")
.addIntegerArguments(n, m, k)
.addOutputs(ret)
.build();
Nd4j.getExecutioner().exec(op);
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Meshgrid op. Returns a pair of arrays where values are broadcast on a 2d grid.<br>
* For example, if x = [1,2,3,4] and y = [5,6,7], then:<br>
* out[0] =<br>
* [1,2,3,4]<br>
* [1,2,3,4]<br>
* [1,2,3,4]<br>
* <br>
* out[1] =<br>
* [5,5,5,5]<br>
* [6,6,6,6]<br>
* [7,7,7,7]<br>
* <br>
*
* @param x X array input
* @param y Y array input
* @return INDArray[] of length 2, shape [y.length, x.length]
*/
public static INDArray[] meshgrid(@NonNull INDArray x, @NonNull INDArray y){
Preconditions.checkArgument(x.isVectorOrScalar(), "X must be a vector");
Preconditions.checkArgument(y.isVectorOrScalar(), "Y must be a vector");
INDArray xOut = Nd4j.createUninitialized(y.length(), x.length());
INDArray yOut = Nd4j.createUninitialized(y.length(), x.length());
CustomOp op = DynamicCustomOp.builder("meshgrid")
.addInputs(x, y)
.addOutputs(xOut, yOut)
.build();
Nd4j.getExecutioner().exec(op);
return new INDArray[]{xOut, yOut};
}
代码示例来源:origin: deeplearning4j/nd4j
INDArray result = Nd4j.createUninitialized(m.shape());
.build();
Nd4j.getExecutioner().exec(op);
代码示例来源:origin: deeplearning4j/nd4j
return Nd4j.createUninitialized(shape).assign(this.getDouble(0));
Nd4j.getExecutioner().exec(new Tile(new INDArray[]{this.dup(this.ordering())},new INDArray[]{result},repeat));
} else
Nd4j.getExecutioner().exec(new Tile(new INDArray[]{this},new INDArray[]{result},repeat));
代码示例来源:origin: deeplearning4j/nd4j
int oW = (int) Math.ceil(img.size(3) * 1.f / sx);
output = Nd4j.createUninitialized(new long[] {img.size(0), img.size(1), kh, kw, oH, oW}, 'c');
int oW = ((int) img.size(3) - (kw + (kw-1)*(1-1)) + 2*pw)/sx + 1;
output = Nd4j.createUninitialized(new long[] {img.size(0), img.size(1), kh, kw, oH, oW}, 'c');
.build()).build();
Nd4j.getExecutioner().exec(im2col);
return im2col.outputArguments()[0];
代码示例来源:origin: deeplearning4j/nd4j
Nd4j.getExecutioner().commit();
Nd4j.getExecutioner().commit();
DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false);
INDArray copy = Nd4j.createUninitialized(this.shape(), this.ordering());
copy.assign(this);
Nd4j.getExecutioner().commit();
copy = Nd4j.createUninitialized(this.shape(), this.ordering());
copy.assign(this);
Nd4j.getExecutioner().commit();
代码示例来源:origin: deeplearning4j/nd4j
/**
* in place addition of two matrices
*
* @param other the second ndarray to add
* @param result the result ndarray
* @return the result of the addition
*/
@Override
public INDArray addi(INDArray other, INDArray result) {
if (other.isScalar()) {
return result.addi(other.getDouble(0), result);
}
if (isScalar()) {
return other.addi(getDouble(0), result);
}
if(!Shape.shapeEquals(this.shape(),other.shape())) {
int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape());
result = Nd4j.createUninitialized(Shape.broadcastOutputShape(this.shape(),other.shape()));
Nd4j.getExecutioner().exec(new BroadcastAddOp(this,other,result,broadcastDimensions),broadcastDimensions);
return result;
}
LinAlgExceptions.assertSameShape(other, result);
Nd4j.getExecutioner().exec(new OldAddOp(this, other, result, length()));
if (Nd4j.ENFORCE_NUMERICAL_STABILITY)
Nd4j.clearNans(result);
return result;
}
内容来源于网络,如有侵权,请联系作者删除!