public class Nd4j extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Nd4j.PadMode |
Constructor and Description |
---|
Nd4j() |
Modifier and Type | Method and Description |
---|---|
static INDArray |
accumulate(Collection<INDArray> arrays)
This method sums given arrays and stores them to a new target array
|
static INDArray |
accumulate(INDArray... arrays)
This method sums given arrays and stores them to a new array
|
static INDArray |
accumulate(INDArray target,
Collection<INDArray> arrays)
This method sums given arrays and stores them to a given target array
|
static INDArray |
accumulate(INDArray target,
INDArray[] arrays)
This method sums given arrays and stores them to a given target array
|
static boolean |
allowsSpecifyOrdering()
Backend specific:
Returns whether specifying the order
for the blas impl is allowed (cblas)
|
static INDArray |
append(INDArray arr,
int padAmount,
double val,
int axis)
Append the given
array with the specified value size
along a particular axis
|
static INDArray |
appendBias(INDArray... vectors) |
static INDArray |
arange(double end)
Array of evenly spaced values.
|
static INDArray |
arange(double begin,
double end)
Array of evenly spaced values.
|
static boolean |
areThreadSafetyChecksSkipped() |
static INDArray |
argMax(INDArray arr,
int... dimension) |
static INDArray |
argMin(INDArray arr,
int... dimension) |
static INDArray |
averageAndPropagate(Collection<INDArray> arrays)
This method averages input arrays, and returns averaged array.
|
static INDArray |
averageAndPropagate(INDArray[] arrays)
This method averages input arrays, and returns averaged array.
|
static INDArray |
averageAndPropagate(INDArray target,
Collection<INDArray> arrays)
This method averages input arrays, and returns averaged array.
|
static INDArray |
averageAndPropagate(INDArray target,
INDArray[] arrays)
This method averages input arrays, and returns averaged array.
|
static INDArray |
bilinearProducts(INDArray curr,
INDArray in)
Returns a column vector where each entry is the nth bilinear
product of the nth slices of the two tensors.
|
static ReferenceQueue<DataBuffer> |
bufferRefQueue()
The reference queue used for cleaning up
databuffers
|
static void |
checkShapeValues(int[] shape) |
protected static void |
checkShapeValues(int length,
int[] shape) |
protected static void |
checkShapeValues(int length,
long[] shape) |
static void |
checkShapeValues(long[] shape) |
static INDArray |
choice(INDArray source,
INDArray probs,
INDArray target)
This method samples value from Source array to Target, with probabilites provided in Probs argument
|
static INDArray |
choice(INDArray source,
INDArray probs,
INDArray target,
Random rng)
This method samples value from Source array to Target, with probabilites provided in Probs argument
|
static INDArray |
choice(INDArray source,
INDArray probs,
int numSamples)
This method returns new INDArray instance, sampled from Source array with probabilities given in Probs
|
static INDArray |
choice(INDArray source,
INDArray probs,
int numSamples,
Random rng)
This method returns new INDArray instance, sampled from Source array with probabilities given in Probs
|
static void |
clearNans(INDArray arr)
Clear nans from an ndarray
|
static INDArray |
concat(int dimension,
INDArray... toConcat)
Concatneate ndarrays along a dimension
|
static org.bytedeco.javacpp.Pointer |
convertToNumpy(INDArray arr)
Converts an
INDArray
to a numpy struct. |
static void |
copy(INDArray a,
INDArray b)
Copy a to b
|
static INDArray |
create(DataBuffer buffer) |
static INDArray |
create(DataBuffer data,
int[] shape) |
static INDArray |
create(DataBuffer data,
int[] shape,
int[] strides,
long offset) |
static INDArray |
create(DataBuffer data,
int[] newShape,
int[] newStride,
long offset,
char ordering) |
static INDArray |
create(DataBuffer data,
int[] shape,
long offset) |
static INDArray |
create(DataBuffer data,
long[] shape) |
static INDArray |
create(DataBuffer data,
long[] shape,
long[] strides,
long offset) |
static INDArray |
create(DataBuffer data,
long[] newShape,
long[] newStride,
long offset,
char ordering) |
static INDArray |
create(double[] data)
Creates a row vector with the data
|
static INDArray |
create(double[][] data)
Create an ndarray based on the given data layout
|
static INDArray |
create(double[][][] data) |
static INDArray |
create(double[][][][] data) |
static INDArray |
create(double[][] data,
char ordering) |
static INDArray |
create(double[] data,
char order)
Creates a row vector with the data
|
static INDArray |
create(double[] data,
int[] shape)
Create an ndrray with the specified shape
|
static INDArray |
create(double[] data,
int[] shape,
char ordering)
Create an ndrray with the specified shape
|
static INDArray |
create(double[] data,
int[] shape,
char ordering,
long offset) |
static INDArray |
create(double[] data,
int[] shape,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(double[] data,
int[] shape,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(double[] data,
int[] shape,
long offset) |
static INDArray |
create(double[] data,
int[] shape,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(double[] data,
int rows,
int columns,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(double[] data,
int rows,
int columns,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(double[] data,
long[] shape) |
static INDArray |
create(double[] data,
long[] shape,
char ordering) |
static INDArray |
create(double[] data,
long[] shape,
long[] stride,
long offset,
char order) |
static INDArray |
create(double[] data,
long[] shape,
long offset,
char ordering) |
static INDArray |
create(float[] data)
Creates a row vector with the data
|
static INDArray |
create(float[][] data) |
static INDArray |
create(float[][][] data) |
static INDArray |
create(float[][][][] data) |
static INDArray |
create(float[][] data,
char ordering) |
static INDArray |
create(float[] data,
char order)
Creates a row vector with the data
|
static INDArray |
create(float[] data,
int[] shape)
Create an ndrray with the specified shape
|
static INDArray |
create(float[] data,
int[] shape,
char ordering)
Create an ndrray with the specified shape
|
static INDArray |
create(float[] data,
int[] shape,
char ordering,
long offset) |
static INDArray |
create(float[] data,
int[] shape,
int[] stride,
char ordering,
long offset) |
static INDArray |
create(float[] data,
int[] shape,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(float[] data,
int[] shape,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(float[] data,
int[] shape,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(float[] data,
int rows,
int columns,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(float[] data,
int rows,
int columns,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(float[] data,
long[] shape) |
static INDArray |
create(float[] data,
long[] shape,
char ordering) |
static INDArray |
create(float[] data,
long[] shape,
long offset) |
static INDArray |
create(int... shape)
Creates an ndarray with the specified shape
|
static INDArray |
create(int columns)
Creates a row vector with the specified number of columns
|
static INDArray |
create(int[][][] data) |
static INDArray |
create(int[][][][] data) |
static INDArray |
create(int[] shape,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(int[] shape,
DataBuffer.Type dataType) |
static INDArray |
create(int[] sliceShape,
double[]... arrays)
Create an ndarray based on the given data
|
static INDArray |
create(int[] sliceShape,
float[]... arrays)
Create an ndarray based on the given data
|
static INDArray |
create(int[] shape,
int[] stride)
Creates an ndarray with the specified shape
|
static INDArray |
create(int[] shape,
int[] stride,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(int[] shape,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(int[] shape,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(int columns,
char order)
Creates a row vector with the specified number of columns
|
static INDArray |
create(int rows,
int columns)
Creates an ndarray with the specified shape
|
static INDArray |
create(int rows,
int columns,
int[] stride)
Creates an ndarray with the specified shape
|
static INDArray |
create(int rows,
int columns,
int[] stride,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(int rows,
int columns,
int[] stride,
long offset)
Creates an ndarray with the specified shape
|
static INDArray |
create(int rows,
int columns,
int[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(List<? extends Number> list)
Creates a row vector with the data
|
static INDArray |
create(List<INDArray> list,
int[] shape)
Creates an ndarray with the specified shape
|
static INDArray |
create(List<INDArray> list,
int[] shape,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(List<INDArray> list,
long[] shape) |
static INDArray |
create(long... shape)
Creates an ndarray with the specified shape
|
static INDArray |
create(long[] shape,
char ordering) |
static INDArray |
create(long[] shape,
long[] stride) |
static INDArray |
create(long[] shape,
long[] stride,
char ordering) |
static INDArray |
create(long[] shape,
long[] stride,
long offset,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
create(long rows,
long columns,
char ordering)
Creates an ndarray with the specified shape
|
static INDArray |
createArrayFromShapeBuffer(DataBuffer data,
DataBuffer shapeInfo) |
static INDArray |
createArrayFromShapeBuffer(DataBuffer data,
org.nd4j.linalg.primitives.Pair<DataBuffer,long[]> shapeInfo) |
static DataBuffer |
createBuffer(byte[] data,
int length)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(byte[] data,
int length,
long offset)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(ByteBuffer buffer,
DataBuffer.Type type,
int length)
Creates a buffer of the specified opType
and length with the given byte buffer.
|
static DataBuffer |
createBuffer(ByteBuffer buffer,
DataBuffer.Type type,
int length,
long offset)
Creates a buffer of the specified opType
and length with the given byte buffer.
|
static DataBuffer |
createBuffer(DataBuffer underlyingBuffer,
long offset,
long length)
Create a view of a data buffer
that leverages the underlying storage of the buffer
with a new view
|
static DataBuffer |
createBuffer(double[] data)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(double[] data,
long offset)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(org.bytedeco.javacpp.DoublePointer doublePointer,
long length)
Create a double data opType buffer
of the specified length
|
static DataBuffer |
createBuffer(float[] data)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(float[] data,
long offset)
Create a buffer based on the data opType
|
static DataBuffer |
createBuffer(org.bytedeco.javacpp.FloatPointer floatPointer,
long length)
Create a float opType
data buffer of the given length
|
static DataBuffer |
createBuffer(int[] data)
Create a buffer equal of length prod(shape)
|
static DataBuffer |
createBuffer(int[] shape,
DataBuffer.Type type)
Create a buffer equal of length prod(shape)
|
static DataBuffer |
createBuffer(int[] shape,
DataBuffer.Type type,
long offset)
Create a buffer equal of length prod(shape)
|
static DataBuffer |
createBuffer(int[] data,
long offset)
Create a buffer equal of length prod(shape)
|
static DataBuffer |
createBuffer(int length,
long offset)
Creates a buffer of the specified length based on the data opType
|
static DataBuffer |
createBuffer(org.bytedeco.javacpp.IntPointer intPointer,
long length)
Create an int data buffer
from the given pointer
and the given length
|
static DataBuffer |
createBuffer(long length)
Creates a buffer of the specified length based on the data opType
|
static DataBuffer |
createBuffer(long[] data)
Create a buffer equal of length prod(shape)
|
static DataBuffer |
createBuffer(long[] shape,
DataBuffer.Type type) |
static DataBuffer |
createBuffer(long length,
boolean initialize) |
static DataBuffer |
createBuffer(org.bytedeco.javacpp.Pointer pointer,
DataBuffer.Type type,
long length,
org.bytedeco.javacpp.indexer.Indexer indexer)
Create a data buffer
based on a pointer
with the given opType and length
|
static DataBuffer |
createBufferDetached(double[] data) |
static DataBuffer |
createBufferDetached(float[] data) |
static DataBuffer |
createBufferDetached(int[] data)
Create a buffer equal of length prod(shape).
|
static DataBuffer |
createBufferDetached(int[] shape,
DataBuffer.Type type) |
static DataBuffer |
createBufferDetached(long[] data)
Create a buffer equal of length prod(shape).
|
static DataBuffer |
createBufferDetached(long[] shape,
DataBuffer.Type type) |
static INDArray |
createFromFlatArray(FlatArray array)
|
static INDArray |
createFromNpyFile(File file)
Create from a given numpy file.
|
static INDArray |
createFromNpyPointer(org.bytedeco.javacpp.Pointer pointer)
Create from an in memory numpy pointer
|
static INDArray |
createNpyFromByteArray(byte[] input)
Create an
INDArray from
the given numpy input. |
static INDArray |
createNpyFromInputStream(InputStream is)
Create a numpy array based on the passed in
input stream
|
static INDArray |
createSparseCOO(DataBuffer values,
DataBuffer indices,
DataBuffer sparseInformation,
long[] shape) |
static INDArray |
createSparseCOO(DataBuffer data,
DataBuffer indices,
long[] shape) |
static INDArray |
createSparseCOO(DataBuffer values,
DataBuffer indices,
long[] sparseOffsets,
int[] flags,
long[] shape,
int[] hiddenDimensions,
int underlyingRank) |
static INDArray |
createSparseCOO(double[] data,
int[][] indices,
long[] shape) |
static INDArray |
createSparseCOO(double[] data,
long[][] indices,
long[] shape) |
static INDArray |
createSparseCOO(float[] data,
int[][] indices,
long[] shape) |
static INDArray |
createSparseCOO(float[] data,
long[][] indices,
long[] shape) |
static INDArray |
createSparseCSR(DataBuffer data,
int[] columns,
int[] pointerB,
int[] pointerE,
long[] shape) |
static INDArray |
createSparseCSR(double[] data,
int[] columns,
int[] pointerB,
int[] pointerE,
long[] shape) |
static INDArray |
createSparseCSR(float[] data,
int[] columns,
int[] pointerB,
int[] pointerE,
long[] shape) |
static INDArray |
createUninitialized(int length)
This method creates an *uninitialized* ndarray of specified length and default ordering.
|
static INDArray |
createUninitialized(int[] shape)
Creates an *uninitialized* ndarray with the specified shape and default ordering.
NOTE: The underlying memory (DataBuffer) will not be initialized. |
static INDArray |
createUninitialized(int[] shape,
char ordering)
Creates an *uninitialized* ndarray with the specified shape and ordering.
NOTE: The underlying memory (DataBuffer) will not be initialized. |
static INDArray |
createUninitialized(long length) |
static INDArray |
createUninitialized(long[] shape) |
static INDArray |
createUninitialized(long[] shape,
char ordering) |
static INDArray |
createUninitialized(long rows,
long columns)
This method returns uninitialized 2D array of rows x columns
PLEASE NOTE: memory of underlying array will be NOT initialized, and won't be set to 0.0
|
static INDArray |
createUninitializedDetached(int length)
Cretes uninitialized INDArray detached from any (if any) workspace
|
static INDArray |
createUninitializedDetached(int[] shape)
Cretes uninitialized INDArray detached from any (if any) workspace
|
static INDArray |
createUninitializedDetached(int[] shape,
char ordering)
Cretes uninitialized INDArray detached from any (if any) workspace
|
static INDArray |
createUninitializedDetached(long[] shape)
Cretes uninitialized INDArray detached from any (if any) workspace
|
static INDArray |
createUninitializedDetached(long[] shape,
char ordering) |
static INDArray |
cumsum(INDArray compute) |
static INDArray |
cumsum(INDArray compute,
int dimension) |
static DataBuffer.Type |
dataType()
Returns the data opType used for the runtime
|
static INDArray |
diag(INDArray x)
Creates a new matrix where the values of the given vector are the diagonal values of
the matrix if a vector is passed in, if a matrix is returns the kth diagonal
in the matrix
|
static INDArray |
diag(INDArray x,
int k)
Creates a new matrix where the values of the given vector are the diagonal values of
the matrix if a vector is passed in, if a matrix is returns the kth diagonal
in the matrix
|
static void |
doAlongDiagonal(INDArray x,
com.google.common.base.Function<Number,Number> func)
Perform an operation along a diagonal
|
static INDArray |
empty()
This method creates "empty" INDArray
PLEASE NOTE: this feature isn't production ready yet
|
static INDArray |
empty(DataBuffer.Type type) |
static INDArray |
emptyLike(INDArray arr)
Empty like
|
static void |
enableFallbackMode(boolean reallyEnable)
This method enables fallback to safe-mode for specific operations.
|
static INDArray |
expandDims(INDArray input,
int dimension)
Expand the array dimensions.
|
static INDArray |
eye(long n)
Create the identity ndarray
|
static NDArrayFactory |
factory()
The factory used for creating ndarrays
|
static INDArray |
fromByteArray(byte[] arr)
Read an ndarray from a byte array
|
static INDArray |
gemm(INDArray a,
INDArray b,
boolean transposeA,
boolean transposeB)
matrix multiply: implements op(a)*op(b)
where op(x) means transpose x (or not) depending on
setting of arguments transposea and transposeb.
so gemm(a,b,false,false) == a.mmul(b), gemm(a,b,true,false) == a.transpose().mmul(b) etc. |
static INDArray |
gemm(INDArray a,
INDArray b,
INDArray c,
boolean transposeA,
boolean transposeB,
double alpha,
double beta)
Matrix multiply: Implements c = alpha*op(a)*op(b) + beta*c where op(X) means transpose X (or not)
depending on setting of arguments transposeA and transposeB.
Note that matrix c MUST be fortran order, have zero offset and have c.data().length == c.length(). |
static AffinityManager |
getAffinityManager() |
static Nd4jBackend |
getBackend() |
static BlasWrapper |
getBlasWrapper() |
static int[] |
getComplexStrides(int[] shape)
Get the strides based on the shape
and NDArrays.order()
|
static int[] |
getComplexStrides(int[] shape,
char order)
Get the strides for the given order and shape
|
static long[] |
getComplexStrides(long[] shape) |
static long[] |
getComplexStrides(long[] shape,
char order) |
static BasicNDArrayCompressor |
getCompressor()
This method returns BasicNDArrayCompressor instance,
suitable for NDArray compression/decompression
at runtime
|
static ConstantHandler |
getConstantHandler() |
static ConvolutionInstance |
getConvolution()
Get the convolution singleton
|
static DataBufferFactory |
getDataBufferFactory() |
static DistributionFactory |
getDistributions()
Get the primary distributions
factory
|
static OpExecutioner |
getExecutioner()
Get the operation executioner instance
|
static Instrumentation |
getInstrumentation()
Gets the instrumentation instance
|
static MemoryManager |
getMemoryManager()
This method returns backend-specific MemoryManager implementation, for low-level memory management
|
static NDArrayFactory |
getNDArrayFactory() |
static OpFactory |
getOpFactory()
Get the operation factory
|
static Random |
getRandom()
Get the current random generator
|
static RandomFactory |
getRandomFactory()
This method returns RandomFactory instance
|
static ShapeInfoProvider |
getShapeInfoProvider() |
static BlasWrapper |
getSparseBlasWrapper() |
static SparseInfoProvider |
getSparseInfoProvider() |
static int[] |
getStrides(int[] shape)
Get the strides based on the shape
and NDArrays.order()
|
static int[] |
getStrides(int[] shape,
char order)
Get the strides for the given order and shape
|
static long[] |
getStrides(long[] shape)
Get the strides based on the shape
and NDArrays.order()
|
static long[] |
getStrides(long[] shape,
char order) |
static MemoryWorkspaceManager |
getWorkspaceManager()
This method returns WorkspaceManager implementation to be used within this JVM process
|
static INDArray |
hstack(Collection<INDArray> arrs)
Concatenates two matrices horizontally.
|
static INDArray |
hstack(INDArray... arrs)
Concatenates two matrices horizontally.
|
void |
initContext()
Initializes nd4j
|
void |
initWithBackend(Nd4jBackend backend)
Initialize with the specific backend
|
static boolean |
isFallbackModeEnabled()
This method checks, if fallback mode was enabled.
|
static INDArray |
linspace(double lower,
double upper,
long num)
Generate a linearly spaced vector
|
static INDArray |
linspace(float lower,
float upper,
long num)
Generate a linearly spaced vector
|
static INDArray |
linspace(long lower,
long upper,
long num)
Generate a linearly spaced vector
|
static INDArray |
max(INDArray compute) |
static INDArray |
max(INDArray compute,
int dimension) |
static INDArray |
mean(INDArray compute) |
static INDArray |
mean(INDArray compute,
int dimension) |
static INDArray[] |
meshgrid(INDArray x,
INDArray y)
Meshgrid op.
|
static INDArray |
min(INDArray compute) |
static INDArray |
min(INDArray compute,
int dimension) |
static INDArray |
norm1(INDArray compute) |
static INDArray |
norm1(INDArray compute,
int dimension) |
static INDArray |
norm2(INDArray compute) |
static INDArray |
norm2(INDArray compute,
int dimension) |
static INDArray |
normmax(INDArray compute) |
static INDArray |
normmax(INDArray compute,
int dimension) |
static int |
numThreads()
This method returns maximal allowed number of threads for Nd4j.
|
static INDArray |
ones(int... shape)
Create an ndarray of ones
|
static INDArray |
ones(int columns)
Creates a row vector with the specified number of columns
|
static INDArray |
ones(int rows,
int columns)
Creates a row vector with the specified number of columns
|
static INDArray |
ones(long... shape) |
static INDArray |
onesLike(INDArray arr)
Ones like
|
static Character |
order()
Returns the ordering of the ndarrays
|
static INDArray |
pad(INDArray toPad,
int[][] padWidth,
List<double[]> constantValues,
Nd4j.PadMode padMode)
Pad the given ndarray to the size along each dimension
|
static INDArray |
pad(INDArray toPad,
int[][] padWidth,
Nd4j.PadMode padMode)
Pad the given ndarray to the size along each dimension
|
static INDArray |
pad(INDArray toPad,
int[] padWidth,
List<double[]> constantValues,
Nd4j.PadMode padMode)
Pad the given ndarray to the size along each dimension
|
static INDArray |
pad(INDArray toPad,
int[] padWidth,
Nd4j.PadMode padMode)
Pad the given ndarray to the size along each dimension
|
static INDArray |
pile(Collection<INDArray> arrays)
This method stacks vertically examples with the same shape, increasing result dimensionality.
|
static INDArray |
pile(INDArray... arrays)
This method stacks vertically examples with the same shape, increasing result dimensionality.
|
static INDArray |
prepend(INDArray arr,
int padAmount,
double val,
int axis)
Append the given
array with the specified value size
along a particular axis
|
static INDArray |
prod(INDArray compute) |
static INDArray |
prod(INDArray compute,
int dimension) |
static INDArray |
pullRows(INDArray source,
INDArray destination,
int sourceDimension,
int[] indexes)
This method produces concatenated array, that consist from tensors, fetched from source array, against some
dimension and specified indexes.
|
static INDArray |
pullRows(INDArray source,
int sourceDimension,
int[] indexes)
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexes
|
static INDArray |
pullRows(INDArray source,
int sourceDimension,
int[] indexes,
char order)
This method produces concatenated array,
that consist from tensors,
fetched from source array,
against some dimension and specified indexes
|
static INDArray |
rand(char order,
int[] shape)
Create a random ndarray with the given shape and array order
|
static INDArray |
rand(char order,
int rows,
int columns)
Create a random ndarray with the given shape and output order
|
static INDArray |
rand(INDArray target)
Fill the given ndarray with random numbers drawn from a uniform distribution
|
static INDArray |
rand(INDArray target,
Distribution dist)
Fill the given ndarray with random numbers drawn from the given distribution
|
static INDArray |
rand(INDArray target,
double min,
double max,
Random rng)
Fill the given ndarray with random numbers drawn from a uniform distribution using the given RandomGenerator
|
static INDArray |
rand(INDArray target,
long seed)
Fill the given ndarray with random numbers drawn from a uniform distribution
|
static INDArray |
rand(INDArray target,
Random rng)
Fill the given ndarray with random numbers drawn from a uniform distribution using the given RandomGenerator
|
static INDArray |
rand(int[] shape)
Create a random ndarray with the given shape using
the current time as the seed
|
static INDArray |
rand(int[] shape,
Distribution dist)
Create a random ndarray with the given shape using the given rng
|
static INDArray |
rand(int[] shape,
double min,
double max,
Random rng)
Generates a random matrix between min and max
|
static INDArray |
rand(int[] shape,
long seed)
Create a random ndarray with the given shape using given seed
|
static INDArray |
rand(int[] shape,
Random rng)
Create a random ndarray with the given shape using the given RandomGenerator
|
static INDArray |
rand(int rows,
int columns)
Create a random ndarray with the given shape using
the current time as the seed
|
static INDArray |
rand(int rows,
int columns,
double min,
double max,
Random rng)
Generates a random matrix between min and max
|
static INDArray |
rand(int rows,
int columns,
long seed)
Create a random ndarray with the given shape using the given seed
|
static INDArray |
rand(int rows,
int columns,
Random rng)
Create a random ndarray with the given shape using the given rng
|
static INDArray |
rand(long[] shape) |
static INDArray |
rand(long[] shape,
Distribution dist)
Create a random ndarray with the given shape using the given rng
|
static INDArray |
rand(long[] shape,
double min,
double max,
Random rng)
Generates a random matrix between min and max
|
static INDArray |
randn(char order,
int[] shape)
Random normal N(0,1) with the specified shape and array order
|
static INDArray |
randn(char order,
long[] shape)
Random normal N(0,1) with the specified shape and array order
|
static INDArray |
randn(char order,
long rows,
long columns)
Random normal N(0,1) with the specified shape and array order
|
static INDArray |
randn(INDArray target)
Fill the given ndarray with random numbers drawn from a normal distribution
|
static INDArray |
randn(INDArray target,
long seed)
Fill the given ndarray with random numbers drawn from a normal distribution
|
static INDArray |
randn(INDArray target,
Random rng)
Fill the given ndarray with random numbers drawn from a normal distribution utilizing the given random generator
|
static INDArray |
randn(int[] shape)
Random normal using the current time stamp
as the seed
|
static INDArray |
randn(int[] shape,
long seed)
Random normal using the specified seed
|
static INDArray |
randn(int[] shape,
Random r)
Random normal using the given rng
|
static INDArray |
randn(long[] shape) |
static INDArray |
randn(long[] shape,
Random r)
Random normal using the given rng
|
static INDArray |
randn(long rows,
long columns)
Random normal using the current time stamp
as the seed
|
static INDArray |
randn(long rows,
long columns,
long seed)
Random normal using the specified seed
|
static INDArray |
randn(long rows,
long columns,
Random r)
Random normal using the given rng
|
static INDArray |
randomBernoulli(double p,
INDArray target)
Fill the specified array with values generated according to a binomial distribution with probability p: i.e.,
values 0 with probability (1-p) or value 1 with probability p
|
static INDArray |
randomBernoulli(double p,
long... shape)
Generate a random array according to a binomial distribution with probability p: i.e., values 0 with probability
(1-p) or value 1 with probability p
|
static INDArray |
randomBinomial(int nTrials,
double p,
INDArray target)
Fill the target array with random values generated according to a binomial distribution with the specified
number of trials and probability
|
static INDArray |
randomBinomial(int nTrials,
double p,
long... shape)
Generate an array with random values generated according to a binomial distribution with the specified
number of trials and probability
|
static INDArray |
randomExponential(double lambda,
INDArray target)
Exponential distribution: P(x) = lambda * exp(-lambda * x)
|
static INDArray |
randomExponential(double lambda,
long... shape)
Exponential distribution: P(x) = lambda * exp(-lambda * x)
|
static INDArray |
read(DataInputStream dis)
Read in an ndarray from a data input stream
|
static INDArray |
read(InputStream reader)
Raad an ndarray from an input stream
|
static INDArray |
readBinary(File read)
Read a binary ndarray from the given file
|
static INDArray |
readNumpy(InputStream filePath,
String split)
Read line via input streams
|
static INDArray |
readNumpy(String filePath)
Read line via input streams
|
static INDArray |
readNumpy(String filePath,
String split)
Read line via input streams
|
static INDArray |
readTxt(String filePath)
Read line via input streams
|
static INDArray |
readTxtString(InputStream ndarray)
Read line via input streams
|
static ReferenceQueue<INDArray> |
refQueue()
The reference queue used for cleaning up
ndarrays
|
static INDArray |
repeat(INDArray n,
int num)
Create an n x (shape)
ndarray where the ndarray is repeated num times
|
static INDArray |
reverse(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etc
|
static INDArray |
rollAxis(INDArray a,
int axis)
Roll the specified axis backwards,
until it lies in a given position.
|
static INDArray |
rollAxis(INDArray a,
int axis,
int start)
Roll the specified axis backwards,
until it lies in a given position.
|
static INDArray |
rot(INDArray reverse)
Reverses the passed in matrix such that m[0] becomes m[m.length - 1] etc
|
static void |
rot90(INDArray toRotate)
Rotate a matrix 90 degrees
|
static void |
saveBinary(INDArray arr,
File saveTo)
Save an ndarray to the given file
|
static INDArray |
scalar(double value)
Create a scalar nd array with the specified value and offset
|
static INDArray |
scalar(double value,
long offset)
Create a scalar nd array with the specified value and offset
|
static INDArray |
scalar(float value)
Create a scalar nd array with the specified value and offset
|
static INDArray |
scalar(float value,
long offset)
Create a scalar nd array with the specified value and offset
|
static INDArray |
scalar(Number value)
Create a scalar ndarray with the specified offset
|
static INDArray |
scalar(Number value,
long offset)
Create a scalar ndarray with the specified offset
|
static void |
setBlasWrapper(BlasWrapper factory)
Sets the global blas wrapper
|
static void |
setConvolution(ConvolutionInstance convolutionInstance)
Set a convolution instance
|
static void |
setDataType(DataBuffer.Type dType)
This method sets dataType for the current JVM runtime
|
static void |
setFactory(NDArrayFactory factory) |
static void |
setNdArrayFactoryClazz(Class<? extends NDArrayFactory> clazz) |
static void |
setNumThreads(int numthreads)
This method sets maximal allowed number of threads for Nd4j
|
static void |
setParams(INDArray theta,
Collection<INDArray>... matrices)
Given a sequence of Iterators over a transform of matrices, fill in all of
the matrices with the entries in the theta vector.
|
static void |
setParams(INDArray theta,
Iterator<? extends INDArray>... matrices)
Given a sequence of Iterators over a transform of matrices, fill in all of
the matrices with the entries in the theta vector.
|
static void |
setSparseFactory(NDArrayFactory factory) |
static void |
setSparseNDArrayClazz(Class<? extends NDArrayFactory> clazz) |
static long[] |
shape(INDArray arr)
Returns the shape of the ndarray
|
static void |
shuffle(Collection<INDArray> toShuffle,
int... dimension)
Symmetric in place shuffle of an ndarray
along a specified set of dimensions
|
static void |
shuffle(Collection<INDArray> toShuffle,
Random rnd,
int... dimension)
Symmetric in place shuffle of an ndarray
along a specified set of dimensions
|
static void |
shuffle(INDArray toShuffle,
int... dimension)
In place shuffle of an ndarray
along a specified set of dimensions
|
static void |
shuffle(INDArray toShuffle,
Random random,
int... dimension)
In place shuffle of an ndarray
along a specified set of dimensions
|
static void |
shuffle(List<INDArray> toShuffle,
Random rnd,
List<int[]> dimensions)
Symmetric in place shuffle of an ndarray
along a variable dimensions
|
static int |
sizeOfDataType()
This method returns sizeOf(currentDataType), in bytes
|
static int |
sizeOfDataType(DataBuffer.Type dtype)
This method returns size of element for specified dataType, in bytes
|
static void |
skipThreadSafetyChecks(boolean reallySkip) |
static INDArray |
sort(INDArray ndarray,
boolean ascending) |
static INDArray |
sort(INDArray ndarray,
int dimension,
boolean ascending)
Sort an ndarray along a particular dimension
Note that the input array is modified in-place. |
static INDArray |
sortColumns(INDArray in,
int rowIdx,
boolean ascending)
Sort (shuffle) the columns of a 2d array according to the value at a specified row.
|
static INDArray |
sortRows(INDArray in,
int colIdx,
boolean ascending)
Sort (shuffle) the rows of a 2d array according to the value at a specified column.
|
static INDArray[] |
sortWithIndices(INDArray ndarray,
int dimension,
boolean ascending)
Sort an ndarray along a particular dimension.
Note that the input array is modified in-place. |
static NDArrayFactory |
sparseFactory() |
static INDArray |
specialConcat(int dimension,
INDArray... toConcat)
Concatneate ndarrays along a dimension
PLEASE NOTE: This method is special for GPU backend, it works on HOST side only.
|
static INDArray |
squeeze(INDArray input,
int dimension)
Squeeze : removes a dimension of size 1
|
static INDArray |
stack(int axis,
INDArray... values)
Stack a set of N SDVariables of rank X into one rank X+1 variable.
|
static INDArray |
std(INDArray compute) |
static INDArray |
std(INDArray compute,
int dimension) |
static INDArray |
stripOnes(INDArray toStrip)
Reshapes an ndarray to remove leading 1s
|
static INDArray |
sum(INDArray compute) |
static INDArray |
sum(INDArray compute,
int dimension) |
static INDArray[] |
tear(INDArray tensor,
int... dimensions)
This method does the opposite to pile/vstack/hstack - it returns independent TAD copies along given dimensions
|
static INDArray |
tensorMmul(INDArray a,
INDArray b,
INDArray result,
int[][] axes)
Tensor matrix multiplication.
|
static INDArray |
tensorMmul(INDArray a,
INDArray b,
int[][] axes)
Tensor matrix multiplication.
|
static INDArray |
tile(INDArray tile,
int... repeat)
An alias for repmat
|
static byte[] |
toByteArray(INDArray arr)
Convert an ndarray to a byte array
|
static INDArray |
toFlattened(char order,
Collection<INDArray> matrices)
Create a long row vector of all of the given ndarrays
|
static INDArray |
toFlattened(char order,
INDArray... matrices)
Create a long row vector of all of the given ndarrays/
|
static INDArray |
toFlattened(Collection<INDArray> matrices)
Create a long row vector of all of the given ndarrays
|
static INDArray |
toFlattened(INDArray... matrices)
Create a long row vector of all of the given ndarrays
|
static INDArray |
toFlattened(int length,
Iterator<? extends INDArray>... matrices)
Create a long row vector of all of the given ndarrays
|
static byte[] |
toNpyByteArray(INDArray input)
Converts an
INDArray
to a byte array |
static INDArray |
tri(int n) |
static INDArray |
tri(int n,
int k) |
static INDArray |
tri(int n,
int m,
int k)
Like the scipy function tri.
|
static INDArray |
triu(INDArray m,
int k)
Upper triangle of an array.
|
static INDArray |
trueScalar(Number scalar)
This method creates new 0D INDArray, aka scalar.
|
static INDArray |
trueVector(double[] data) |
static INDArray |
trueVector(float[] data) |
static INDArray |
typeConversion(INDArray array,
DataBuffer.TypeEx targetType) |
static INDArray |
valueArrayOf(int[] shape,
double value)
Creates an ndarray with the specified value
as the only value in the ndarray.
|
static INDArray |
valueArrayOf(long[] shape,
double value)
Creates an ndarray with the specified value
as the only value in the ndarray.
|
static INDArray |
valueArrayOf(long num,
double value)
Creates a row vector ndarray with the specified value
as the only value in the ndarray
Some people may know this as np.full
|
static INDArray |
valueArrayOf(long rows,
long columns,
double value)
Creates a row vector with the specified number of columns
Some people may know this as np.full
|
static INDArray |
var(INDArray compute) |
static INDArray |
var(INDArray compute,
int dimension) |
static INDArray |
vstack(Collection<INDArray> arrs)
Concatenates two matrices vertically.
|
static INDArray |
vstack(INDArray... arrs)
Concatenates two matrices vertically.
|
static INDArray[] |
where(INDArray condition,
INDArray x,
INDArray y)
Similar to numpy.where operation.
|
static void |
write(INDArray arr,
DataOutputStream dataOutputStream)
Write an ndarray to the specified outputstream
|
static void |
write(OutputStream writer,
INDArray write)
Y
Write an ndarray to a writer
|
static void |
writeAsNumpy(INDArray arr,
File file)
|
static void |
writeAsNumpy(INDArray arr,
OutputStream writeTo)
Writes an array to an output stream
|
static void |
writeTxt(INDArray write,
String filePath)
Write NDArray to a text file
|
static void |
writeTxt(INDArray write,
String filePath,
int precision)
Deprecated.
Precision is no longer used.
Defaults to scientific notation with 18 digits after the decimal
Use
writeTxt(INDArray, String) |
static void |
writeTxt(INDArray write,
String filePath,
String split)
Deprecated.
custom col and higher dimension separators are no longer supported; uses ","
Use
writeTxt(INDArray, String) |
static void |
writeTxt(INDArray write,
String filePath,
String split,
int precision)
Deprecated.
custom col separators are no longer supported; uses ","
|
static void |
writeTxtString(INDArray write,
OutputStream os)
Write ndarray as text to output stream
|
static void |
writeTxtString(INDArray write,
OutputStream os,
int precision)
Deprecated.
precision can no longer be specified. The array is written in scientific notation.
Use
writeTxtString(INDArray, OutputStream) |
static void |
writeTxtString(INDArray write,
OutputStream os,
String split)
Deprecated.
column separator can longer be specified; Uses ","
Use
writeTxtString(INDArray, OutputStream) instead |
static void |
writeTxtString(INDArray write,
OutputStream os,
String split,
int precision)
Deprecated.
custom col separators are no longer supported; uses ","
|
static INDArray |
zeros(int... shape)
Create an ndarray of zeros
|
static INDArray |
zeros(int columns)
Creates a row vector with the specified number of columns
|
static INDArray |
zeros(int[] shape,
char order)
Create an ndarray of zeros
|
static INDArray |
zeros(int[] shape,
DataBuffer.Type dataType) |
static INDArray |
zeros(int[] shape,
int[] stride) |
static INDArray |
zeros(int[] shape,
int[] stride,
char ordering) |
static INDArray |
zeros(int[] shape,
int[] stride,
long offset) |
static INDArray |
zeros(int[] shape,
int[] stride,
long offset,
char ordering) |
static INDArray |
zeros(int columns,
char order) |
static INDArray |
zeros(int rows,
int columns,
char ordering) |
static INDArray |
zeros(int rows,
int columns,
int[] stride) |
static INDArray |
zeros(int rows,
int columns,
int[] stride,
char ordering) |
static INDArray |
zeros(int rows,
int columns,
int[] stride,
long offset) |
static INDArray |
zeros(int rows,
int columns,
int[] stride,
long offset,
char ordering) |
static INDArray |
zeros(long... shape)
Create an ndarray of zeros
|
static INDArray |
zeros(long[] shape,
char order) |
static INDArray |
zeros(long rows,
long columns)
Creates a row vector with the specified number of columns
|
static INDArray |
zerosLike(INDArray arr)
Empty like
|
public static final String NUMERICAL_STABILITY
public static final String DATA_BUFFER_OPS
public static final String CONVOLUTION_OPS
@Deprecated public static final String DTYPE
ND4JSystemProperties.DTYPE
public static final String BLAS_OPS
public static final String SPARSE_BLAS_OPS
public static final String NATIVE_OPS
public static final String ORDER_KEY
public static final String NDARRAY_FACTORY_CLASS
public static final String SPARSE_NDARRAY_FACTORY_CLASS
public static final String COPY_OPS
public static final String OP_EXECUTIONER
public static final String OP_FACTORY
public static final String DISTRIBUTION
public static final String INSTRUMENTATION
public static final String INSTRUMENTATION_CLASS
public static final String RESOURCE_MANGER_ON
public static final String EXECUTION_MODE
public static final String SHAPEINFO_PROVIDER
public static final String SPARSEINFO_PROVIDER
public static final String CONSTANT_PROVIDER
public static final String AFFINITY_MANAGER
public static final String COMPRESSION_DEBUG
public static final String MEMORY_MANAGER
public static final String WORKSPACE_MANAGER
public static final String RANDOM_PROVIDER
@Deprecated public static final String LOG_INIT_ENV_PROPERTY
ND4JSystemProperties.LOG_INITIALIZATION
public static OpExecutioner.ExecutionMode executionMode
protected static DataBuffer.Type dtype
public static DataBuffer.AllocationMode alloc
public static char ORDER
public static double EPS_THRESHOLD
public static int MAX_ELEMENTS_PER_SLICE
public static int MAX_SLICES_TO_PRINT
public static boolean ENFORCE_NUMERICAL_STABILITY
public static boolean copyOnOps
public static boolean shouldInstrument
public static boolean resourceManagerOn
public static boolean compressDebug
public static volatile boolean preventUnpack
public static Nd4jBackend backend
public static RandomFactory randomFactory
protected static Class<? extends MemoryWorkspaceManager> workspaceManagerClazz
protected static Class<? extends BlasWrapper> blasWrapperClazz
protected static Class<? extends BlasWrapper> sparseBlasWrapperClazz
protected static Class<? extends NDArrayFactory> ndArrayFactoryClazz
protected static Class<? extends NDArrayFactory> sparseNDArrayClazz
protected static Class<? extends ConvolutionInstance> convolutionInstanceClazz
protected static Class<? extends DataBufferFactory> dataBufferFactoryClazz
protected static Class<? extends OpExecutioner> opExecutionerClazz
protected static Class<? extends DistributionFactory> distributionFactoryClazz
protected static Class<? extends Instrumentation> instrumentationClazz
protected static Class<? extends BaseShapeInfoProvider> shapeInfoProviderClazz
protected static Class<? extends BaseSparseInfoProvider> sparseInfoProviderClazz
protected static Class<? extends BasicConstantHandler> constantProviderClazz
protected static Class<? extends BasicAffinityManager> affinityManagerClazz
protected static Class<? extends BasicMemoryManager> memoryManagerClazz
protected static DataBufferFactory DATA_BUFFER_FACTORY_INSTANCE
protected static BlasWrapper BLAS_WRAPPER_INSTANCE
protected static BlasWrapper SPARSE_BLAS_WRAPPER_INSTANCE
protected static NDArrayFactory INSTANCE
protected static NDArrayFactory SPARSE_INSTANCE
protected static ConvolutionInstance CONVOLUTION_INSTANCE
protected static OpExecutioner OP_EXECUTIONER_INSTANCE
protected static DistributionFactory DISTRIBUTION_FACTORY
protected static OpFactory OP_FACTORY_INSTANCE
protected static Instrumentation instrumentation
protected static ShapeInfoProvider shapeInfoProvider
protected static SparseInfoProvider sparseInfoProvider
protected static ConstantHandler constantHandler
protected static AffinityManager affinityManager
protected static MemoryManager memoryManager
protected static AtomicBoolean fallbackMode
protected static Properties props
protected static ReferenceQueue<INDArray> referenceQueue
protected static ReferenceQueue<DataBuffer> bufferQueue
public static INDArray pad(INDArray toPad, int[][] padWidth, Nd4j.PadMode padMode)
toPad
- the ndarray to padpadWidth
- the width to pad along each dimensionpadMode
- the mode to pad inpublic static INDArray pad(INDArray toPad, int[][] padWidth, List<double[]> constantValues, Nd4j.PadMode padMode)
toPad
- the ndarray to padpadWidth
- the width to pad along each dimensionconstantValues
- the values to append for each dimensionpadMode
- the mode to pad inpublic static INDArray pad(INDArray toPad, int[] padWidth, List<double[]> constantValues, Nd4j.PadMode padMode)
toPad
- the ndarray to padpadWidth
- the width to pad along each dimensionconstantValues
- the values to append for each dimensionpadMode
- the mode to pad inpublic static INDArray pad(INDArray toPad, int[] padWidth, Nd4j.PadMode padMode)
toPad
- the ndarray to padpadWidth
- the width to pad along each dimensionpadMode
- the mode to pad inpublic static INDArray append(INDArray arr, int padAmount, double val, int axis)
arr
- the array to append topadAmount
- the pad amount of the array to be returnedval
- the value to appendaxis
- the axis to append topublic static INDArray prepend(INDArray arr, int padAmount, double val, int axis)
arr
- the array to append topadAmount
- the pad amount of the array to be returnedval
- the value to appendaxis
- the axis to append topublic static INDArray expandDims(INDArray input, int dimension)
input
- the input arraydimension
- the dimension to add the
new axis atpublic static INDArray squeeze(INDArray input, int dimension)
input
- the input arraydimension
- the dimension to removepublic static boolean allowsSpecifyOrdering()
public static void shuffle(INDArray toShuffle, Random random, int... dimension)
toShuffle
- the ndarray to shufflerandom
- the random to usedimension
- the dimension to do the shufflepublic static void shuffle(INDArray toShuffle, int... dimension)
toShuffle
- the ndarray to shuffledimension
- the dimension to do the shufflepublic static void shuffle(Collection<INDArray> toShuffle, int... dimension)
toShuffle
- the ndarray to shuffledimension
- the dimension to do the shufflepublic static void shuffle(Collection<INDArray> toShuffle, Random rnd, int... dimension)
toShuffle
- the ndarray to shuffledimension
- the dimension to do the shufflepublic static void shuffle(List<INDArray> toShuffle, Random rnd, List<int[]> dimensions)
toShuffle
- the ndarray to shuffledimensions
- the dimension to do the shuffle. Please note - order matters here.public static ReferenceQueue<INDArray> refQueue()
public static ReferenceQueue<DataBuffer> bufferRefQueue()
public static Instrumentation getInstrumentation()
public static DistributionFactory getDistributions()
public static void setNdArrayFactoryClazz(Class<? extends NDArrayFactory> clazz)
public static void setSparseNDArrayClazz(Class<? extends NDArrayFactory> clazz)
public static Random getRandom()
public static RandomFactory getRandomFactory()
public static ConvolutionInstance getConvolution()
public static void setConvolution(ConvolutionInstance convolutionInstance)
convolutionInstance
- public static long[] shape(INDArray arr)
arr
- the array to get the shape ofpublic static INDArray create(int[] sliceShape, float[]... arrays)
sliceShape
- the shape of each slicearrays
- the arrays of data to createpublic static INDArray create(int[] sliceShape, double[]... arrays)
sliceShape
- the shape of each slicearrays
- the arrays of data to createpublic static OpExecutioner getExecutioner()
public static OpFactory getOpFactory()
public static DataBufferFactory getDataBufferFactory()
public static void setParams(INDArray theta, Collection<INDArray>... matrices)
public static INDArray rollAxis(INDArray a, int axis)
a
- the array to rollaxis
- the axis to roll backwardspublic static INDArray argMax(INDArray arr, int... dimension)
arr
- dimension
- public static INDArray argMin(INDArray arr, int... dimension)
arr
- dimension
- public static INDArray rollAxis(INDArray a, int axis, int start)
a
- the array to rollaxis
- the axis to roll backwardsstart
- the starting pointpublic static INDArray tensorMmul(INDArray a, INDArray b, INDArray result, int[][] axes)
a
- the left tensorb
- the right tensorresult
- the result arrayaxes
- the axes for each array to do matrix multiply alongpublic static INDArray tensorMmul(INDArray a, INDArray b, int[][] axes)
a
- the left tensorb
- the right tensoraxes
- the axes for each array to do matrix multiply alongpublic static INDArray gemm(INDArray a, INDArray b, boolean transposeA, boolean transposeB)
a
- first matrixb
- second matrixtransposeA
- if true: transpose matrix a before mmultransposeB
- if true: transpose matrix b before mmulpublic static INDArray gemm(INDArray a, INDArray b, INDArray c, boolean transposeA, boolean transposeB, double alpha, double beta)
a
- First matrixb
- Second matrixc
- result matrix. Used in calculation (assuming beta != 0) and result is stored in this. f order, and not a view onlytransposeA
- if true: transpose matrix a before mmultransposeB
- if true: transpose matrix b before mmulpublic static void setParams(INDArray theta, Iterator<? extends INDArray>... matrices)
public static NDArrayFactory factory()
public static NDArrayFactory sparseFactory()
public static DataBuffer createBuffer(DataBuffer underlyingBuffer, long offset, long length)
underlyingBuffer
- the underlying bufferoffset
- the offset for the viewpublic static DataBuffer createBuffer(int[] shape, DataBuffer.Type type, long offset)
shape
- the shape of the buffer to createtype
- the opType to createpublic static DataBuffer createBuffer(ByteBuffer buffer, DataBuffer.Type type, int length, long offset)
buffer
- the buffer to create fromtype
- the opType of buffer to createlength
- the length of the bufferpublic static DataBuffer createBuffer(byte[] data, int length, long offset)
data
- the data to create the buffer withpublic static DataBuffer createBuffer(int[] data, long offset)
data
- the shape of the buffer to createpublic static DataBuffer createBuffer(int length, long offset)
length
- the length of te bufferpublic static DataBuffer createBuffer(org.bytedeco.javacpp.DoublePointer doublePointer, long length)
doublePointer
- length
- public static DataBuffer createBuffer(org.bytedeco.javacpp.FloatPointer floatPointer, long length)
floatPointer
- length
- public static DataBuffer createBuffer(org.bytedeco.javacpp.IntPointer intPointer, long length)
intPointer
- length
- public static DataBuffer createBuffer(float[] data, long offset)
data
- the data to create the buffer withpublic static DataBuffer createBuffer(double[] data, long offset)
data
- the data to create the buffer withpublic static DataBuffer createBuffer(int[] shape, DataBuffer.Type type)
shape
- the shape of the buffer to createtype
- the opType to createpublic static DataBuffer createBufferDetached(int[] shape, DataBuffer.Type type)
public static DataBuffer createBuffer(long[] shape, DataBuffer.Type type)
public static DataBuffer createBufferDetached(long[] shape, DataBuffer.Type type)
public static DataBuffer createBuffer(ByteBuffer buffer, DataBuffer.Type type, int length)
buffer
- the buffer to create fromtype
- the opType of buffer to createlength
- the length of the bufferpublic static DataBuffer createBuffer(byte[] data, int length)
data
- the data to create the buffer withpublic static DataBuffer createBuffer(int[] data)
data
- the shape of the buffer to createpublic static DataBuffer createBuffer(long[] data)
data
- the shape of the buffer to createpublic static DataBuffer createBufferDetached(int[] data)
data
- public static DataBuffer createBufferDetached(long[] data)
data
- public static DataBuffer createBuffer(long length)
length
- the length of te bufferpublic static DataBuffer createBuffer(org.bytedeco.javacpp.Pointer pointer, DataBuffer.Type type, long length, org.bytedeco.javacpp.indexer.Indexer indexer)
pointer
- the pointer to create the buffer fortype
- the opType of pointerlength
- the length of the bufferindexer
- the indexer to usepublic static DataBuffer createBuffer(long length, boolean initialize)
length
- initialize
- public static DataBuffer createBuffer(float[] data)
data
- the data to create the buffer withpublic static DataBuffer createBufferDetached(float[] data)
public static DataBuffer createBufferDetached(double[] data)
public static DataBuffer createBuffer(double[] data)
data
- the data to create the buffer withpublic static void setFactory(NDArrayFactory factory)
public static void setSparseFactory(NDArrayFactory factory)
public static Character order()
public static DataBuffer.Type dataType()
public static void setDataType(@NonNull DataBuffer.Type dType)
dType
- public static Nd4jBackend getBackend()
public static BlasWrapper getBlasWrapper()
public static BlasWrapper getSparseBlasWrapper()
public static void setBlasWrapper(BlasWrapper factory)
factory
- public static INDArray[] sortWithIndices(INDArray ndarray, int dimension, boolean ascending)
ndarray
- the ndarray to sortdimension
- the dimension to sortpublic static INDArray sort(INDArray ndarray, int dimension, boolean ascending)
ndarray
- the ndarray to sortdimension
- the dimension to sortpublic static INDArray sortRows(INDArray in, int colIdx, boolean ascending)
in
- 2d array to sortcolIdx
- The column to sort onascending
- true if smallest-to-largest; false if largest-to-smallestpublic static INDArray sortColumns(INDArray in, int rowIdx, boolean ascending)
in
- 2d array to sortrowIdx
- The row to sort onascending
- true if smallest-to-largest; false if largest-to-smallestpublic static INDArray repeat(INDArray n, int num)
n
- the ndarray to replicatenum
- the number of copies to repeatpublic static INDArray linspace(long lower, long upper, long num)
lower
- upper boundupper
- lower boundnum
- the step sizepublic static INDArray linspace(double lower, double upper, long num)
lower
- upper boundupper
- lower boundnum
- the step sizepublic static INDArray linspace(float lower, float upper, long num)
lower
- upper boundupper
- lower boundnum
- the step sizepublic static INDArray[] meshgrid(@NonNull INDArray x, @NonNull INDArray y)
x
- X array inputy
- Y array inputpublic static INDArray toFlattened(Collection<INDArray> matrices)
matrices
- the matrices to create the flattened ndarray forpublic static INDArray toFlattened(char order, Collection<INDArray> matrices)
order
- the order in which to flatten the matricesmatrices
- the matrices to create the flattened ndarray forpublic static INDArray toFlattened(int length, Iterator<? extends INDArray>... matrices)
matrices
- the matrices to create the flattened ndarray forpublic static INDArray bilinearProducts(INDArray curr, INDArray in)
public static INDArray toFlattened(INDArray... matrices)
matrices
- the matrices to create the flattened ndarray forpublic static INDArray toFlattened(char order, INDArray... matrices)
order
- order in which to flatten ndarraysmatrices
- the matrices to create the flattened ndarray forpublic static INDArray eye(long n)
n
- the number for the identitypublic static void rot90(INDArray toRotate)
toRotate
- the matrix to rotatepublic static void writeTxt(INDArray write, String filePath, String split, int precision)
filePath
- split
- the split separator, defaults to ","precision
- digits after the decimal pointpublic static void writeTxt(INDArray write, String filePath, int precision)
writeTxt(INDArray, String)
write
- filePath
- precision
- public static void writeTxt(INDArray write, String filePath, String split)
writeTxt(INDArray, String)
write
- filePath
- split
- public static void writeTxt(INDArray write, String filePath)
write
- Array to writefilePath
- public static void writeTxtString(INDArray write, OutputStream os, String split, int precision)
os
- the outputstream stream ndarraysplit
- precision
- @Deprecated public static void writeTxtString(INDArray write, OutputStream os, int precision)
writeTxtString(INDArray, OutputStream)
write
- os
- precision
- @Deprecated public static void writeTxtString(INDArray write, OutputStream os, String split)
writeTxtString(INDArray, OutputStream)
insteadwrite
- os
- split
- public static void writeTxtString(INDArray write, OutputStream os)
write
- os
- public static void write(OutputStream writer, INDArray write) throws IOException
writer
- the writer to write towrite
- the ndarray to writeIOException
public static byte[] toByteArray(INDArray arr) throws IOException
arr
- the array to convertIOException
public static INDArray fromByteArray(byte[] arr) throws IOException
arr
- the array to read fromIOException
public static INDArray readNumpy(InputStream filePath, String split) throws IOException
filePath
- the input stream ndarraysplit
- the split separatorIOException
public static INDArray readNumpy(String filePath, String split) throws IOException
filePath
- the input stream ndarraysplit
- the split separatorIOException
public static INDArray readNumpy(String filePath) throws IOException
filePath
- the input stream ndarrayIOException
public static INDArray read(InputStream reader) throws IOException
reader
- the input stream to useIOException
public static INDArray readTxtString(InputStream ndarray)
ndarray
- the input stream ndarraypublic static INDArray readTxt(String filePath)
filePath
- the input stream ndarraypublic static INDArray createArrayFromShapeBuffer(DataBuffer data, DataBuffer shapeInfo)
data
- shapeInfo
- public static INDArray createArrayFromShapeBuffer(DataBuffer data, org.nd4j.linalg.primitives.Pair<DataBuffer,long[]> shapeInfo)
data
- shapeInfo
- public static INDArray read(DataInputStream dis) throws IOException
dis
- the data input stream to read fromIOException
public static void write(INDArray arr, DataOutputStream dataOutputStream) throws IOException
arr
- the array to writedataOutputStream
- the data output stream to write toIOException
public static void saveBinary(INDArray arr, File saveTo) throws IOException
arr
- the array to savesaveTo
- the file to save toIOException
public static INDArray readBinary(File read) throws IOException
read
- the nd array to readIOException
public static void clearNans(INDArray arr)
arr
- the array to clearpublic static INDArray rot(INDArray reverse)
reverse
- the matrix to reversepublic static INDArray reverse(INDArray reverse)
reverse
- the matrix to reversepublic static INDArray arange(double begin, double end)
begin
- the begin of the rangeend
- the end of the rangepublic static INDArray arange(double end)
end
- the end of the rangepublic static void copy(INDArray a, INDArray b)
a
- the origin matrixb
- the destination matrixpublic static INDArray diag(INDArray x, int k)
x
- the diagonal valuesk
- the kth diagonal to getpublic static INDArray diag(INDArray x)
x
- the diagonal valuespublic static INDArray choice(@NonNull INDArray source, @NonNull INDArray probs, @NonNull INDArray target, @NonNull Random rng)
source
- probs
- target
- public static INDArray choice(INDArray source, INDArray probs, INDArray target)
source
- probs
- target
- public static INDArray choice(INDArray source, INDArray probs, int numSamples, @NonNull Random rng)
source
- probs
- numSamples
- public static INDArray choice(INDArray source, INDArray probs, int numSamples)
source
- probs
- numSamples
- public static void doAlongDiagonal(INDArray x, com.google.common.base.Function<Number,Number> func)
x
- the ndarray to perform the operation onfunc
- the operation to performpublic static INDArray rand(int[] shape)
shape
- the shape of the ndarraypublic static INDArray rand(long[] shape)
public static INDArray rand(char order, int[] shape)
order
- the order of the ndarray to returnshape
- the shape of the ndarraypublic static INDArray rand(int rows, int columns)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixpublic static INDArray rand(char order, int rows, int columns)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixpublic static INDArray rand(int[] shape, long seed)
shape
- the shape of the ndarrayseed
- the seed to usepublic static INDArray rand(int rows, int columns, long seed)
rows
- the number of rows in the matrixcolumns
- the columns of the ndarrayseed
- the seed to usepublic static INDArray rand(int[] shape, Random rng)
shape
- the shape of the ndarrayrng
- the random generator to usepublic static INDArray rand(int[] shape, Distribution dist)
shape
- the shape of the ndarraydist
- distribution to usepublic static INDArray rand(long[] shape, Distribution dist)
shape
- the shape of the ndarraydist
- distribution to usepublic static INDArray rand(int rows, int columns, Random rng)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixrng
- the random generator to usepublic static INDArray rand(int[] shape, double min, double max, Random rng)
shape
- the number of rows of the matrixmin
- the minimum numbermax
- the maximum numberrng
- the rng to usepublic static INDArray rand(long[] shape, double min, double max, Random rng)
shape
- the number of rows of the matrixmin
- the minimum numbermax
- the maximum numberrng
- the rng to usepublic static INDArray rand(int rows, int columns, double min, double max, Random rng)
rows
- the number of rows of the matrixcolumns
- the number of columns in the matrixmin
- the minimum numbermax
- the maximum numberrng
- the rng to usepublic static INDArray randn(INDArray target)
target
- target arraypublic static INDArray randn(int[] shape)
shape
- the shape of the ndarraypublic static INDArray randn(long[] shape)
public static INDArray randn(char order, int[] shape)
order
- order of the output ndarrayshape
- the shape of the ndarraypublic static INDArray randn(char order, long[] shape)
order
- order of the output ndarrayshape
- the shape of the ndarraypublic static INDArray randn(int[] shape, long seed)
shape
- the shape of the ndarraypublic static INDArray randn(long rows, long columns)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixpublic static INDArray randn(char order, long rows, long columns)
order
- the order of the output arrayrows
- the number of rows in the matrixcolumns
- the number of columns in the matrixpublic static INDArray randn(long rows, long columns, long seed)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixpublic static INDArray randn(long rows, long columns, Random r)
rows
- the number of rows in the matrixcolumns
- the number of columns in the matrixr
- the random generator to usepublic static INDArray randn(int[] shape, Random r)
shape
- the shape of the ndarrayr
- the random generator to usepublic static INDArray randn(long[] shape, Random r)
shape
- the shape of the ndarrayr
- the random generator to usepublic static INDArray rand(INDArray target)
target
- target arraypublic static INDArray rand(INDArray target, long seed)
target
- target arrayseed
- the seed to usepublic static INDArray rand(INDArray target, Random rng)
target
- target arrayrng
- the random generator to usepublic static INDArray rand(INDArray target, Distribution dist)
target
- target arraydist
- distribution to usepublic static INDArray rand(INDArray target, double min, double max, Random rng)
target
- target arraymin
- the minimum numbermax
- the maximum numberrng
- the random generator to usepublic static INDArray randn(INDArray target, long seed)
target
- target arraypublic static INDArray randn(INDArray target, Random rng)
target
- target arrayrng
- the random generator to usepublic static INDArray randomBernoulli(double p, long... shape)
p
- Probability. Must be in range 0 to 1shape
- Shape of the result arraypublic static INDArray randomBernoulli(double p, @NonNull INDArray target)
p
- Probability. Must be in range 0 to 1target
- Result array to place generated values inpublic static INDArray randomBinomial(int nTrials, double p, long... shape)
nTrials
- Number of trials. Must be >= 0p
- Probability. Must be in range 0 to 1shape
- Shape of the result arraypublic static INDArray randomBinomial(int nTrials, double p, INDArray target)
nTrials
- Number of trials. Must be >= 0p
- Probability. Must be in range 0 to 1target
- Result arraypublic static INDArray randomExponential(double lambda, long... shape)
lambda
- Must be > 0shape
- Shape of the array to generatepublic static INDArray randomExponential(double lambda, INDArray target)
lambda
- Must be > 0target
- Array to hold the resultpublic static INDArray createUninitialized(long rows, long columns)
rows
- columns
- public static INDArray create(float[] data)
data
- the columns of the ndarraypublic static INDArray create(List<? extends Number> list)
list
- the columns of the ndarraypublic static INDArray create(double[] data)
data
- the columns of the ndarraypublic static INDArray create(float[][] data)
data
- public static INDArray create(float[][] data, char ordering)
data
- ordering
- public static INDArray create(double[][] data)
data
- the data to usepublic static INDArray create(double[][][] data)
public static INDArray create(float[][][] data)
public static INDArray create(int[][][] data)
public static INDArray create(double[][][][] data)
public static INDArray create(float[][][][] data)
public static INDArray create(int[][][][] data)
public static INDArray create(double[][] data, char ordering)
data
- ordering
- public static INDArray create(int columns)
columns
- the columns of the ndarraypublic static INDArray create(float[] data, char order)
data
- the columns of the ndarraypublic static INDArray create(double[] data, char order)
data
- the columns of the ndarraypublic static INDArray create(int columns, char order)
columns
- the columns of the ndarraypublic static INDArray zeros(int columns, char order)
public static INDArray trueScalar(Number scalar)
scalar
- public static INDArray trueVector(float[] data)
public static INDArray trueVector(double[] data)
public static INDArray empty()
public static INDArray empty(DataBuffer.Type type)
public static INDArray create(float[] data, int[] shape)
data
- the data to use with tne ndarrayshape
- the shape of the ndarraypublic static INDArray create(float[] data, long[] shape)
public static INDArray create(double[] data, long[] shape)
public static INDArray create(double[] data, int[] shape)
data
- the data to use with tne ndarrayshape
- the shape of the ndarraypublic static INDArray create(double[] data, int[] shape, int[] stride, long offset)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(double[] data, long[] shape, long[] stride, long offset, char order)
public static INDArray create(float[] data, int rows, int columns, int[] stride, long offset)
data
- the data to use with the ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(double[] data, int rows, int columns, int[] stride, long offset)
data
- the data to use with tne ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(float[] data, int[] shape, long offset)
shape
- the shape of the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(float[] data, long[] shape, long offset)
public static INDArray create(double[] data, int[] shape, long offset, char ordering)
shape
- the shape of the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(double[] data, long[] shape, long offset, char ordering)
public static INDArray create(float[] data, int[] shape, int[] stride, long offset)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(List<INDArray> list, int[] shape)
shape
- the shape of the ndarraypublic static INDArray create(int rows, int columns, int[] stride, long offset)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray zeros(int rows, int columns, int[] stride, long offset)
public static INDArray create(int[] shape, int[] stride, long offset)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray zeros(int[] shape, int[] stride, long offset)
public static INDArray create(int rows, int columns, int[] stride)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarraypublic static INDArray zeros(int rows, int columns, int[] stride)
public static INDArray create(int[] shape, int[] stride)
shape
- the shape of the ndarraystride
- the stride for the ndarraypublic static INDArray create(long[] shape, long[] stride)
shape
- stride
- public static INDArray zeros(int[] shape, int[] stride)
shape
- stride
- public static INDArray create(int rows, int columns)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraypublic static INDArray create(int... shape)
shape
- the shape of the ndarraypublic static INDArray create(long... shape)
shape
- the shape of the ndarraypublic static INDArray create(float[] data, int[] shape, int[] stride, char ordering, long offset)
data
- shape
- stride
- ordering
- offset
- public static INDArray create(float[] data, int[] shape, char ordering, long offset)
data
- shape
- ordering
- offset
- public static INDArray create(double[] data, int[] shape, char ordering, long offset)
public static INDArray create(DataBuffer data, int[] shape, int[] strides, long offset)
data
- shape
- strides
- offset
- public static INDArray create(DataBuffer data, long[] shape, long[] strides, long offset)
public static INDArray create(DataBuffer data, int[] shape, long offset)
data
- shape
- offset
- public static INDArray create(DataBuffer data, int[] newShape, int[] newStride, long offset, char ordering)
data
- newShape
- newStride
- offset
- ordering
- public static INDArray create(DataBuffer data, long[] newShape, long[] newStride, long offset, char ordering)
public static INDArray create(DataBuffer data, int[] shape)
data
- shape
- public static INDArray create(DataBuffer data, long[] shape)
public static INDArray create(DataBuffer buffer)
buffer
- public static INDArray create(float[] data, int rows, int columns, int[] stride, long offset, char ordering)
data
- the data to use with the ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(int[] shape, DataBuffer.Type dataType)
shape
- dataType
- public static INDArray zeros(int[] shape, DataBuffer.Type dataType)
public static INDArray create(double[] data, int[] shape, int[] stride, long offset, char ordering)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(double[] data, int[] shape, char ordering)
data
- the data to use with tne ndarrayshape
- the shape of the ndarraypublic static INDArray create(float[] data, int[] shape, char ordering)
data
- the data to use with tne ndarrayshape
- the shape of the ndarraypublic static INDArray create(float[] data, long[] shape, char ordering)
public static INDArray create(double[] data, long[] shape, char ordering)
public static INDArray create(double[] data, int rows, int columns, int[] stride, long offset, char ordering)
data
- the data to use with tne ndarrayrows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(float[] data, int[] shape, int[] stride, long offset, char ordering)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(List<INDArray> list, int[] shape, char ordering)
shape
- the shape of the ndarraypublic static INDArray create(int rows, int columns, int[] stride, long offset, char ordering)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray zeros(int rows, int columns, int[] stride, long offset, char ordering)
public static INDArray create(int[] shape, int[] stride, long offset, char ordering)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray create(long[] shape, long[] stride, long offset, char ordering)
shape
- the shape of the ndarraystride
- the stride for the ndarrayoffset
- the offset of the ndarraypublic static INDArray zeros(int[] shape, int[] stride, long offset, char ordering)
public static INDArray create(int rows, int columns, int[] stride, char ordering)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraystride
- the stride for the ndarraypublic static INDArray zeros(int rows, int columns, int[] stride, char ordering)
public static INDArray create(int[] shape, int[] stride, char ordering)
shape
- the shape of the ndarraystride
- the stride for the ndarraypublic static INDArray create(long[] shape, long[] stride, char ordering)
public static INDArray zeros(int[] shape, int[] stride, char ordering)
shape
- stride
- ordering
- public static INDArray create(long rows, long columns, char ordering)
rows
- the rows of the ndarraycolumns
- the columns of the ndarraypublic static INDArray zeros(int rows, int columns, char ordering)
rows
- columns
- ordering
- public static INDArray create(@NonNull int[] shape, char ordering)
shape
- the shape of the ndarraypublic static INDArray create(@NonNull long[] shape, char ordering)
shape
- ordering
- public static void checkShapeValues(long[] shape)
shape
- public static void checkShapeValues(int[] shape)
shape
- protected static void checkShapeValues(int length, int[] shape)
protected static void checkShapeValues(int length, long[] shape)
public static INDArray createUninitialized(int[] shape, char ordering)
shape
- the shape of the ndarrayordering
- the order of the ndarraypublic static INDArray createUninitialized(long[] shape, char ordering)
public static INDArray createUninitializedDetached(int[] shape, char ordering)
shape
- ordering
- public static INDArray createUninitializedDetached(long[] shape, char ordering)
shape
- ordering
- public static INDArray createUninitialized(int[] shape)
shape
- the shape of the ndarraypublic static INDArray createUninitialized(long[] shape)
public static INDArray createUninitializedDetached(int[] shape)
shape
- public static INDArray createUninitializedDetached(long[] shape)
shape
- public static INDArray createUninitialized(int length)
length
- public static INDArray createUninitialized(long length)
public static INDArray createUninitializedDetached(int length)
length
- public static INDArray create(double[] data, int[] shape, long offset)
data
- shape
- offset
- public static INDArray createSparseCSR(double[] data, int[] columns, int[] pointerB, int[] pointerE, long[] shape)
data
- columns
- pointerB
- pointerE
- shape
- public static INDArray createSparseCSR(float[] data, int[] columns, int[] pointerB, int[] pointerE, long[] shape)
data
- columns
- pointerB
- pointerE
- shape
- public static INDArray createSparseCSR(DataBuffer data, int[] columns, int[] pointerB, int[] pointerE, long[] shape)
data
- columns
- pointerB
- pointerE
- shape
- public static INDArray createSparseCOO(double[] data, int[][] indices, long[] shape)
data
- indices
- shape
- public static INDArray createSparseCOO(float[] data, int[][] indices, long[] shape)
data
- indices
- shape
- public static INDArray createSparseCOO(double[] data, long[][] indices, long[] shape)
data
- indices
- shape
- public static INDArray createSparseCOO(float[] data, long[][] indices, long[] shape)
data
- indices
- shape
- public static INDArray createSparseCOO(DataBuffer data, DataBuffer indices, long[] shape)
data
- indices
- shape
- public static INDArray createSparseCOO(DataBuffer values, DataBuffer indices, DataBuffer sparseInformation, long[] shape)
values
- a DataBuffer with the sparse non-null valuesindices
- a DataBuffer with the indexes of the valuessparseInformation
- a DataBuffer containing the sparse information (flags, offsets and hidden dimensions)shape
- public static INDArray createSparseCOO(DataBuffer values, DataBuffer indices, long[] sparseOffsets, int[] flags, long[] shape, int[] hiddenDimensions, int underlyingRank)
values
- a DataBuffer with the sparse non-null valuesindices
- a DataBuffer with the indexes of the valuessparseOffsets
- the sparseflags
- an array that define the inactive dimensionshape
- hiddenDimensions
- an array containing the position of the hidden dimensionsunderlyingRank
- the rank of the original ndarraypublic static INDArray zeros(long rows, long columns)
rows
- the rows of the sndarraycolumns
- the columns of the ndarraypublic static INDArray zeros(int columns)
columns
- the columns of the ndarraypublic static INDArray valueArrayOf(int[] shape, double value)
shape
- the shape of the ndarrayvalue
- the value to assignpublic static INDArray valueArrayOf(long[] shape, double value)
shape
- the shape of the ndarrayvalue
- the value to assignpublic static INDArray valueArrayOf(long num, double value)
num
- number of columnsvalue
- the value to assignpublic static INDArray valueArrayOf(long rows, long columns, double value)
rows
- the number of rows in the matrixcolumns
- the columns of the ndarrayvalue
- the value to assignpublic static INDArray ones(int rows, int columns)
rows
- the number of rows in the matrixcolumns
- the columns of the ndarraypublic static INDArray zerosLike(INDArray arr)
arr
- the array to create the ones likepublic static INDArray emptyLike(INDArray arr)
arr
- the array to create the ones likepublic static INDArray onesLike(INDArray arr)
arr
- the array to create the ones likepublic static INDArray ones(int columns)
columns
- the columns of the ndarraypublic static INDArray hstack(INDArray... arrs)
arrs
- the first matrix to concatpublic static INDArray hstack(Collection<INDArray> arrs)
arrs
- the first matrix to concatpublic static INDArray vstack(INDArray... arrs)
arrs
- public static INDArray vstack(Collection<INDArray> arrs)
arrs
- public static INDArray averageAndPropagate(INDArray target, INDArray[] arrays)
arrays
- public static INDArray averageAndPropagate(INDArray[] arrays)
arrays
- public static INDArray averageAndPropagate(Collection<INDArray> arrays)
arrays
- public static INDArray averageAndPropagate(INDArray target, Collection<INDArray> arrays)
arrays
- public static INDArray stripOnes(INDArray toStrip)
toStrip
- the ndarray to newShapeNoCopypublic static INDArray accumulate(Collection<INDArray> arrays)
arrays
- public static INDArray accumulate(INDArray... arrays)
arrays
- public static INDArray accumulate(INDArray target, Collection<INDArray> arrays)
target
- arrays
- public static INDArray accumulate(INDArray target, INDArray[] arrays)
target
- arrays
- public static INDArray pullRows(INDArray source, int sourceDimension, int[] indexes)
source
- source tensorsourceDimension
- dimension of source tensorindexes
- indexes from source arraypublic static INDArray pullRows(INDArray source, int sourceDimension, int[] indexes, char order)
source
- source tensorsourceDimension
- dimension of source tensorindexes
- indexes from source arraypublic static INDArray pullRows(INDArray source, INDArray destination, int sourceDimension, int[] indexes)
source
- source tensordestination
- Destination tensor (result will be placed here)sourceDimension
- dimension of source tensorindexes
- indexes from source arraypublic static INDArray stack(int axis, INDArray... values)
axis
- Axis to stack onvalues
- Input variables to stack. Must have the same shape for all inputsconcat(int, INDArray...)
public static INDArray concat(int dimension, INDArray... toConcat)
dimension
- the dimension to concatneate alongtoConcat
- the ndarrays to concatpublic static INDArray specialConcat(int dimension, INDArray... toConcat)
dimension
- toConcat
- public static INDArray zeros(int[] shape, char order)
shape
- the shape of the ndarraypublic static INDArray zeros(long[] shape, char order)
public static INDArray zeros(int... shape)
shape
- the shape of the ndarraypublic static INDArray zeros(long... shape)
shape
- the shape of the ndarraypublic static INDArray ones(@NonNull int... shape)
shape
- the shape of the ndarraypublic static INDArray ones(@NonNull long... shape)
public static INDArray scalar(Number value, long offset)
value
- the value to initialize the scalar withoffset
- the offset of the ndarraypublic static INDArray scalar(double value, long offset)
value
- the value of the scalaroffset
- the offset of the ndarraypublic static INDArray scalar(float value, long offset)
value
- the value of the scalaroffset
- the offset of the ndarraypublic static INDArray scalar(Number value)
value
- the value to initialize the scalar withpublic static INDArray scalar(double value)
value
- the value of the scalar
= * @return the scalar nd arraypublic static INDArray scalar(float value)
value
- the value of the scalar
= * @return the scalar nd arraypublic static int[] getStrides(int[] shape, char order)
shape
- the shape of the ndarrayorder
- the order to getScalar the strides forpublic static long[] getStrides(long[] shape, char order)
public static int[] getStrides(int[] shape)
shape
- the shape of the ndarraypublic static long[] getStrides(long[] shape)
shape
- the shape of the ndarraypublic static INDArray tile(INDArray tile, int... repeat)
tile
- the ndarray to tilerepeat
- the shape to repeatpublic static int[] getComplexStrides(int[] shape, char order)
shape
- the shape of the ndarrayorder
- the order to getScalar the strides forpublic static long[] getComplexStrides(long[] shape, char order)
public static int[] getComplexStrides(int[] shape)
shape
- the shape of the ndarraypublic static long[] getComplexStrides(long[] shape)
public void initContext()
public void initWithBackend(Nd4jBackend backend)
backend
- the backend to initialize withpublic static ShapeInfoProvider getShapeInfoProvider()
public static SparseInfoProvider getSparseInfoProvider()
public static ConstantHandler getConstantHandler()
public static AffinityManager getAffinityManager()
public static NDArrayFactory getNDArrayFactory()
public static BasicNDArrayCompressor getCompressor()
public static MemoryManager getMemoryManager()
public static INDArray typeConversion(INDArray array, DataBuffer.TypeEx targetType)
public static int sizeOfDataType()
public static int sizeOfDataType(DataBuffer.Type dtype)
dtype
- number of bytes per elementpublic static void enableFallbackMode(boolean reallyEnable)
reallyEnable
- public static boolean isFallbackModeEnabled()
public static MemoryWorkspaceManager getWorkspaceManager()
public static INDArray pile(INDArray... arrays)
public static INDArray pile(@NonNull Collection<INDArray> arrays)
public static INDArray[] tear(INDArray tensor, int... dimensions)
tensor
- dimensions
- public static INDArray triu(INDArray m, int k)
m
- k
- public static INDArray tri(int n)
n
- public static INDArray tri(int n, int k)
n
- k
- public static INDArray tri(int n, int m, int k)
n
- number of rows in the arraym
- number of columns in the array ( can be just equal to n)k
- The sub-diagonal at and below which the array is filled.
`k` = 0 is the main diagonal, while `k` < 0 is below it,
and `k` > 0 is above. The default is 0.public static INDArray[] where(INDArray condition, INDArray x, INDArray y)
out[i] = (condition[i] != 0 ? x[i] : y[i])
condition
- Condition arrayx
- X array. If null, y must be null also.y
- Y array. If null, x must be null alsopublic static void writeAsNumpy(INDArray arr, File file) throws IOException
arr
- the array to writefile
- the file to writeIOException
- if an error occurs when writing the filepublic static org.bytedeco.javacpp.Pointer convertToNumpy(INDArray arr)
INDArray
to a numpy struct.arr
- the array to convertpublic static void writeAsNumpy(INDArray arr, OutputStream writeTo) throws IOException
arr
- the array to writewriteTo
- the output stream to write toIOException
public static INDArray createFromNpyPointer(org.bytedeco.javacpp.Pointer pointer)
pointer
- the pointer to the
numpy arraypublic static INDArray createFromNpyFile(File file)
file
- the file to create the ndarray frompublic static INDArray createNpyFromInputStream(InputStream is) throws IOException
is
- the input stream to readIOException
public static INDArray createNpyFromByteArray(byte[] input)
INDArray
from
the given numpy input.
The numpy input follows the format:
https://docs.scipy.org/doc/numpy-1.14.0/neps/npy-format.htmlinput
- the input byte array with the npy formatINDArray
public static byte[] toNpyByteArray(INDArray input) throws IOException
INDArray
to a byte arrayinput
- the input arrayINDArray
as a byte array
with the numpy format.
For more on the format, see: https://docs.scipy.org/doc/numpy-1.14.0/neps/npy-format.htmlIOException
public static int numThreads()
public static void setNumThreads(int numthreads)
numthreads
- public static void skipThreadSafetyChecks(boolean reallySkip)
public static boolean areThreadSafetyChecksSkipped()
Copyright © 2018. All rights reserved.