Package org.nd4j.linalg.factory.ops
Class NDBase
- java.lang.Object
-
- org.nd4j.linalg.factory.ops.NDBase
-
public class NDBase extends Object
-
-
Constructor Summary
Constructors Constructor Description NDBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description INDArray
all(INDArray x, int... dimensions)
Boolean and array reduction operation, optionally along specified dimensionsINDArray
any(INDArray x, int... dimensions)
Boolean or array reduction operation, optionally along specified dimensionsINDArray
argmax(INDArray in, boolean keepDims, int... dimensions)
Argmax array reduction operation, optionally along specified dimensions.
Output values are the index of the maximum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
argmax(INDArray in, int... dimensions)
Argmax array reduction operation, optionally along specified dimensions.
Output values are the index of the maximum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
argmin(INDArray in, boolean keepDims, int... dimensions)
Argmin array reduction operation, optionally along specified dimensions.
Output values are the index of the minimum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
argmin(INDArray in, int... dimensions)
Argmin array reduction operation, optionally along specified dimensions.
Output values are the index of the minimum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
assign(INDArray x, INDArray y)
Assign the contents of y to x.
Y must be broadcastable to x or the same shape.INDArray[]
batchMmul(INDArray[] inputsA, INDArray... inputsB)
Matrix multiply a batch of matrices.INDArray[]
batchMmul(INDArray[] inputsA, INDArray[] inputsB, boolean transposeA, boolean transposeB)
Matrix multiply a batch of matrices.INDArray
castTo(INDArray arg, DataType datatype)
Cast the array to a new datatype - for example, Integer -> FloatINDArray
clipByNorm(INDArray x, double clipValue)
Returns a clipped ndarray such that the input is normalized so that its L2 norm
is <= the specified value.INDArray
clipByNorm(INDArray x, INDArray clipValue, INDArray dimensions)
Returns a clipped ndarray such that the input is normalized so that its L2 norm
is <= the specified value.INDArray
clipByValue(INDArray x, double clipValueMin, double clipValueMax)
Return the clipped ndarray containing values no smaller or larger than the given min and max.INDArray
clipByValue(INDArray x, INDArray clipValueMin, INDArray clipValueMax)
Return the clipped ndarray containing values no smaller or larger than the given min and max.INDArray
concat(int dimension, INDArray... inputs)
Concatenate a set of inputs along the specified dimension.
Note that inputs must have identical rank and identical dimensions, other than the dimension to stack on.
For example, if 2 inputs have shape [a, x, c] and [a, y, c] and dimension = 1, then the output has shape [a, x+y, c]
Inputs must satisfy the following constraints:
Input arrays must all be the same datatype: isSameType(inputs)INDArray
create(INDArray shape, DataType dataType)
Return a newly created variable, with the specified shape and data type.INDArray
create(INDArray shape, DataType dataType, String order, boolean initialize)
Return a newly created variable, with the specified shape and data type.INDArray
createView(INDArray input, INDArray... indices)
Return a newly created variable, with the specified shape and data type.INDArray
cumprod(INDArray in, boolean exclusive, boolean reverse, int... axis)
Cumulative product operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a*b, a*b*c]
exclusive=true, reverse=false, [0, a, a*b]
exclusive=false, reverse=true: [a*b*c, b*c, c]
exclusive=true, reverse=true: [b*c, c, 0]INDArray
cumprod(INDArray in, int... axis)
Cumulative product operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a*b, a*b*c]
exclusive=true, reverse=false, [0, a, a*b]
exclusive=false, reverse=true: [a*b*c, b*c, c]
exclusive=true, reverse=true: [b*c, c, 0]INDArray
cumsum(INDArray in, boolean exclusive, boolean reverse, int... axis)
Cumulative sum operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a+b, a+b+c]
exclusive=true, reverse=false, [0, a, a+b]
exclusive=false, reverse=true: [a+b+c, b+c, c]
exclusive=true, reverse=true: [b+c, c, 0]INDArray
cumsum(INDArray in, int... axis)
Cumulative sum operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a+b, a+b+c]
exclusive=true, reverse=false, [0, a, a+b]
exclusive=false, reverse=true: [a+b+c, b+c, c]
exclusive=true, reverse=true: [b+c, c, 0]INDArray
dot(INDArray x, INDArray y, int... dimensions)
Pairwise dot product reduction along dimension
output = sum(i=0 ...INDArray[]
dynamicPartition(INDArray x, INDArray partitions, int numPartitions)
Dynamically partition the input variable values into the specified number of paritions, using the indices.
Example:INDArray
dynamicStitch(INDArray[] indices, INDArray... x)
Dynamically merge the specified input arrays into a single array, using the specified indicesINDArray
eq(INDArray x, double y)
Equals operation: elementwise x == y
Return boolean array with values true where satisfied, or false otherwise.INDArray
eq(INDArray x, INDArray y)
Equal to operation: elementwise x == y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
expandDims(INDArray x, int axis)
Reshape the input by adding a 1 at the specified location.
For example, if input has shape [a, b], then output shape is:
axis = 0: [1, a, b]
axis = 1: [a, 1, b]
axis = 2: [a, b, 1]INDArray
fill(INDArray shape, DataType dataType, double value)
Generate an output variable with the specified (dynamic) shape with all elements set to the specified valueINDArray
flatten(INDArray... inputs)
Return a flattened variable with the specified orderingINDArray
flatten(INDArray[] inputs, String order)
Return a flattened variable with the specified orderingINDArray
gather(INDArray df, int[] indices, int axis)
Gather slices from the input variable where the indices are specified as fixed int[] values.
Output shape is same as input shape, except for axis dimension, which has size equal to indices.length.INDArray
gather(INDArray df, INDArray indices, int axis)
Gather slices from the input variable where the indices are specified as dynamic array values.
Output shape is same as input shape, except for axis dimension, which has size equal to indices.length.INDArray
gatherNd(INDArray df, INDArray indices)
Gather slices from df with shape specified by indices.INDArray
gt(INDArray x, double y)
Greater than operation: elementwise x > y
Return boolean array with values true where satisfied, or false otherwise.INDArray
gt(INDArray x, INDArray y)
Greater than operation: elementwise x > y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
gte(INDArray x, double y)
Greater than or equals operation: elementwise x >= y
Return boolean array with values true where satisfied, or false otherwise.INDArray
gte(INDArray x, INDArray y)
Greater than or equal to operation: elementwise x >= y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
identity(INDArray input)
Elementwise identity operation: out = xINDArray
invertPermutation(INDArray input)
Compute the inverse permutation indices for a permutation operation
Example: if input is [2, 0, 1] then output is [1, 2, 0]
The idea is that x.permute(input).permute(invertPermutation(input)) == xINDArray
isNumericTensor(INDArray x)
Is the director a numeric tensor? In the current version of ND4J/SameDiff, this always returns true/1INDArray
linspace(DataType dataType, double start, double stop, long number)
Create a new 1d array with values evenly spaced between values 'start' and 'stop'
For example, linspace(start=3.0, stop=4.0, number=3) will generate [3.0, 3.5, 4.0]INDArray
linspace(INDArray start, INDArray stop, INDArray number, DataType dataType)
Create a new 1d array with values evenly spaced between values 'start' and 'stop'
For example, linspace(start=3.0, stop=4.0, number=3) will generate [3.0, 3.5, 4.0]INDArray
lt(INDArray x, double y)
Less than operation: elementwise x < y
Return boolean array with values true where satisfied, or false otherwise.INDArray
lt(INDArray x, INDArray y)
Less than operation: elementwise x < y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
lte(INDArray x, double y)
Less than or equals operation: elementwise x <= y
Return boolean array with values true where satisfied, or false otherwise.INDArray
lte(INDArray x, INDArray y)
Less than or equal to operation: elementwise x <= y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
matchCondition(INDArray in, Condition condition)
Returns a boolean mask of equal shape to the input, where the condition is satisfied - value 1 where satisfied, 0 otherwiseINDArray
matchConditionCount(INDArray in, Condition condition)
Returns a count of the number of elements that satisfy the conditionINDArray
matchConditionCount(INDArray in, Condition condition, boolean keepDim, int... dimensions)
Returns a count of the number of elements that satisfy the condition (for each slice along the specified dimensions)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
matchConditionCount(INDArray in, Condition condition, int... dimensions)
Returns a count of the number of elements that satisfy the condition (for each slice along the specified dimensions)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
max(INDArray x, boolean keepDims, int... dimensions)
Max array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
max(INDArray x, int... dimensions)
Max array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
max(INDArray first, INDArray second)
Element-wise maximum operation: out[i] = max(first[i], second[i])
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.htmlINDArray
mean(INDArray x, boolean keepDims, int... dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
mean(INDArray x, int... dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
mean(INDArray x, INDArray dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
mean(INDArray x, INDArray dimensions, boolean keepDims)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
merge(INDArray x, INDArray y)
The merge operation is a control operation that forwards the either of the inputs to the output, when
the first of them becomes available.INDArray
min(INDArray x, boolean keepDims, int... dimensions)
Minimum array reduction operation, optionally along specified dimensions.INDArray
min(INDArray x, int... dimensions)
Minimum array reduction operation, optionally along specified dimensions.INDArray
min(INDArray first, INDArray second)
Element-wise minimum operation: out[i] = min(first[i], second[i])
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.htmlINDArray
minMax(int datatype, int minOrMax)
Return a scalar array reflecting the min or max value for a given data type.INDArray
mmul(INDArray x, INDArray y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.INDArray
mmul(INDArray x, INDArray y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.INDArray
neq(INDArray x, double y)
Not equals operation: elementwise x != y
Return boolean array with values true where satisfied, or false otherwise.INDArray
neq(INDArray x, INDArray y)
Not equal to operation: elementwise x != y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.INDArray
norm1(INDArray x, boolean keepDims, int... dimensions)
Norm1 (L1 norm) reduction operation: The output contains the L1 norm for each tensor/subset along the specified dimensions:
out = sum_i abs(x[i])
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
norm1(INDArray x, int... dimensions)
Norm1 (L1 norm) reduction operation: The output contains the L1 norm for each tensor/subset along the specified dimensions:
out = sum_i abs(x[i])
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
norm2(INDArray x, boolean keepDims, int... dimensions)
Norm2 (L2 norm) reduction operation: The output contains the L2 norm for each tensor/subset along the specified dimensions:
out = sqrt(sum_i x[i]^2)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
norm2(INDArray x, int... dimensions)
Norm2 (L2 norm) reduction operation: The output contains the L2 norm for each tensor/subset along the specified dimensions:
out = sqrt(sum_i x[i]^2)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
normmax(INDArray x, boolean keepDims, int... dimensions)
Max norm (infinity norm) reduction operation: The output contains the max norm for each tensor/subset along the
specified dimensions:
out = max(abs(x[i]))
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
normmax(INDArray x, int... dimensions)
Max norm (infinity norm) reduction operation: The output contains the max norm for each tensor/subset along the
specified dimensions:
out = max(abs(x[i]))
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
oneHot(INDArray indices, int depth)
Convert the array to a one-hot array with values 0 and 1 for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with out[i, ..., j, in[i,...,j]] = 1 with other values being set to 0
see oneHot(SDVariable, int, int, double, double)INDArray
oneHot(INDArray indices, int depth, int axis, double on, double off)
Convert the array to a one-hot array with values and for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with {out[i, ..., j, in[i,...,j]] with other values being set toINDArray
oneHot(INDArray indices, int depth, int axis, double on, double off, DataType dataType)
Convert the array to a one-hot array with values and for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with {out[i, ..., j, in[i,...,j]] with other values being set toINDArray
onesLike(INDArray input)
Return a variable of all 1s, with the same shape as the input variable.INDArray
onesLike(INDArray input, DataType dataType)
As per onesLike(String, SDVariable) but the output datatype may be specifiedINDArray
permute(INDArray x, int... dimensions)
Array permutation operation: permute the dimensions according to the specified permutation indices.
Example: if input has shape [a,b,c] and dimensions = [2,0,1] the output has shape [c,a,b]INDArray
permute(INDArray x, INDArray dimensions)
Array permutation operation: permute the dimensions according to the specified permutation indices.
Example: if input has shape [a,b,c] and dimensions = [2,0,1] the output has shape [c,a,b]INDArray
prod(INDArray x, boolean keepDims, int... dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
prod(INDArray x, int... dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
prod(INDArray x, INDArray dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
prod(INDArray x, INDArray dimensions, boolean keepDims)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
range(double from, double to, double step, DataType dataType)
Create a new variable with a 1d array, where the values start at from and increment by step
up to (but not including) limit.
For example, range(1.0, 3.0, 0.5) will return [1.0, 1.5, 2.0, 2.5]INDArray
range(INDArray from, INDArray to, INDArray step, DataType dataType)
Create a new variable with a 1d array, where the values start at from and increment by step
up to (but not including) limit.
For example, range(1.0, 3.0, 0.5) will return [1.0, 1.5, 2.0, 2.5]INDArray
rank(INDArray in)
Returns the rank (number of dimensions, i.e., length(shape)) of the specified INDArray as a 0D scalar variableINDArray
repeat(INDArray input, INDArray repeats, int axis)
A tensor with the shape of input minus the specified axis with elements repeated along the specified axis.INDArray
replaceWhere(INDArray update, double value, Condition condition)
Element-wise replace where condition:
out[i] = value if condition(update[i]) is satisfied, or
out[i] = update[i] if condition(update[i]) is NOT satisfiedINDArray
replaceWhere(INDArray update, INDArray from, Condition condition)
Element-wise replace where condition:
out[i] = from[i] if condition(update[i]) is satisfied, or
out[i] = update[i] if condition(update[i]) is NOT satisfiedINDArray
reshape(INDArray x, long... shape)
Reshape the input variable to the specified (fixed) shape.INDArray
reshape(INDArray x, INDArray shape)
Reshape the input variable to the specified (fixed) shape.INDArray
reverse(INDArray x, int... dimensions)
Reverse the values of an array for the specified dimensions
If input is:
[ 1, 2, 3]
[ 4, 5, 6]
then
reverse(in, 0):
[3, 2, 1]
[6, 5, 4]
reverse(in, 1):
[4, 5, 6]
[1, 2 3]INDArray
reverseSequence(INDArray x, INDArray seq_lengths)
Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversedINDArray
reverseSequence(INDArray x, INDArray seq_lengths, int seqDim, int batchDim)
Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversedINDArray
scalarFloorMod(INDArray in, double value)
Element-wise scalar floor modulus operation: out = floorMod(in, value).
i.e., returns the remainder after division by 'value'INDArray
scalarMax(INDArray in, double value)
Element-wise scalar maximum operation: out = max(in, value)INDArray
scalarMin(INDArray in, double value)
Element-wise scalar minimum operation: out = min(in, value)INDArray
scalarSet(INDArray in, double set)
Return a variable with equal shape to the input, but all elements set to value 'set'INDArray
scatterAdd(INDArray ref, INDArray indices, INDArray updates)
Scatter addition operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterDiv(INDArray ref, INDArray indices, INDArray updates)
Scatter division operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterMax(INDArray ref, INDArray indices, INDArray updates)
Scatter max operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterMin(INDArray ref, INDArray indices, INDArray updates)
Scatter min operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterMul(INDArray ref, INDArray indices, INDArray updates)
Scatter multiplication operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterSub(INDArray ref, INDArray indices, INDArray updates)
Scatter subtraction operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
scatterUpdate(INDArray ref, INDArray indices, INDArray updates)
Scatter update operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.INDArray
segmentMax(INDArray data, INDArray segmentIds)
Segment max operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirementINDArray
segmentMean(INDArray data, INDArray segmentIds)
Segment mean operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirementINDArray
segmentMin(INDArray data, INDArray segmentIds)
Segment min operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirementINDArray
segmentProd(INDArray data, INDArray segmentIds)
Segment product operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirementINDArray
segmentSum(INDArray data, INDArray segmentIds)
Segment sum operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirementINDArray
sequenceMask(INDArray lengths, int maxLen, DataType dataType)
Generate a sequence mask (with values 0 or 1) based on the specified lengths
Specifically, out[i, ..., k, j] = (j < lengths[i, ..., k] ? 1.0 : 0.0)INDArray
sequenceMask(INDArray lengths, DataType dataType)
see sequenceMask(String, SDVariable, SDVariable, DataType)INDArray
sequenceMask(INDArray lengths, INDArray maxLen, DataType dataType)
Generate a sequence mask (with values 0 or 1) based on the specified lengths
Specifically, out[i, ..., k, j] = (j < lengths[i, ..., k] ? 1.0 : 0.0)INDArray[]
setShape(INDArray input, INDArray shape)
Sets an inplace shape on the passed in input.INDArray
shape(INDArray input)
Returns the shape of the specified INDArray as a 1D INDArrayINDArray
size(INDArray in)
Returns the size (number of elements, i.e., prod(shape)) of the specified INDArray as a 0D scalar variableINDArray
sizeAt(INDArray in, int dimension)
Returns a rank 0 (scalar) variable for the size of the specified dimension.
For example, if X has shape [10,20,30] then sizeAt(X,1)=20.INDArray
slice(INDArray input, int[] begin, int... size)
Get a subset of the specified input, by specifying the first element and the size of the array.
For example, if input is:
[a, b, c]
[d, e, f]
then slice(input, begin=[0,1], size=[2,1] will return:
[b]
[e]
Note that for each dimension i, begin[i] + size[i] <= input.size(i)INDArray
slice(INDArray input, INDArray begin, INDArray size)
Get a subset of the specified input, by specifying the first element and the size of the array.
For example, if input is:
[a, b, c]
[d, e, f]
then slice(input, begin=[0,1], size=[2,1] will return:
[b]
[e]
Note that for each dimension i, begin[i] + size[i] <= input.size(i)INDArray
sparseToDense(INDArray indices, INDArray shape, INDArray values)
Create a dense matrix equivalent of a sparse matrix based on the given input.INDArray
sparseToDense(INDArray indices, INDArray shape, INDArray values, INDArray defaultValue)
Create a dense matrix equivalent of a sparse matrix based on the given input.INDArray[]
split(INDArray input, int numSplit, int splitDim)
Split a value in to a list of ndarrays.INDArray[]
split(INDArray input, INDArray numSplit, int splitDim)
Split a value in to a list of ndarrays.INDArray[]
splitV(INDArray input, INDArray sizes, int numSplit, int splitDim)
Split a value in to a list of ndarrays with varying sizes
according to the sizes parameter.INDArray
squaredNorm(INDArray x, boolean keepDims, int... dimensions)
Squared L2 norm: see norm2(String, SDVariable, boolean, int...)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
squaredNorm(INDArray x, int... dimensions)
Squared L2 norm: see norm2(String, SDVariable, boolean, int...)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
squeeze(INDArray x, int axis)
Remove a single dimension of size 1.
For example, if input has shape [a,b,1,c] then squeeze(input, 2) returns an array of shape [a,b,c]INDArray
stack(int axis, INDArray... values)
Stack a set of N INDArray of rank X into one rank X+1 variable.
If inputs have shape [a,b,c] then output has shape:
axis = 0: [N,a,b,c]
axis = 1: [a,N,b,c]
axis = 2: [a,b,N,c]
axis = 3: [a,b,c,N]
see unstack(String[], SDVariable, int, int)INDArray
standardDeviation(INDArray x, boolean biasCorrected, boolean keepDims, int... dimensions)
Standard deviation array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
standardDeviation(INDArray x, boolean biasCorrected, int... dimensions)
Standard deviation array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
stridedSlice(INDArray in, long[] begin, long[] end, long... strides)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]INDArray
stridedSlice(INDArray in, long[] begin, long[] end, long[] strides, int beginMask, int endMask, int ellipsisMask, int newAxisMask, int shrinkAxisMask)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]INDArray
stridedSlice(INDArray in, INDArray begin, INDArray end, INDArray strides)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]INDArray
stridedSlice(INDArray in, INDArray begin, INDArray end, INDArray strides, int beginMask, int endMask, int ellipsisMask, int newAxisMask, int shrinkAxisMask)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]INDArray
sum(INDArray x, boolean keepDims, int... dimensions)
Sum array reduction operation, optionally along specified dimensions.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
sum(INDArray x, int... dimensions)
Sum array reduction operation, optionally along specified dimensions.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray[]
switchOp(INDArray x, INDArray predicate)
Switch operation
Predicate - if false, values are output to left (first) branch/output; if true, to right (second) branch/outputINDArray
tensorMmul(INDArray x, INDArray y, int[] dimensionsX, int... dimensionsY)
//TODO: Ops must be documented.INDArray
tensorMmul(INDArray x, INDArray y, int[] dimensionsX, int[] dimensionsY, boolean transposeX, boolean transposeY, boolean transposeZ)
//TODO: Ops must be documented.INDArray
tile(INDArray x, int... repeat)
see tile(String, SDVariable, int...)INDArray
tile(INDArray x, INDArray repeat)
Repeat (tile) the input tensor the specified number of times.
For example, if input is
[1, 2]
[3, 4]
and repeat is [2, 3]
then output is
[1, 2, 1, 2, 1, 2]
[3, 4, 3, 4, 3, 4]
[1, 2, 1, 2, 1, 2]
[3, 4, 3, 4, 3, 4]INDArray
transpose(INDArray x)
Matrix transpose operation: If input has shape [a,b] output has shape [b,a]INDArray
unsortedSegmentMax(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment max operation.INDArray
unsortedSegmentMax(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment max operation.INDArray
unsortedSegmentMean(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment mean operation.INDArray
unsortedSegmentMean(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment mean operation.INDArray
unsortedSegmentMin(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment min operation.INDArray
unsortedSegmentMin(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment min operation.INDArray
unsortedSegmentProd(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment product operation.INDArray
unsortedSegmentProd(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment product operation.INDArray
unsortedSegmentSqrtN(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment sqrtN operation.INDArray
unsortedSegmentSqrtN(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment sqrtN operation.INDArray
unsortedSegmentSum(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment sum operation.INDArray
unsortedSegmentSum(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment sum operation.INDArray[]
unstack(INDArray value, int axis, int num)
Unstack a variable of rank X into N rank X-1 variables by taking slices along the specified axis.
If input has shape [a,b,c] then output has shape:
axis = 0: [b,c]
axis = 1: [a,c]
axis = 2: [a,b]INDArray
variance(INDArray x, boolean biasCorrected, boolean keepDims, int... dimensions)
Variance array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
variance(INDArray x, boolean biasCorrected, int... dimensions)
Variance array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
where(INDArray condition)
Returns elements that are true from the given condition array
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
where(INDArray x, INDArray condition)
Similar to numpy where, takes elements from x or y depending on whether the condition at a given element is true or false
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
where(INDArray x, INDArray y, INDArray condition)
Similar to numpy where, takes elements from x or y depending on whether the condition at a given element is true or false
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
whereNumpy(INDArray x, INDArray y, INDArray condition)
As implemented in numpy, Return elements chosen from x or y depending on condition.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1.INDArray
zerosLike(INDArray input)
Return a variable of all 0s, with the same shape as the input variable.
-
-
-
Method Detail
-
all
public INDArray all(INDArray x, int... dimensions)
Boolean and array reduction operation, optionally along specified dimensions- Parameters:
x
- Input variable (NDARRAY type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (BOOL type)
-
any
public INDArray any(INDArray x, int... dimensions)
Boolean or array reduction operation, optionally along specified dimensions- Parameters:
x
- Input variable (NDARRAY type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (BOOL type)
-
argmax
public INDArray argmax(INDArray in, boolean keepDims, int... dimensions)
Argmax array reduction operation, optionally along specified dimensions.
Output values are the index of the maximum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
in
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
argmax
public INDArray argmax(INDArray in, int... dimensions)
Argmax array reduction operation, optionally along specified dimensions.
Output values are the index of the maximum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
in
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
argmin
public INDArray argmin(INDArray in, boolean keepDims, int... dimensions)
Argmin array reduction operation, optionally along specified dimensions.
Output values are the index of the minimum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html- Parameters:
in
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
argmin
public INDArray argmin(INDArray in, int... dimensions)
Argmin array reduction operation, optionally along specified dimensions.
Output values are the index of the minimum value of each slice along the specified dimension.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html- Parameters:
in
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
assign
public INDArray assign(INDArray x, INDArray y)
Assign the contents of y to x.
Y must be broadcastable to x or the same shape.- Parameters:
x
- The variable to assign to (NDARRAY type)y
- The variable to assign (NDARRAY type)- Returns:
- output The newly assigned output (NUMERIC type)
-
batchMmul
public INDArray[] batchMmul(INDArray[] inputsA, INDArray[] inputsB, boolean transposeA, boolean transposeB)
Matrix multiply a batch of matrices. matricesA and matricesB have to be arrays of same
length and each pair taken from these sets has to have dimensions (M, N) and (N, K),
respectively. If transposeA is true, matrices from matricesA will have shape (N, M) instead.
Likewise, if transposeB is true, matrices from matricesB will have shape (K, N).
The result of this operation will be a batch of multiplied matrices. The
result has the same length as both input batches and each output matrix is of shape (M, K).- Parameters:
inputsA
- First array of input matrices, all of shape (M, N) or (N, M) (NUMERIC type)inputsB
- Second array of input matrices, all of shape (N, K) or (K, N) (NUMERIC type)transposeA
- Whether to transpose A arrays or nottransposeB
- Whether to transpose B arrays or not
-
batchMmul
public INDArray[] batchMmul(INDArray[] inputsA, INDArray... inputsB)
Matrix multiply a batch of matrices. matricesA and matricesB have to be arrays of same
length and each pair taken from these sets has to have dimensions (M, N) and (N, K),
respectively. If transposeA is true, matrices from matricesA will have shape (N, M) instead.
Likewise, if transposeB is true, matrices from matricesB will have shape (K, N).
The result of this operation will be a batch of multiplied matrices. The
result has the same length as both input batches and each output matrix is of shape (M, K).- Parameters:
inputsA
- First array of input matrices, all of shape (M, N) or (N, M) (NUMERIC type)inputsB
- Second array of input matrices, all of shape (N, K) or (K, N) (NUMERIC type)
-
castTo
public INDArray castTo(INDArray arg, DataType datatype)
Cast the array to a new datatype - for example, Integer -> Float- Parameters:
arg
- Input variable to cast (NDARRAY type)datatype
- Datatype to cast to- Returns:
- output Output array (after casting) (NDARRAY type)
-
clipByNorm
public INDArray clipByNorm(INDArray x, double clipValue)
Returns a clipped ndarray such that the input is normalized so that its L2 norm
is <= the specified value.- Parameters:
x
- Input variable to clip (NUMERIC type)clipValue
- The value max for clipping- Returns:
- output The clipped value (NUMERIC type)
-
clipByNorm
public INDArray clipByNorm(INDArray x, INDArray clipValue, INDArray dimensions)
Returns a clipped ndarray such that the input is normalized so that its L2 norm
is <= the specified value.- Parameters:
x
- Input variable to clip (NUMERIC type)clipValue
- The value max value for clipping (NUMERIC type)dimensions
- The dimensions to clip (NUMERIC type)- Returns:
- output The clipped value (NUMERIC type)
-
clipByValue
public INDArray clipByValue(INDArray x, double clipValueMin, double clipValueMax)
Return the clipped ndarray containing values no smaller or larger than the given min and max.- Parameters:
x
- Input variable to cip (NUMERIC type)clipValueMin
- The value min for clippingclipValueMax
- The max value to clip to- Returns:
- output The clipped value (NUMERIC type)
-
clipByValue
public INDArray clipByValue(INDArray x, INDArray clipValueMin, INDArray clipValueMax)
Return the clipped ndarray containing values no smaller or larger than the given min and max.- Parameters:
x
- Input variable to cip (NUMERIC type)clipValueMin
- The value min for clipping (NUMERIC type)clipValueMax
- The max value to clip to (NUMERIC type)- Returns:
- output The clipped value (NUMERIC type)
-
concat
public INDArray concat(int dimension, INDArray... inputs)
Concatenate a set of inputs along the specified dimension.
Note that inputs must have identical rank and identical dimensions, other than the dimension to stack on.
For example, if 2 inputs have shape [a, x, c] and [a, y, c] and dimension = 1, then the output has shape [a, x+y, c]
Inputs must satisfy the following constraints:
Input arrays must all be the same datatype: isSameType(inputs)- Parameters:
inputs
- Input variables (NUMERIC type)dimension
- Dimension to concatenate on- Returns:
- output (NUMERIC type)
-
create
public INDArray create(INDArray shape, DataType dataType, String order, boolean initialize)
Return a newly created variable, with the specified shape and data type.- Parameters:
shape
- Input INDArray (NUMERIC type)dataType
- Data type of arrayorder
- Order of arrayinitialize
- Whether to initialize the array or not- Returns:
- output A new INDArray with the same (dynamic) shape as the input (NUMERIC type)
-
create
public INDArray create(INDArray shape, DataType dataType)
Return a newly created variable, with the specified shape and data type.- Parameters:
shape
- Input INDArray (NUMERIC type)dataType
- Data type of array- Returns:
- output A new INDArray with the same (dynamic) shape as the input (NUMERIC type)
-
createView
public INDArray createView(INDArray input, INDArray... indices)
Return a newly created variable, with the specified shape and data type.- Parameters:
input
- Input INDArray (NDARRAY type)indices
- (NDARRAY type)- Returns:
- output A new INDArray with the same (dynamic) shape as the input (NUMERIC type)
-
cumprod
public INDArray cumprod(INDArray in, boolean exclusive, boolean reverse, int... axis)
Cumulative product operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a*b, a*b*c]
exclusive=true, reverse=false, [0, a, a*b]
exclusive=false, reverse=true: [a*b*c, b*c, c]
exclusive=true, reverse=true: [b*c, c, 0]- Parameters:
in
- Input variable (NUMERIC type)exclusive
- If true: exclude the first valuereverse
- If true: reverse the direction of the accumulationaxis
- Scalar axis argument for dimension to perform cumululative sum operations along (Size: AtLeast(min=1))- Returns:
- output Output variable (NUMERIC type)
-
cumprod
public INDArray cumprod(INDArray in, int... axis)
Cumulative product operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a*b, a*b*c]
exclusive=true, reverse=false, [0, a, a*b]
exclusive=false, reverse=true: [a*b*c, b*c, c]
exclusive=true, reverse=true: [b*c, c, 0]- Parameters:
in
- Input variable (NUMERIC type)axis
- Scalar axis argument for dimension to perform cumululative sum operations along (Size: AtLeast(min=1))- Returns:
- output Output variable (NUMERIC type)
-
cumsum
public INDArray cumsum(INDArray in, boolean exclusive, boolean reverse, int... axis)
Cumulative sum operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a+b, a+b+c]
exclusive=true, reverse=false, [0, a, a+b]
exclusive=false, reverse=true: [a+b+c, b+c, c]
exclusive=true, reverse=true: [b+c, c, 0]- Parameters:
in
- Input variable (NUMERIC type)exclusive
- If true: exclude the first valuereverse
- If true: reverse the direction of the accumulationaxis
- Scalar axis argument for dimension to perform cumululative sum operations along (Size: AtLeast(min=1))- Returns:
- output (NUMERIC type)
-
cumsum
public INDArray cumsum(INDArray in, int... axis)
Cumulative sum operation.
For input: [ a, b, c], output is:
exclusive=false, reverse=false: [a, a+b, a+b+c]
exclusive=true, reverse=false, [0, a, a+b]
exclusive=false, reverse=true: [a+b+c, b+c, c]
exclusive=true, reverse=true: [b+c, c, 0]- Parameters:
in
- Input variable (NUMERIC type)axis
- Scalar axis argument for dimension to perform cumululative sum operations along (Size: AtLeast(min=1))- Returns:
- output (NUMERIC type)
-
dot
public INDArray dot(INDArray x, INDArray y, int... dimensions)
Pairwise dot product reduction along dimension
output = sum(i=0 ... size(dim)-1) x[i] * y[i]- Parameters:
x
- first input (NUMERIC type)y
- second input (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output output variable (NUMERIC type)
-
dynamicPartition
public INDArray[] dynamicPartition(INDArray x, INDArray partitions, int numPartitions)
Dynamically partition the input variable values into the specified number of paritions, using the indices.
Example:
input = [1,2,3,4,5]
numPartitions = 2
partitions = [1,0,0,1,0]
out[0] = [2,3,5]
out[1] = [1,4] }
- Parameters:
x
- Input variable (NUMERIC type)partitions
- 1D input with values 0 to numPartitions-1 (INT type)numPartitions
- Number of partitions, >= 1
-
dynamicStitch
public INDArray dynamicStitch(INDArray[] indices, INDArray... x)
Dynamically merge the specified input arrays into a single array, using the specified indices- Parameters:
indices
- Indices to use when merging. Must be >= 1, same length as input variables (INT type)x
- Input variables. (NUMERIC type)- Returns:
- output Merged output variable (NUMERIC type)
-
eq
public INDArray eq(INDArray x, double y)
Equals operation: elementwise x == y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NUMERIC type)y
- Double value argument to use in operation- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
eq
public INDArray eq(INDArray x, INDArray y)
Equal to operation: elementwise x == y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NDARRAY type)y
- Input 2 (NDARRAY type)- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
expandDims
public INDArray expandDims(INDArray x, int axis)
Reshape the input by adding a 1 at the specified location.
For example, if input has shape [a, b], then output shape is:
axis = 0: [1, a, b]
axis = 1: [a, 1, b]
axis = 2: [a, b, 1]- Parameters:
x
- Input variable (NDARRAY type)axis
- Axis to expand- Returns:
- output Output variable (NUMERIC type)
-
fill
public INDArray fill(INDArray shape, DataType dataType, double value)
Generate an output variable with the specified (dynamic) shape with all elements set to the specified value- Parameters:
shape
- Shape: must be a 1D array/variable (INT type)dataType
- Datatype of the output arrayvalue
- Value to set all elements to- Returns:
- output Output variable (NUMERIC type)
-
flatten
public INDArray flatten(INDArray[] inputs, String order)
Return a flattened variable with the specified ordering- Parameters:
inputs
- Input variables (NDARRAY type)order
- ordering for the variable- Returns:
- output Output variable (NUMERIC type)
-
flatten
public INDArray flatten(INDArray... inputs)
Return a flattened variable with the specified ordering- Parameters:
inputs
- Input variables (NDARRAY type)- Returns:
- output Output variable (NUMERIC type)
-
gather
public INDArray gather(INDArray df, int[] indices, int axis)
Gather slices from the input variable where the indices are specified as fixed int[] values.
Output shape is same as input shape, except for axis dimension, which has size equal to indices.length.- Parameters:
df
- Input variable (NDARRAY type)indices
- Indices to get (Size: AtLeast(min=1))axis
- Axis that the indices refer to- Returns:
- output Output variable with slices pulled from the specified axis (NDARRAY type)
-
gather
public INDArray gather(INDArray df, INDArray indices, int axis)
Gather slices from the input variable where the indices are specified as dynamic array values.
Output shape is same as input shape, except for axis dimension, which has size equal to indices.length.- Parameters:
df
- Input variable (NDARRAY type)indices
- Indices to get slices for. Rank 0 or 1 input (INT type)axis
- Axis that the indices refer to- Returns:
- output Output variable with slices pulled from the specified axis (NDARRAY type)
-
gatherNd
public INDArray gatherNd(INDArray df, INDArray indices)
Gather slices from df with shape specified by indices.- Parameters:
df
- (NDARRAY type)indices
- (NUMERIC type)- Returns:
- output (NDARRAY type)
-
gt
public INDArray gt(INDArray x, double y)
Greater than operation: elementwise x > y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NDARRAY type)y
- Double value argument to use in operation- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
gt
public INDArray gt(INDArray x, INDArray y)
Greater than operation: elementwise x > y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NDARRAY type)y
- Input 2 (NDARRAY type)- Returns:
- output Output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
gte
public INDArray gte(INDArray x, double y)
Greater than or equals operation: elementwise x >= y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NDARRAY type)y
- Double value argument to use in operation- Returns:
- output Output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
gte
public INDArray gte(INDArray x, INDArray y)
Greater than or equal to operation: elementwise x >= y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NDARRAY type)y
- Input 2 (NDARRAY type)- Returns:
- output (NDARRAY type)
-
identity
public INDArray identity(INDArray input)
Elementwise identity operation: out = x- Parameters:
input
- Input variable (NDARRAY type)- Returns:
- output Output variable (NDARRAY type)
-
invertPermutation
public INDArray invertPermutation(INDArray input)
Compute the inverse permutation indices for a permutation operation
Example: if input is [2, 0, 1] then output is [1, 2, 0]
The idea is that x.permute(input).permute(invertPermutation(input)) == x- Parameters:
input
- 1D indices for permutation (INT type)- Returns:
- output 1D inverted permutation (INT type)
-
isNumericTensor
public INDArray isNumericTensor(INDArray x)
Is the director a numeric tensor? In the current version of ND4J/SameDiff, this always returns true/1- Parameters:
x
- Input variable (NUMERIC type)- Returns:
- output scalar boolean with value true or false (NDARRAY type)
-
linspace
public INDArray linspace(DataType dataType, double start, double stop, long number)
Create a new 1d array with values evenly spaced between values 'start' and 'stop'
For example, linspace(start=3.0, stop=4.0, number=3) will generate [3.0, 3.5, 4.0]- Parameters:
dataType
- Data type of the output arraystart
- Start valuestop
- Stop valuenumber
- Number of values to generate- Returns:
- output INDArray with linearly spaced elements (NUMERIC type)
-
linspace
public INDArray linspace(INDArray start, INDArray stop, INDArray number, DataType dataType)
Create a new 1d array with values evenly spaced between values 'start' and 'stop'
For example, linspace(start=3.0, stop=4.0, number=3) will generate [3.0, 3.5, 4.0]- Parameters:
start
- Start value (NUMERIC type)stop
- Stop value (NUMERIC type)number
- Number of values to generate (LONG type)dataType
- Data type of the output array- Returns:
- output INDArray with linearly spaced elements (NUMERIC type)
-
lt
public INDArray lt(INDArray x, double y)
Less than operation: elementwise x < y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NDARRAY type)y
- Double value argument to use in operation- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
lt
public INDArray lt(INDArray x, INDArray y)
Less than operation: elementwise x < y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NDARRAY type)y
- Input 2 (NDARRAY type)- Returns:
- output Output Boolean array out, with values true/false based on where the condition is satisfied (NDARRAY type)
-
lte
public INDArray lte(INDArray x, double y)
Less than or equals operation: elementwise x <= y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NDARRAY type)y
- Double value argument to use in operation- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
lte
public INDArray lte(INDArray x, INDArray y)
Less than or equal to operation: elementwise x <= y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NUMERIC type)y
- Input 2 (NUMERIC type)- Returns:
- output Output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
matchCondition
public INDArray matchCondition(INDArray in, Condition condition)
Returns a boolean mask of equal shape to the input, where the condition is satisfied - value 1 where satisfied, 0 otherwise- Parameters:
in
- Input (NUMERIC type)condition
- Condition- Returns:
- output Boolean mask (NUMERIC type)
-
matchConditionCount
public INDArray matchConditionCount(INDArray in, Condition condition)
Returns a count of the number of elements that satisfy the condition- Parameters:
in
- Input (NUMERIC type)condition
- Condition- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
matchConditionCount
public INDArray matchConditionCount(INDArray in, Condition condition, boolean keepDim, int... dimensions)
Returns a count of the number of elements that satisfy the condition (for each slice along the specified dimensions)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
in
- Input variable (NUMERIC type)condition
- ConditionkeepDim
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
matchConditionCount
public INDArray matchConditionCount(INDArray in, Condition condition, int... dimensions)
Returns a count of the number of elements that satisfy the condition (for each slice along the specified dimensions)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
in
- Input variable (NUMERIC type)condition
- Conditiondimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
max
public INDArray max(INDArray x, boolean keepDims, int... dimensions)
Max array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
max
public INDArray max(INDArray x, int... dimensions)
Max array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
max
public INDArray max(INDArray first, INDArray second)
Element-wise maximum operation: out[i] = max(first[i], second[i])
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html- Parameters:
first
- First input array (NUMERIC type)second
- Second input array (NUMERIC type)- Returns:
- output Output variable (NUMERIC type)
-
mean
public INDArray mean(INDArray x, boolean keepDims, int... dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
mean
public INDArray mean(INDArray x, int... dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
mean
public INDArray mean(INDArray x, INDArray dimensions, boolean keepDims)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (INT type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensions- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
mean
public INDArray mean(INDArray x, INDArray dimensions)
Mean (average) array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (INT type)- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
merge
public INDArray merge(INDArray x, INDArray y)
The merge operation is a control operation that forwards the either of the inputs to the output, when
the first of them becomes available. If both are available, the output is undefined (either input could
be forwarded to the output)- Parameters:
x
- Input variable (NDARRAY type)y
- Input variable (NDARRAY type)- Returns:
- output Output (NDARRAY type)
-
min
public INDArray min(INDArray x, boolean keepDims, int... dimensions)
Minimum array reduction operation, optionally along specified dimensions. out = min(in)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
min
public INDArray min(INDArray x, int... dimensions)
Minimum array reduction operation, optionally along specified dimensions. out = min(in)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output Reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
min
public INDArray min(INDArray first, INDArray second)
Element-wise minimum operation: out[i] = min(first[i], second[i])
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html- Parameters:
first
- First input array (NUMERIC type)second
- Second input array (NUMERIC type)- Returns:
- output Second input array (NUMERIC type)
-
minMax
public INDArray minMax(int datatype, int minOrMax)
Return a scalar array reflecting the min or max value for a given data type.- Parameters:
datatype
- The input target data type represented as an intminOrMax
- The min or max (0 or 1) value to return- Returns:
- output Output array (after casting) (NDARRAY type)
-
mmul
public INDArray mmul(INDArray x, INDArray y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
x
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)transposeX
- Transpose x (first argument)transposeY
- Transpose y (second argument)transposeZ
- Transpose result array- Returns:
- output (NUMERIC type)
-
mmul
public INDArray mmul(INDArray x, INDArray y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
x
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)- Returns:
- output (NUMERIC type)
-
neq
public INDArray neq(INDArray x, double y)
Not equals operation: elementwise x != y
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input array (NDARRAY type)y
- Double value argument to use in operation- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NUMERIC type)
-
neq
public INDArray neq(INDArray x, INDArray y)
Not equal to operation: elementwise x != y
If x and y arrays have equal shape, the output shape is the same as these inputs.
Note: supports broadcasting if x and y have different shapes and are broadcastable.
For example, if X has shape [1,10] and Y has shape [5,10] then op(X,Y) has output shape [5,10]
Broadcast rules are the same as NumPy: https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
Return boolean array with values true where satisfied, or false otherwise.- Parameters:
x
- Input 1 (NDARRAY type)y
- Input 2 (NDARRAY type)- Returns:
- output Boolean array out, with values true/false based on where the condition is satisfied (NDARRAY type)
-
norm1
public INDArray norm1(INDArray x, boolean keepDims, int... dimensions)
Norm1 (L1 norm) reduction operation: The output contains the L1 norm for each tensor/subset along the specified dimensions:
out = sum_i abs(x[i])
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
norm1
public INDArray norm1(INDArray x, int... dimensions)
Norm1 (L1 norm) reduction operation: The output contains the L1 norm for each tensor/subset along the specified dimensions:
out = sum_i abs(x[i])
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
norm2
public INDArray norm2(INDArray x, boolean keepDims, int... dimensions)
Norm2 (L2 norm) reduction operation: The output contains the L2 norm for each tensor/subset along the specified dimensions:
out = sqrt(sum_i x[i]^2)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- dimensions dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
norm2
public INDArray norm2(INDArray x, int... dimensions)
Norm2 (L2 norm) reduction operation: The output contains the L2 norm for each tensor/subset along the specified dimensions:
out = sqrt(sum_i x[i]^2)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- dimensions dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
normmax
public INDArray normmax(INDArray x, boolean keepDims, int... dimensions)
Max norm (infinity norm) reduction operation: The output contains the max norm for each tensor/subset along the
specified dimensions:
out = max(abs(x[i]))
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
normmax
public INDArray normmax(INDArray x, int... dimensions)
Max norm (infinity norm) reduction operation: The output contains the max norm for each tensor/subset along the
specified dimensions:
out = max(abs(x[i]))
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- dimensions to reduce over (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
oneHot
public INDArray oneHot(INDArray indices, int depth, int axis, double on, double off, DataType dataType)
Convert the array to a one-hot array with values and for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with {out[i, ..., j, in[i,...,j]] with other values being set to- Parameters:
indices
- Indices - value 0 to depth-1 (NUMERIC type)depth
- Number of classesaxis
-on
-off
-dataType
- Output data type- Returns:
- output Output variable (NUMERIC type)
-
oneHot
public INDArray oneHot(INDArray indices, int depth, int axis, double on, double off)
Convert the array to a one-hot array with values and for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with {out[i, ..., j, in[i,...,j]] with other values being set to- Parameters:
indices
- Indices - value 0 to depth-1 (NUMERIC type)depth
- Number of classesaxis
-on
-off
-- Returns:
- output Output variable (NUMERIC type)
-
oneHot
public INDArray oneHot(INDArray indices, int depth)
Convert the array to a one-hot array with values 0 and 1 for each entry
If input has shape [ a, ..., n] then output has shape [ a, ..., n, depth],
with out[i, ..., j, in[i,...,j]] = 1 with other values being set to 0
see oneHot(SDVariable, int, int, double, double)- Parameters:
indices
- Indices - value 0 to depth-1 (NUMERIC type)depth
- Number of classes- Returns:
- output Output variable (NUMERIC type)
-
onesLike
public INDArray onesLike(INDArray input)
Return a variable of all 1s, with the same shape as the input variable. Note that this is dynamic:
if the input shape changes in later execution, the returned variable's shape will also be updated- Parameters:
input
- Input INDArray (NDARRAY type)- Returns:
- output A new INDArray with the same (dynamic) shape as the input (NUMERIC type)
-
onesLike
public INDArray onesLike(INDArray input, DataType dataType)
As per onesLike(String, SDVariable) but the output datatype may be specified- Parameters:
input
- (NDARRAY type)dataType
-- Returns:
- output (NUMERIC type)
-
permute
public INDArray permute(INDArray x, INDArray dimensions)
Array permutation operation: permute the dimensions according to the specified permutation indices.
Example: if input has shape [a,b,c] and dimensions = [2,0,1] the output has shape [c,a,b]- Parameters:
x
- Input variable (NDARRAY type)dimensions
- Permute dimensions (INT type)- Returns:
- output Output variable (permuted input) (NUMERIC type)
-
permute
public INDArray permute(INDArray x, int... dimensions)
Array permutation operation: permute the dimensions according to the specified permutation indices.
Example: if input has shape [a,b,c] and dimensions = [2,0,1] the output has shape [c,a,b]- Parameters:
x
- Input variable (NDARRAY type)dimensions
- (Size: AtLeast(min=0))- Returns:
- output Output variable (permuted input) (NUMERIC type)
-
prod
public INDArray prod(INDArray x, boolean keepDims, int... dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output (NUMERIC type)
-
prod
public INDArray prod(INDArray x, int... dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output (NUMERIC type)
-
prod
public INDArray prod(INDArray x, INDArray dimensions, boolean keepDims)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (INT type)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensions- Returns:
- output (NUMERIC type)
-
prod
public INDArray prod(INDArray x, INDArray dimensions)
Product array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (INT type)- Returns:
- output (NUMERIC type)
-
range
public INDArray range(double from, double to, double step, DataType dataType)
Create a new variable with a 1d array, where the values start at from and increment by step
up to (but not including) limit.
For example, range(1.0, 3.0, 0.5) will return [1.0, 1.5, 2.0, 2.5]- Parameters:
from
- Initial/smallest valueto
- Largest value (exclusive)step
- Step sizedataType
-- Returns:
- output INDArray with the specified values (NUMERIC type)
-
range
public INDArray range(INDArray from, INDArray to, INDArray step, DataType dataType)
Create a new variable with a 1d array, where the values start at from and increment by step
up to (but not including) limit.
For example, range(1.0, 3.0, 0.5) will return [1.0, 1.5, 2.0, 2.5]- Parameters:
from
- Initial/smallest value (NUMERIC type)to
- Largest value (exclusive) (NUMERIC type)step
- Step size (NUMERIC type)dataType
-- Returns:
- output INDArray with the specified values (NUMERIC type)
-
rank
public INDArray rank(INDArray in)
Returns the rank (number of dimensions, i.e., length(shape)) of the specified INDArray as a 0D scalar variable- Parameters:
in
- Input variable (NDARRAY type)- Returns:
- output (scalar) output variable with value equal to the rank of the input variable (NUMERIC type)
-
repeat
public INDArray repeat(INDArray input, INDArray repeats, int axis)
A tensor with the shape of input minus the specified axis with elements repeated along the specified axis.- Parameters:
input
- Input value to repeat (NUMERIC type)repeats
- A 1d input representing the number of inputs of repeats for each element. (NUMERIC type)axis
- Data type of the output array- Returns:
- output A tensor with the shape of input minus the specified axis (NUMERIC type)
-
replaceWhere
public INDArray replaceWhere(INDArray update, INDArray from, Condition condition)
Element-wise replace where condition:
out[i] = from[i] if condition(update[i]) is satisfied, or
out[i] = update[i] if condition(update[i]) is NOT satisfied- Parameters:
update
- Source array (NUMERIC type)from
- Replacement values array (used conditionally). Must be same shape as 'update' array (NUMERIC type)condition
- Condition to check on update array elements- Returns:
- output New array with values replaced where condition is satisfied (NUMERIC type)
-
replaceWhere
public INDArray replaceWhere(INDArray update, double value, Condition condition)
Element-wise replace where condition:
out[i] = value if condition(update[i]) is satisfied, or
out[i] = update[i] if condition(update[i]) is NOT satisfied- Parameters:
update
- Source array (NUMERIC type)value
- Value to set at the output, if the condition is satisfiedcondition
- Condition to check on update array elements- Returns:
- output New array with values replaced where condition is satisfied (NUMERIC type)
-
reshape
public INDArray reshape(INDArray x, INDArray shape)
Reshape the input variable to the specified (fixed) shape. The output variable will have the same values as the
input, but with the specified shape.
Note that prod(shape) must match length(input) == prod(input.shape)- Parameters:
x
- Input variable (NDARRAY type)shape
- New shape for variable (NUMERIC type)- Returns:
- output Output variable (NUMERIC type)
-
reshape
public INDArray reshape(INDArray x, long... shape)
Reshape the input variable to the specified (fixed) shape. The output variable will have the same values as the
input, but with the specified shape.
Note that prod(shape) must match length(input) == prod(input.shape)- Parameters:
x
- Input variable (NDARRAY type)shape
- New shape for variable (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
reverse
public INDArray reverse(INDArray x, int... dimensions)
Reverse the values of an array for the specified dimensions
If input is:
[ 1, 2, 3]
[ 4, 5, 6]
then
reverse(in, 0):
[3, 2, 1]
[6, 5, 4]
reverse(in, 1):
[4, 5, 6]
[1, 2 3]- Parameters:
x
- Input variable (NDARRAY type)dimensions
- Input variable (Size: AtLeast(min=0))- Returns:
- output Output variable (NUMERIC type)
-
reverseSequence
public INDArray reverseSequence(INDArray x, INDArray seq_lengths, int seqDim, int batchDim)
Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversed- Parameters:
x
- Input variable (NDARRAY type)seq_lengths
- Length of the sequences (INT type)seqDim
- Sequence dimensionbatchDim
- Batch dimension- Returns:
- output Reversed sequences (NUMERIC type)
-
reverseSequence
public INDArray reverseSequence(INDArray x, INDArray seq_lengths)
Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversed- Parameters:
x
- Input variable (NDARRAY type)seq_lengths
- Length of the sequences (INT type)- Returns:
- output Reversed sequences (NUMERIC type)
-
scalarFloorMod
public INDArray scalarFloorMod(INDArray in, double value)
Element-wise scalar floor modulus operation: out = floorMod(in, value).
i.e., returns the remainder after division by 'value'- Parameters:
in
- Input variable (NUMERIC type)value
- Scalar value to compare- Returns:
- output Output variable (NUMERIC type)
-
scalarMax
public INDArray scalarMax(INDArray in, double value)
Element-wise scalar maximum operation: out = max(in, value)- Parameters:
in
- Input variable (NUMERIC type)value
- Scalar value to compare- Returns:
- output Scalar value to compare (NUMERIC type)
-
scalarMin
public INDArray scalarMin(INDArray in, double value)
Element-wise scalar minimum operation: out = min(in, value)- Parameters:
in
- Input variable (NUMERIC type)value
- Scalar value to compare- Returns:
- output Output variable (NUMERIC type)
-
scalarSet
public INDArray scalarSet(INDArray in, double set)
Return a variable with equal shape to the input, but all elements set to value 'set'- Parameters:
in
- Input variable (NUMERIC type)set
- Value to set- Returns:
- output Output variable (NUMERIC type)
-
scatterAdd
public INDArray scatterAdd(INDArray ref, INDArray indices, INDArray updates)
Scatter addition operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterDiv
public INDArray scatterDiv(INDArray ref, INDArray indices, INDArray updates)
Scatter division operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterMax
public INDArray scatterMax(INDArray ref, INDArray indices, INDArray updates)
Scatter max operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterMin
public INDArray scatterMin(INDArray ref, INDArray indices, INDArray updates)
Scatter min operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterMul
public INDArray scatterMul(INDArray ref, INDArray indices, INDArray updates)
Scatter multiplication operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterSub
public INDArray scatterSub(INDArray ref, INDArray indices, INDArray updates)
Scatter subtraction operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
scatterUpdate
public INDArray scatterUpdate(INDArray ref, INDArray indices, INDArray updates)
Scatter update operation.
If indices is rank 0 (a scalar), then out[index, ...] = out[index, ...] + op(updates[...])
If indices is rank 1 (a vector), then for each position i, out[indices[i], ...] = out[indices[i], ...] + op(updates[i, ...])
If indices is rank 2+, then for each position (i,...,k), out[indices[i], ..., indices[k], ...] = out[indices[i], ..., indices[k], ...] + op(updates[i, ..., k, ...])
Note that if multiple indices refer to the same location, the contributions from each is handled correctly.- Parameters:
ref
- Initial/source variable (NUMERIC type)indices
- Indices array (NUMERIC type)updates
- Updates to add to the initial/source array (NUMERIC type)- Returns:
- output The updated variable (NUMERIC type)
-
segmentMax
public INDArray segmentMax(INDArray data, INDArray segmentIds)
Segment max operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirement- Parameters:
data
- Data to perform segment max on (NDARRAY type)segmentIds
- Variable for the segment IDs (NUMERIC type)- Returns:
- output Segment output (NUMERIC type)
-
segmentMean
public INDArray segmentMean(INDArray data, INDArray segmentIds)
Segment mean operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirement- Parameters:
data
- Data to perform segment max on (NDARRAY type)segmentIds
- Variable for the segment IDs (NUMERIC type)- Returns:
- output Segment output (NUMERIC type)
-
segmentMin
public INDArray segmentMin(INDArray data, INDArray segmentIds)
Segment min operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirement- Parameters:
data
- Data to perform segment max on (NDARRAY type)segmentIds
- Variable for the segment IDs (NUMERIC type)- Returns:
- output Segment output (NUMERIC type)
-
segmentProd
public INDArray segmentProd(INDArray data, INDArray segmentIds)
Segment product operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirement- Parameters:
data
- Data to perform segment max on (NDARRAY type)segmentIds
- Variable for the segment IDs (NUMERIC type)- Returns:
- output Segment output (NUMERIC type)
-
segmentSum
public INDArray segmentSum(INDArray data, INDArray segmentIds)
Segment sum operation.
If data = [3, 6, 1, 4, 9, 2, 8]
segmentIds = [0, 0, 1, 1, 1, 2, 2]
then output = [6, 9, 8] = [op(3,6), op(1,4,9), op(2,8)]
Note that the segment IDs must be sorted from smallest to largest segment.
See {unsortedSegment (String, SDVariable, SDVariable, int) ops
for the same op without this sorted requirement- Parameters:
data
- Data to perform segment max on (NDARRAY type)segmentIds
- Variable for the segment IDs (NUMERIC type)- Returns:
- output Segment output (NUMERIC type)
-
sequenceMask
public INDArray sequenceMask(INDArray lengths, int maxLen, DataType dataType)
Generate a sequence mask (with values 0 or 1) based on the specified lengths
Specifically, out[i, ..., k, j] = (j < lengths[i, ..., k] ? 1.0 : 0.0)- Parameters:
lengths
- Lengths of the sequences (NUMERIC type)maxLen
- Maximum sequence lengthdataType
-- Returns:
- output Output variable (NUMERIC type)
-
sequenceMask
public INDArray sequenceMask(INDArray lengths, INDArray maxLen, DataType dataType)
Generate a sequence mask (with values 0 or 1) based on the specified lengths
Specifically, out[i, ..., k, j] = (j < lengths[i, ..., k] ? 1.0 : 0.0)- Parameters:
lengths
- Lengths of the sequences (NUMERIC type)maxLen
- Maximum sequence length (INT type)dataType
-- Returns:
- output Output variable (NUMERIC type)
-
sequenceMask
public INDArray sequenceMask(INDArray lengths, DataType dataType)
see sequenceMask(String, SDVariable, SDVariable, DataType)- Parameters:
lengths
- (NUMERIC type)dataType
-- Returns:
- output (NUMERIC type)
-
setShape
public INDArray[] setShape(INDArray input, INDArray shape)
Sets an inplace shape on the passed in input.- Parameters:
input
- The input to set the shape of (NUMERIC type)shape
- The shape to set the input to (NUMERIC type)
-
shape
public INDArray shape(INDArray input)
Returns the shape of the specified INDArray as a 1D INDArray- Parameters:
input
- Input variable (NUMERIC type)- Returns:
- output 1D output variable with contents equal to the shape of the input (NUMERIC type)
-
size
public INDArray size(INDArray in)
Returns the size (number of elements, i.e., prod(shape)) of the specified INDArray as a 0D scalar variable- Parameters:
in
- Input variable (NUMERIC type)- Returns:
- output 0D (scalar) output variable with value equal to the number of elements in the specified array (NUMERIC type)
-
sizeAt
public INDArray sizeAt(INDArray in, int dimension)
Returns a rank 0 (scalar) variable for the size of the specified dimension.
For example, if X has shape [10,20,30] then sizeAt(X,1)=20. Similarly, sizeAt(X,-1)=30- Parameters:
in
- Input variable (NUMERIC type)dimension
- Dimension to get size of- Returns:
- output Scalar INDArray for size at specified variable (NUMERIC type)
-
slice
public INDArray slice(INDArray input, int[] begin, int... size)
Get a subset of the specified input, by specifying the first element and the size of the array.
For example, if input is:
[a, b, c]
[d, e, f]
then slice(input, begin=[0,1], size=[2,1] will return:
[b]
[e]
Note that for each dimension i, begin[i] + size[i] <= input.size(i)- Parameters:
input
- input Variable to get subset of (NDARRAY type)begin
- Beginning index. Must be same length as rank of input array (Size: AtLeast(min=1))size
- Size of the output array. Must be same length as rank of input array (Size: AtLeast(min=1))- Returns:
- output Subset of the input (NUMERIC type)
-
slice
public INDArray slice(INDArray input, INDArray begin, INDArray size)
Get a subset of the specified input, by specifying the first element and the size of the array.
For example, if input is:
[a, b, c]
[d, e, f]
then slice(input, begin=[0,1], size=[2,1] will return:
[b]
[e]
Note that for each dimension i, begin[i] + size[i] <= input.size(i)- Parameters:
input
- input Variable to get subset of (NDARRAY type)begin
- Beginning index. Must be same length as rank of input array (INT type)size
- Size of the output array. Must be same length as rank of input array (INT type)- Returns:
- output Subset of the input (NUMERIC type)
-
sparseToDense
public INDArray sparseToDense(INDArray indices, INDArray shape, INDArray values)
Create a dense matrix equivalent of a sparse matrix based on the given input.- Parameters:
indices
- The indices of the sparse matrix (NUMERIC type)shape
- The output shape (NUMERIC type)values
- The values for the array (NUMERIC type)- Returns:
- output Populated dense INDArray with given values and indices (NUMERIC type)
-
sparseToDense
public INDArray sparseToDense(INDArray indices, INDArray shape, INDArray values, INDArray defaultValue)
Create a dense matrix equivalent of a sparse matrix based on the given input.- Parameters:
indices
- The indices of the sparse matrix (NUMERIC type)shape
- The output shape (NUMERIC type)values
- The values for the array (NUMERIC type)defaultValue
- Default value (NUMERIC type)- Returns:
- output Populated dense INDArray with given values and indices (NUMERIC type)
-
split
public INDArray[] split(INDArray input, int numSplit, int splitDim)
Split a value in to a list of ndarrays.- Parameters:
input
- Input to split (NDARRAY type)numSplit
- Number of splitssplitDim
- The dimension to split on
-
split
public INDArray[] split(INDArray input, INDArray numSplit, int splitDim)
Split a value in to a list of ndarrays.- Parameters:
input
- Input to split (NUMERIC type)numSplit
- Number of splits (NUMERIC type)splitDim
- The dimension to split on
-
splitV
public INDArray[] splitV(INDArray input, INDArray sizes, int numSplit, int splitDim)
Split a value in to a list of ndarrays with varying sizes
according to the sizes parameter.- Parameters:
input
- Input to split (NDARRAY type)sizes
- The sizes to split by (NDARRAY type)numSplit
- Number of splitssplitDim
- The dimension to split on
-
squaredNorm
public INDArray squaredNorm(INDArray x, boolean keepDims, int... dimensions)
Squared L2 norm: see norm2(String, SDVariable, boolean, int...)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- (NUMERIC type)keepDims
-dimensions
- (Size: AtLeast(min=0))- Returns:
- output (NUMERIC type)
-
squaredNorm
public INDArray squaredNorm(INDArray x, int... dimensions)
Squared L2 norm: see norm2(String, SDVariable, boolean, int...)
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- (NUMERIC type)dimensions
- (Size: AtLeast(min=0))- Returns:
- output (NUMERIC type)
-
squeeze
public INDArray squeeze(INDArray x, int axis)
Remove a single dimension of size 1.
For example, if input has shape [a,b,1,c] then squeeze(input, 2) returns an array of shape [a,b,c]- Parameters:
x
- Input variable (NUMERIC type)axis
- Size 1 dimension to remove- Returns:
- output Output variable (NUMERIC type)
-
stack
public INDArray stack(int axis, INDArray... values)
Stack a set of N INDArray of rank X into one rank X+1 variable.
If inputs have shape [a,b,c] then output has shape:
axis = 0: [N,a,b,c]
axis = 1: [a,N,b,c]
axis = 2: [a,b,N,c]
axis = 3: [a,b,c,N]
see unstack(String[], SDVariable, int, int)- Parameters:
values
- Input variables to stack. Must have the same shape for all inputs (NDARRAY type)axis
- Axis to stack on- Returns:
- output Output variable (NDARRAY type)
-
standardDeviation
public INDArray standardDeviation(INDArray x, boolean biasCorrected, boolean keepDims, int... dimensions)
Standard deviation array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)biasCorrected
- If true: divide by (N-1) (i.e., sample stdev). If false: divide by N (population stdev)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
standardDeviation
public INDArray standardDeviation(INDArray x, boolean biasCorrected, int... dimensions)
Standard deviation array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)biasCorrected
- If true: divide by (N-1) (i.e., sample stdev). If false: divide by N (population stdev)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
stridedSlice
public INDArray stridedSlice(INDArray in, long[] begin, long[] end, long[] strides, int beginMask, int endMask, int ellipsisMask, int newAxisMask, int shrinkAxisMask)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]- Parameters:
in
- Variable to get subset of (NDARRAY type)begin
- Beginning index (Size: AtLeast(min=1))end
- End index (Size: AtLeast(min=1))strides
- Stride ("step size") for each dimension. For example, stride of 2 means take every second element. (Size: AtLeast(min=1))beginMask
- Bit mask: If the ith bit is set to 1, then the value in the begin long[] is ignored, and a value of 0 is used instead for the beginning index for that dimensionendMask
- Bit mask: If the ith bit is set to 1, then the value in the end long[] is ignored, and a value of size(i)-1 is used instead for the end index for that dimensionellipsisMask
- Bit mask: only one non-zero value is allowed here. If a non-zero value is set, then other dimensions are inserted as required at the specified positionnewAxisMask
- Bit mask: if the ith bit is set to 1, then the begin/end/stride values are ignored, and a size 1 dimension is inserted at this pointshrinkAxisMask
- Bit mask: if the ith bit is set to 1, then the begin/end/stride values are ignored, and a size 1 dimension is removed at this point. Note that begin/end/stride values must result in a size 1 output for these dimensions- Returns:
- output A subset of the input array (NUMERIC type)
-
stridedSlice
public INDArray stridedSlice(INDArray in, long[] begin, long[] end, long... strides)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]- Parameters:
in
- Variable to get subset of (NDARRAY type)begin
- Beginning index (Size: AtLeast(min=1))end
- End index (Size: AtLeast(min=1))strides
- Stride ("step size") for each dimension. For example, stride of 2 means take every second element. (Size: AtLeast(min=1))- Returns:
- output A subset of the input array (NUMERIC type)
-
stridedSlice
public INDArray stridedSlice(INDArray in, INDArray begin, INDArray end, INDArray strides, int beginMask, int endMask, int ellipsisMask, int newAxisMask, int shrinkAxisMask)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]- Parameters:
in
- Variable to get subset of (NDARRAY type)begin
- The beginning indices for the slice (NUMERIC type)end
- The ending indicesof the slice (NUMERIC type)strides
- The strides for each dimension (NUMERIC type)beginMask
- Bit mask: If the ith bit is set to 1, then the value in the begin long[] is ignored, and a value of 0 is used instead for the beginning index for that dimensionendMask
- Bit mask: If the ith bit is set to 1, then the value in the end long[] is ignored, and a value of size(i)-1 is used instead for the end index for that dimensionellipsisMask
- Bit mask: only one non-zero value is allowed here. If a non-zero value is set, then other dimensions are inserted as required at the specified positionnewAxisMask
- Bit mask: if the ith bit is set to 1, then the begin/end/stride values are ignored, and a size 1 dimension is inserted at this pointshrinkAxisMask
- Bit mask: if the ith bit is set to 1, then the begin/end/stride values are ignored, and a size 1 dimension is removed at this point. Note that begin/end/stride values must result in a size 1 output for these dimensions- Returns:
- output A subset of the input array (NUMERIC type)
-
stridedSlice
public INDArray stridedSlice(INDArray in, INDArray begin, INDArray end, INDArray strides)
Get a subset of the specified input, by specifying the first element, last element, and the strides.
For example, if input is:
[a, b, c]
[d, e, f]
[g, h, i]
then stridedSlice(input, begin=[0,1], end=[2,2], strides=[2,1], all masks = 0) will return:
[b, c]
[h, i]- Parameters:
in
- Variable to get subset of (NDARRAY type)begin
- The beginning indices for the slice (NUMERIC type)end
- The ending indicesof the slice (NUMERIC type)strides
- The strides for each dimension (NUMERIC type)- Returns:
- output A subset of the input array (NUMERIC type)
-
sum
public INDArray sum(INDArray x, boolean keepDims, int... dimensions)
Sum array reduction operation, optionally along specified dimensions.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)keepDims
- If true: keep the dimensions that are reduced on (as length 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
sum
public INDArray sum(INDArray x, int... dimensions)
Sum array reduction operation, optionally along specified dimensions.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) if keepDims = false, or of rank (input rank) if keepdims = true (NUMERIC type)
-
switchOp
public INDArray[] switchOp(INDArray x, INDArray predicate)
Switch operation
Predicate - if false, values are output to left (first) branch/output; if true, to right (second) branch/output- Parameters:
x
- Input variable (NDARRAY type)predicate
- Predictate - if false, values are output to left (first) branch/output; if true, to right (second) branch/output (BOOL type)
-
tensorMmul
public INDArray tensorMmul(INDArray x, INDArray y, int[] dimensionsX, int[] dimensionsY, boolean transposeX, boolean transposeY, boolean transposeZ)
//TODO: Ops must be documented.- Parameters:
x
- Input variable x (NUMERIC type)y
- Input variable y (NUMERIC type)dimensionsX
- dimensions for first input array (x) (Size: AtLeast(min=1))dimensionsY
- dimensions for second input array (y) (Size: AtLeast(min=1))transposeX
- Transpose x (first argument)transposeY
- Transpose y (second argument)transposeZ
- Transpose result array- Returns:
- output Output variable (NUMERIC type)
-
tensorMmul
public INDArray tensorMmul(INDArray x, INDArray y, int[] dimensionsX, int... dimensionsY)
//TODO: Ops must be documented.- Parameters:
x
- Input variable x (NUMERIC type)y
- Input variable y (NUMERIC type)dimensionsX
- dimensions for first input array (x) (Size: AtLeast(min=1))dimensionsY
- dimensions for second input array (y) (Size: AtLeast(min=1))- Returns:
- output Output variable (NUMERIC type)
-
tile
public INDArray tile(INDArray x, INDArray repeat)
Repeat (tile) the input tensor the specified number of times.
For example, if input is
[1, 2]
[3, 4]
and repeat is [2, 3]
then output is
[1, 2, 1, 2, 1, 2]
[3, 4, 3, 4, 3, 4]
[1, 2, 1, 2, 1, 2]
[3, 4, 3, 4, 3, 4]- Parameters:
x
- Input variable (NDARRAY type)repeat
- Number of times to repeat in each axis. Must have length equal to the rank of the input array (INT type)- Returns:
- output Output variable (NDARRAY type)
-
tile
public INDArray tile(INDArray x, int... repeat)
see tile(String, SDVariable, int...)- Parameters:
x
- (NDARRAY type)repeat
- (Size: AtLeast(min=1))- Returns:
- output (NDARRAY type)
-
transpose
public INDArray transpose(INDArray x)
Matrix transpose operation: If input has shape [a,b] output has shape [b,a]- Parameters:
x
- Input variable (NDARRAY type)- Returns:
- output transposed input (NDARRAY type)
-
unsortedSegmentMax
public INDArray unsortedSegmentMax(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment max operation. As per segmentMax(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [6, 9, 8] = [max(3,6), max(1,4,9), max(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentMax
public INDArray unsortedSegmentMax(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment max operation. As per segmentMax(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [6, 9, 8] = [max(3,6), max(1,4,9), max(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentMean
public INDArray unsortedSegmentMean(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment mean operation. As per segmentMean(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [4.5, 4.666, 5] = [mean(3,6), mean(1,4,9), mean(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentMean
public INDArray unsortedSegmentMean(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment mean operation. As per segmentMean(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [4.5, 4.666, 5] = [mean(3,6), mean(1,4,9), mean(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentMin
public INDArray unsortedSegmentMin(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment min operation. As per segmentMin(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [3, 1, 2] = [min(3,6), min(1,4,9), min(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentMin
public INDArray unsortedSegmentMin(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment min operation. As per segmentMin(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [3, 1, 2] = [min(3,6), min(1,4,9), min(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentProd
public INDArray unsortedSegmentProd(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment product operation. As per segmentProd(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [4.5, 4.666, 5] = [mean(3,6), mean(1,4,9), mean(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentProd
public INDArray unsortedSegmentProd(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment product operation. As per segmentProd(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [4.5, 4.666, 5] = [mean(3,6), mean(1,4,9), mean(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentSqrtN
public INDArray unsortedSegmentSqrtN(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment sqrtN operation. Simply returns the sqrt of the count of the number of values in each segment
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [1.414, 1.732, 1.414] = [sqrt(2), sqrtN(3), sqrtN(2)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentSqrtN
public INDArray unsortedSegmentSqrtN(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment sqrtN operation. Simply returns the sqrt of the count of the number of values in each segment
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [1.414, 1.732, 1.414] = [sqrt(2), sqrtN(3), sqrtN(2)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentSum
public INDArray unsortedSegmentSum(INDArray data, INDArray segmentIds, int numSegments)
Unsorted segment sum operation. As per segmentSum(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [9, 14, 10] = [sum(3,6), sum(1,4,9), sum(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments- Returns:
- output Unsorted segment output (NUMERIC type)
-
unsortedSegmentSum
public INDArray unsortedSegmentSum(INDArray data, INDArray segmentIds, INDArray numSegments)
Unsorted segment sum operation. As per segmentSum(String, SDVariable, SDVariable) but without
the requirement for the indices to be sorted.
If data = [1, 3, 2, 6, 4, 9, 8]
segmentIds = [1, 0, 2, 0, 1, 1, 2]
then output = [9, 14, 10] = [sum(3,6), sum(1,4,9), sum(2,8)]- Parameters:
data
- Data (variable) to perform unsorted segment max on (NUMERIC type)segmentIds
- Variable for the segment IDs (NUMERIC type)numSegments
- Number of segments (INT type)- Returns:
- output Unsorted segment output (NUMERIC type)
-
unstack
public INDArray[] unstack(INDArray value, int axis, int num)
Unstack a variable of rank X into N rank X-1 variables by taking slices along the specified axis.
If input has shape [a,b,c] then output has shape:
axis = 0: [b,c]
axis = 1: [a,c]
axis = 2: [a,b]- Parameters:
value
- Input variable to unstack (NDARRAY type)axis
- Axis to unstack onnum
- Number of output variables
-
variance
public INDArray variance(INDArray x, boolean biasCorrected, boolean keepDims, int... dimensions)
Variance array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)biasCorrected
- If true: divide by (N-1) (i.e., sample variable). If false: divide by N (population variance)keepDims
- If true: keep the dimensions that are reduced on (as size 1). False: remove the reduction dimensionsdimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
variance
public INDArray variance(INDArray x, boolean biasCorrected, int... dimensions)
Variance array reduction operation, optionally along specified dimensions
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- Input variable (NUMERIC type)biasCorrected
- If true: divide by (N-1) (i.e., sample variable). If false: divide by N (population variance)dimensions
- Dimensions to reduce over. If dimensions are not specified, full array reduction is performed (Size: AtLeast(min=0))- Returns:
- output reduced array of rank (input rank - num dimensions) (NUMERIC type)
-
where
public INDArray where(INDArray x, INDArray y, INDArray condition)
Similar to numpy where, takes elements from x or y depending on whether the condition at a given element is true or false
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- The first array (NDARRAY type)y
- The second array (NDARRAY type)condition
- Condition array determining which elements at which indices should be picked from. If true, picks from x, other wise y (BOOL type)- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
where
public INDArray where(INDArray x, INDArray condition)
Similar to numpy where, takes elements from x or y depending on whether the condition at a given element is true or false
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- The first array (NUMERIC type)condition
- Condition array determining which elements at which indices should be picked from. If true, picks from x, other wise y (BOOL type)- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
where
public INDArray where(INDArray condition)
Returns elements that are true from the given condition array
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
condition
- Condition array determining which elements at which indices should be picked from. If true, picks from x, other wise y (BOOL type)- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
whereNumpy
public INDArray whereNumpy(INDArray x, INDArray y, INDArray condition)
As implemented in numpy, Return elements chosen from x or y depending on condition.
Note that if keepDims = true, the output variable has the same rank as the input variable,
with the reduced dimensions having size 1. This can be useful for later broadcast operations (such as subtracting
the mean along a dimension).
Example: if input has shape [a,b,c] and dimensions=[1] then output has shape:
keepDims = true: [a,1,c]
keepDims = false: [a,c]- Parameters:
x
- The first array (NDARRAY type)y
- The second array (NDARRAY type)condition
- Condition array determining which elements at which indices should be picked from. If true, picks from x, other wise y (NUMERIC type)- Returns:
- output Number of elements that the condition is satisfied for (NUMERIC type)
-
zerosLike
public INDArray zerosLike(INDArray input)
Return a variable of all 0s, with the same shape as the input variable. Note that this is dynamic:
if the input shape changes in later execution, the returned variable's shape will also be updated- Parameters:
input
- Input (NDARRAY type)- Returns:
- output A new Variable with the same (dynamic) shape as the input (NUMERIC type)
-
-