use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.
the class Nd4j method createComplex.
/**
* Create an ndrray with the specified shape
*
* @param data the data to use with tne ndarray
* @param shape the shape of the ndarray
* @return the created ndarray
*/
public static IComplexNDArray createComplex(double[] data, int[] shape) {
shape = getEnsuredShape(shape);
if (shape.length == 1) {
if (shape[0] == data.length) {
shape = new int[] { 1, data.length };
} else
throw new ND4JIllegalStateException("Shape of the new array " + Arrays.toString(shape) + " doesn't match data length: " + data.length);
}
checkShapeValues(shape);
IComplexNDArray ret = INSTANCE.createComplex(data, shape);
logCreationIfNecessary(ret);
return ret;
}
use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.
the class Nd4j method create.
/**
* Creates a row vector with the specified number of columns
*
* @param columns the columns of the ndarray
* @return the created ndarray
*/
public static INDArray create(int columns, char order) {
if (columns < 1)
throw new ND4JIllegalStateException("Number of columns should be positive for new INDArray");
INDArray ret = INSTANCE.create(new int[] { 1, columns }, Nd4j.getStrides(new int[] { 1, columns }, order), 0, order);
logCreationIfNecessary(ret);
return ret;
}
use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.
the class Nd4j method create.
/**
* Creates an ndarray with the specified shape
*
* @param shape the shape of the ndarray
* @param stride the stride for the ndarray
* @param offset the offset of the ndarray
* @return the instance
*/
public static INDArray create(float[] data, int[] shape, int[] stride, long offset) {
shape = getEnsuredShape(shape);
if (shape.length == 1) {
if (shape[0] == data.length) {
shape = new int[] { 1, data.length };
} else
throw new ND4JIllegalStateException("Shape of the new array " + Arrays.toString(shape) + " doesn't match data length: " + data.length);
}
checkShapeValues(data.length, shape);
INDArray ret = INSTANCE.create(data, shape, stride, offset);
logCreationIfNecessary(ret);
return ret;
}
use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.
the class Nd4j method create.
/**
* Creates an ndarray with the specified shape
*
* @param rows the rows of the ndarray
* @param columns the columns of the ndarray
* @param stride the stride for the ndarray
* @param offset the offset of the ndarray
* @return the instance
*/
public static INDArray create(int rows, int columns, int[] stride, long offset) {
if (rows < 1 || columns < 1)
throw new ND4JIllegalStateException("Number of rows and columns should be positive for new INDArray");
INDArray ret = INSTANCE.create(rows, columns, stride, offset);
logCreationIfNecessary(ret);
return ret;
}
use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.
the class BaseTransformOp method calculateOutputShape.
@Override
public List<int[]> calculateOutputShape() {
List<int[]> ret = new ArrayList<>(1);
if (arg() == null)
throw new ND4JIllegalStateException("No arg found for op!");
val arr = sameDiff.getArrForVarName(arg().getVarName());
if (arr == null)
return Collections.emptyList();
ret.add(arr.shape());
this.n = arr.length();
return ret;
}
Aggregations