Search in sources :

Example 11 with ND4JIllegalStateException

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;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException) IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 12 with ND4JIllegalStateException

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;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 13 with ND4JIllegalStateException

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;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 14 with ND4JIllegalStateException

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;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 15 with ND4JIllegalStateException

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;
}
Also used : lombok.val(lombok.val) ArrayList(java.util.ArrayList) ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Aggregations

ND4JIllegalStateException (org.nd4j.linalg.exception.ND4JIllegalStateException)116 lombok.val (lombok.val)26 INDArray (org.nd4j.linalg.api.ndarray.INDArray)23 CudaContext (org.nd4j.linalg.jcublas.context.CudaContext)21 AllocationPoint (org.nd4j.jita.allocator.impl.AllocationPoint)19 DataBuffer (org.nd4j.linalg.api.buffer.DataBuffer)17 CudaPointer (org.nd4j.jita.allocator.pointers.CudaPointer)15 PagedPointer (org.nd4j.linalg.api.memory.pointers.PagedPointer)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 BaseDataBuffer (org.nd4j.linalg.api.buffer.BaseDataBuffer)7 IComplexNDArray (org.nd4j.linalg.api.complex.IComplexNDArray)6 Pointer (org.bytedeco.javacpp.Pointer)5 ArrayList (java.util.ArrayList)4 DifferentialFunction (org.nd4j.autodiff.functions.DifferentialFunction)4 Aeron (io.aeron.Aeron)3 FragmentAssembler (io.aeron.FragmentAssembler)3 MediaDriver (io.aeron.driver.MediaDriver)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CloseHelper (org.agrona.CloseHelper)3