Refine search
@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; }
@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; }
@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; }
@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; }
@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; }
@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; }
/** * 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()))); }
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; }
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; }
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; }
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; }
/** * Negate each element. */ @Override public INDArray neg() { return Nd4j.getExecutioner().exec(new Negative(this, Nd4j.createUninitialized(this.shape(), this.ordering()))) .z(); }
public static INDArray reverse(INDArray x, boolean dup) { return Nd4j.getExecutioner().exec(new OldReverse(x, dup ? Nd4j.createUninitialized(x.shape(), x.ordering()) : x)) .z(); }
/** * 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; }
/** * 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}; }
INDArray result = Nd4j.createUninitialized(m.shape()); .build(); Nd4j.getExecutioner().exec(op);
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));
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];
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();
/** * 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; }