Search in sources :

Example 6 with ND4JIllegalStateException

use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.

the class Nd4j method createComplex.

/**
 * Creates a complex 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 IComplexNDArray createComplex(double[] data, 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");
    IComplexNDArray ret = INSTANCE.createComplex(data, rows, columns, stride, offset);
    logCreationIfNecessary(ret);
    return ret;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException) IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 7 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 data    the data to use with the ndarray
 * @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(float[] data, 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(data, rows, columns, stride, offset);
    logCreationIfNecessary(ret);
    return ret;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 8 with ND4JIllegalStateException

use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.

the class Nd4j method valueArrayOf.

/**
 * Creates a row vector with the specified number of columns
 *
 * Some people may know this as np.full
 *
 * @param rows    the number of rows in the matrix
 * @param columns the columns of the ndarray
 * @param value   the value to assign
 * @return the created ndarray
 */
public static INDArray valueArrayOf(int rows, int columns, double value) {
    if (rows < 1 || columns < 1)
        throw new ND4JIllegalStateException("Number of rows and columns should be positive for new INDArray");
    INDArray ret = INSTANCE.valueArrayOf(rows, columns, value);
    logCreationIfNecessary(ret);
    return ret;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 9 with ND4JIllegalStateException

use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.

the class Nd4j method create.

/**
 * @param data
 * @param shape
 * @param offset
 * @return
 */
public static INDArray create(double[] data, int[] shape, 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, offset);
    logCreationIfNecessary(ret);
    return ret;
}
Also used : ND4JIllegalStateException(org.nd4j.linalg.exception.ND4JIllegalStateException)

Example 10 with ND4JIllegalStateException

use of org.nd4j.linalg.exception.ND4JIllegalStateException in project nd4j by deeplearning4j.

the class Nd4j method create.

/**
 * @param data
 * @param shape
 * @param ordering
 * @param offset
 * @return
 */
public static INDArray create(float[] data, int[] shape, char ordering, long offset) {
    shape = getEnsuredShape(shape);
    if (shape.length == 1) {
        if (shape[0] != data.length)
            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, getStrides(shape, ordering), offset, ordering);
    logCreationIfNecessary(ret);
    return ret;
}
Also used : 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