public ConditionBuilder and(Condition... conditions) { if (soFar == null) soFar = new And(conditions); else { soFar = new And(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
public ConditionBuilder eq(Condition... conditions) { if (soFar == null) soFar = new ConditionEquals(conditions); else { soFar = new ConditionEquals(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
public ConditionBuilder or(Condition... conditions) { if (soFar == null) soFar = new Or(conditions); else { soFar = new Or(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
/** * Create an ndarray based on the given data * @param sliceShape the shape of each slice * @param arrays the arrays of data to create * @return the ndarray of the specified shape where * number of slices is equal to array length and each * slice is the specified shape */ public static INDArray create(int[] sliceShape, double[]... arrays) { int slices = arrays.length; INDArray ret = Nd4j.create(ArrayUtil.combine(new int[] {slices}, sliceShape)); for (int i = 0; i < ret.slices(); i++) ret.putSlice(i, Nd4j.create(arrays[i]).reshape(ArrayUtil.toLongArray(sliceShape))); return ret; }
/** * Create an ndarray based on the given data * @param sliceShape the shape of each slice * @param arrays the arrays of data to create * @return the ndarray of the specified shape where * number of slices is equal to array length and each * slice is the specified shape */ public static INDArray create(int[] sliceShape, float[]... arrays) { int slices = arrays.length; INDArray ret = Nd4j.create(ArrayUtil.combine(new int[] {slices}, sliceShape)); for (int i = 0; i < ret.slices(); i++) ret.putSlice(i, Nd4j.create(arrays[i]).reshape(ArrayUtil.toLongArray(sliceShape))); return ret; }
int[] firstPerm = argsort(combine(deletedAxes[0],keep(argsort(sumAxes[1]),sumAxes[0]))); SDVariable firstResult = doTensorMmul(i_v1.get(0), rarg(), firstAxes); SDVariable permuted = f().permute(firstResult,firstPerm); int[] secondPerm = argsort(combine(keep(argsort(sumAxes[0]),sumAxes[1]),deletedAxes[1])); SDVariable secondResult = doTensorMmul(i_v1.get(0), larg(), secondAxes); SDVariable secondPermuted = f().permute(secondResult,secondPerm);
/** * Gets a copy of example i * * @param i the example to getFromOrigin * @return the example at i (one example) */ @Override public DataSet get(int i) { if (i > numExamples() || i < 0) throw new IllegalArgumentException("invalid example number"); if (i == 0 && numExamples() == 1) return this; if (getFeatureMatrix().rank() == 4) { //ensure rank is preserved INDArray slice = getFeatureMatrix().slice(i); return new DataSet(slice.reshape(ArrayUtil.combine(new long[] {1}, slice.shape())), getLabels().slice(i)); } return new DataSet(getFeatures().slice(i), getLabels().slice(i)); }
public ConditionBuilder or(Condition... conditions) { if (soFar == null) soFar = new Or(conditions); else { soFar = new Or(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
public ConditionBuilder and(Condition... conditions) { if (soFar == null) soFar = new And(conditions); else { soFar = new And(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
public ConditionBuilder eq(Condition... conditions) { if (soFar == null) soFar = new ConditionEquals(conditions); else { soFar = new ConditionEquals(ArrayUtil.combine(conditions, new Condition[] {soFar})); } return this; }
public INDArray asMatrix(Mat image) throws IOException { INDArray ret = transformImage(image, null); return ret.reshape(ArrayUtil.combine(new int[] {1}, ret.shape())); }
/** * Create an ndarray based on the given data * @param sliceShape the shape of each slice * @param arrays the arrays of data to create * @return the ndarray of the specified shape where * number of slices is equal to array length and each * slice is the specified shape */ public static INDArray create(int[] sliceShape, float[]... arrays) { int slices = arrays.length; INDArray ret = Nd4j.create(ArrayUtil.combine(new int[] {slices}, sliceShape)); for (int i = 0; i < ret.slices(); i++) ret.putSlice(i, Nd4j.create(arrays[i]).reshape(sliceShape)); return ret; }
/** * Create an ndarray based on the given data * @param sliceShape the shape of each slice * @param arrays the arrays of data to create * @return the ndarray of the specified shape where * number of slices is equal to array length and each * slice is the specified shape */ public static INDArray create(int[] sliceShape, double[]... arrays) { int slices = arrays.length; INDArray ret = Nd4j.create(ArrayUtil.combine(new int[] {slices}, sliceShape)); for (int i = 0; i < ret.slices(); i++) ret.putSlice(i, Nd4j.create(arrays[i]).reshape(sliceShape)); return ret; }
/** * Gets a copy of example i * * @param i the example to getFromOrigin * @return the example at i (one example) */ @Override public DataSet get(int i) { if (i > numExamples() || i < 0) throw new IllegalArgumentException("invalid example number"); if (i == 0 && numExamples() == 1) return this; if (getFeatureMatrix().rank() == 4) { //ensure rank is preserved INDArray slice = getFeatureMatrix().slice(i); return new DataSet(slice.reshape(ArrayUtil.combine(new int[] {1}, slice.shape())), getLabels().slice(i)); } return new DataSet(getFeatures().slice(i), getLabels().slice(i)); }
int[] aStrides = ArrayUtil.copy(this.aStrides); int[] bStrides = ArrayUtil.copy(this.bStrides); int[] cStrides = ArrayUtil.combine(this.cStrides); int[] shape = ArrayUtil.copy(this.shape); int nDim = this.nDim;
ret = normalizeIfNeeded(ret); return ret.reshape(ArrayUtil.combine(new int[]{1},ret.shape()));