public static INDArray newShapeNoCopy(INDArray arr, int[] newShape, boolean isFOrder) { return newShapeNoCopy(arr, ArrayUtil.toLongArray(newShape), isFOrder); } /**
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); this.v = viewArray; //Reshape to match the expected shape of the input gradient arrays this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (v == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(epsilon); this.historicalGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.historicalGradient = Shape.newShapeNoCopy(this.historicalGradient, gradientShape, gradientOrder == 'f'); if (historicalGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(config.getEpsilon()); this.lastGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.lastGradient = Shape.newShapeNoCopy(this.lastGradient, gradientShape, gradientOrder == 'f'); if (lastGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); gradientReshapeOrder = gradientOrder; }
public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector() && !(viewArray.rank() == 2 && viewArray.columns() == 1 && viewArray.rows() == 1)) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(epsilon); this.historicalGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.historicalGradient = Shape.newShapeNoCopy(this.historicalGradient, gradientShape, gradientOrder == 'f'); if (historicalGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); long length = viewArray.length(); this.msg = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.msdx = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.msg = Shape.newShapeNoCopy(this.msg, gradientShape, gradientOrder == 'f'); this.msdx = Shape.newShapeNoCopy(this.msdx, gradientShape, gradientOrder == 'f'); if (msg == null || msdx == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); long length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.u = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.u = Shape.newShapeNoCopy(this.u, gradientShape, gradientOrder == 'f'); if (m == null || u == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); long length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.v = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (m == null || v == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); long length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.v = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (m == null || v == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, long[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); val n = viewArray.length() / 3; this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, n)); this.v = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(n, 2*n)); this.vHat = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(2*n, 3*n)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); this.vHat = Shape.newShapeNoCopy(this.vHat, gradientShape, gradientOrder == 'f'); if (m == null || v == null || vHat == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
INDArray reshapeAttempt = Shape.newShapeNoCopy(this, shape, order == 'f'); if (reshapeAttempt != null) {
public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(epsilon); this.historicalGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.historicalGradient = Shape.newShapeNoCopy(this.historicalGradient, gradientShape, gradientOrder == 'f'); if (historicalGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); this.v = viewArray; //Reshape to match the expected shape of the input gradient arrays this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (v == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(epsilon); this.historicalGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.historicalGradient = Shape.newShapeNoCopy(this.historicalGradient, gradientShape, gradientOrder == 'f'); if (historicalGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(config.getEpsilon()); this.lastGradient = viewArray; //Reshape to match the expected shape of the input gradient arrays this.lastGradient = Shape.newShapeNoCopy(this.lastGradient, gradientShape, gradientOrder == 'f'); if (lastGradient == null) throw new IllegalStateException("Could not correctly reshape gradient view array"); gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); int length = viewArray.length(); this.msg = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.msdx = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.msg = Shape.newShapeNoCopy(this.msg, gradientShape, gradientOrder == 'f'); this.msdx = Shape.newShapeNoCopy(this.msdx, gradientShape, gradientOrder == 'f'); if (msg == null || msdx == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); int length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.v = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (m == null || v == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); int length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.v = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.v = Shape.newShapeNoCopy(this.v, gradientShape, gradientOrder == 'f'); if (m == null || v == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
@Override public void setStateViewArray(INDArray viewArray, int[] gradientShape, char gradientOrder, boolean initialize) { if (!viewArray.isRowVector()) throw new IllegalArgumentException("Invalid input: expect row vector input"); if (initialize) viewArray.assign(0); int length = viewArray.length(); this.m = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(0, length / 2)); this.u = viewArray.get(NDArrayIndex.point(0), NDArrayIndex.interval(length / 2, length)); //Reshape to match the expected shape of the input gradient arrays this.m = Shape.newShapeNoCopy(this.m, gradientShape, gradientOrder == 'f'); this.u = Shape.newShapeNoCopy(this.u, gradientShape, gradientOrder == 'f'); if (m == null || u == null) throw new IllegalStateException("Could not correctly reshape gradient view arrays"); this.gradientReshapeOrder = gradientOrder; }
INDArray reshapeAttempt = Shape.newShapeNoCopy(this, shape, order == 'f'); if (reshapeAttempt != null) {