The abs
op computes the absolute value of a tensor.
The abs
op computes the absolute value of a tensor.
Given a tensor x
of real numbers, the op returns a tensor containing the absolute value of each element in
x
. For example, if x
is an input element and y
is an output element, the op computes y = |x|
.
Given a tensor x
of complex numbers, the op returns a tensor of type FLOAT32
or FLOAT64
that is the
magnitude value of each element in x
. All elements in x
must be complex numbers of the form a + bj
. The
magnitude is computed as \sqrt{a2 + b2}
. For example:
// Tensor 'x' is [[-2.25 + 4.75j], [-3.25 + 5.75j]] abs(x) ==> [5.25594902, 6.60492229]
Input tensor.
Result as a new tensor.
The acos
op computes the inverse cosine of a tensor element-wise.
The acos
op computes the inverse cosine of a tensor element-wise. I.e., y = \acos{x}
.
Input tensor.
Result as a new tensor.
The acosh
op computes the inverse hyperbolic cosine of a tensor element-wise.
The acosh
op computes the inverse hyperbolic cosine of a tensor element-wise. I.e., y = \acosh{x}
.
Input tensor.
Result as a new tensor.
The add
op adds two tensors element-wise.
The add
op adds two tensors element-wise. I.e., z = x + y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The addBias
op adds bias
to value
.
The addBias
op adds bias
to value
.
The op is (mostly) a special case of add
where bias
is restricted to be one-dimensional (i.e., has rank
1). Broadcasting is supported and so value
may have any number of dimensions. Unlike add
, the type of
bias
is allowed to differ from that of value value
in the case where both types are quantized.
Value tensor.
Bias tensor that must be one-dimensional (i.e., it must have rank 1).
Data format of the input and output tensors. With the default format NWCFormat, the
bias
tensor will be added to the last dimension of the value
tensor. Alternatively, the
format could be NCWFormat, and the bias
tensor would be added to the third-to-last
dimension.
Result as a new tensor.
The addN
op adds all input tensors element-wise.
The addN
op adds all input tensors element-wise.
Input tensors.
Result as a new tensor.
The all
op computes the logical AND of elements across axes of a tensor.
The all
op computes the logical AND of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[true, true], [false, false]] all(x) ==> false all(x, 0) ==> [false, false] all(x, 1) ==> [true, false]
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The any
op computes the logical OR of elements across axes of a tensor.
The any
op computes the logical OR of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[true, true], [false, false]] any(x) ==> true any(x, 0) ==> [true, true] any(x, 1) ==> [true, false]
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The approximatelyEqual
op computes the truth value of abs(x - y) < tolerance
element-wise.
The approximatelyEqual
op computes the truth value of abs(x - y) < tolerance
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Comparison tolerance value.
Result as a new tensor.
The argmax
op returns the indices with the largest value across axes of a tensor.
The argmax
op returns the indices with the largest value across axes of a tensor.
Note that in case of ties the identity of the return value is not guaranteed.
Input tensor.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
Data type for the output tensor.
Result as a new tensor.
The argmax
op returns the indices with the largest value across axes of a tensor.
The argmax
op returns the indices with the largest value across axes of a tensor.
Note that in case of ties the identity of the return value is not guaranteed.
Input tensor.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
Result as a new tensor.
The argmin
op returns the indices with the smallest value across axes of a tensor.
The argmin
op returns the indices with the smallest value across axes of a tensor.
Note that in case of ties the identity of the return value is not guaranteed.
Input tensor.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
Data type for the output tensor.
Result as a new tensor.
The argmin
op returns the indices with the smallest value across axes of a tensor.
The argmin
op returns the indices with the smallest value across axes of a tensor.
Note that in case of ties the identity of the return value is not guaranteed.
Input tensor.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
Result as a new tensor.
The asin
op computes the inverse sine of a tensor element-wise.
The asin
op computes the inverse sine of a tensor element-wise. I.e., y = \asin{x}
.
Input tensor.
Result as a new tensor.
The asinh
op computes the inverse hyperbolic sine of a tensor element-wise.
The asinh
op computes the inverse hyperbolic sine of a tensor element-wise. I.e., y = \asinh{x}
.
Input tensor.
Result as a new tensor.
The atan
op computes the inverse tangent of a tensor element-wise.
The atan
op computes the inverse tangent of a tensor element-wise. I.e., y = \atan{x}
.
Input tensor.
Result as a new tensor.
The atan2
op computes the inverse tangent of x / y
element-wise, respecting signs of the arguments.
The atan2
op computes the inverse tangent of x / y
element-wise, respecting signs of the arguments.
The op computes the angle \theta \in [-\pi, \pi]
such that y = r \cos(\theta)
and
x = r \sin(\theta)
, where r = \sqrt(x2 + y2)
.
First input tensor.
Second input tensor.
Result as a new tensor.
The atanh
op computes the inverse hyperbolic tangent of a tensor element-wise.
The atanh
op computes the inverse hyperbolic tangent of a tensor element-wise. I.e., y = \atanh{x}
.
Input tensor.
Result as a new tensor.
The batchToSpace
op rearranges (permutes) data from batches into blocks of spatial data, followed by cropping.
The batchToSpace
op rearranges (permutes) data from batches into blocks of spatial data, followed by cropping.
More specifically, the op outputs a copy of the input tensor where values from the batch
dimension are moved
in spatial blocks to the height
and width
dimensions, followed by cropping along the height
and width
dimensions. This is the reverse functionality to that of spaceToBatch.
input
is a 4
-dimensional input tensor with shape
[batch * blockSize * blockSize, heightPad / blockSize, widthPad / blockSize, depth]
.
crops
has shape [2, 2]
. It specifies how many elements to crop from the intermediate result across the
spatial dimensions as follows: crops = cropBottom], [cropLeft, cropRight
. The shape of the output
will be: [batch, heightPad - cropTom - cropBottom, widthPad - cropLeft - cropRight, depth]
.
Some examples:
// === Example #1 === // input = [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] (shape = [4, 1, 1, 1]) // blockSize = 2 // crops = [[0, 0], [0, 0]] batchToSpace(input, blockSize, crops) ==> [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // === Example #2 === // input = [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [4, 1, 1, 3]) // blockSize = 2 // crops = [[0, 0], [0, 0]] batchToSpace(input, blockSize, crops) ==> [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] (shape = [1, 2, 2, 3]) // === Example #3 === // input = [[[[1], [3]], [[ 9], [11]]], // [[[2], [4]], [[10], [12]]], // [[[5], [7]], [[13], [15]]], // [[[6], [8]], [[14], [16]]]] (shape = [4, 2, 2, 1]) // blockSize = 2 // crops = [[0, 0], [0, 0]] batchToSpace(input, blockSize, crops) ==> [[[[ 1], [2], [3], [ 4]], [[ 5], [6], [7], [ 8]], [[ 9], [10], [11], [12]], [[13], [14], [15], [16]]]] (shape = [1, 4, 4, 1]) // === Example #4 === // input = [[[[0], [1], [3]]], [[[0], [ 9], [11]]], // [[[0], [2], [4]]], [[[0], [10], [12]]], // [[[0], [5], [7]]], [[[0], [13], [15]]], // [[[0], [6], [8]]], [[[0], [14], [16]]]] (shape = [8, 1, 3, 1]) // blockSize = 2 // crops = [[0, 0], [2, 0]] batchToSpace(input, blockSize, crops) ==> [[[[ 1], [2], [3], [ 4]], [[ 5], [6], [7], [ 8]]], [[[ 9], [10], [11], [12]], [[13], [14], [15], [16]]]] (shape = [2, 2, 4, 1])
4
-dimensional input tensor with shape [batch, height, width, depth]
.
Block size which must be greater than 1
.
2
-dimensional tensor containing non-negative integers with shape [2, 2]
.
Result as a new tensor.
The batchToSpaceND
op reshapes the "batch" dimension 0
into M + 1
dimensions of shape
blockShape + [batch]
and interleaves these blocks back into the grid defined by the spatial dimensions
[1, ..., M]
, to obtain a result with the same rank as the input.
The batchToSpaceND
op reshapes the "batch" dimension 0
into M + 1
dimensions of shape
blockShape + [batch]
and interleaves these blocks back into the grid defined by the spatial dimensions
[1, ..., M]
, to obtain a result with the same rank as the input. The spatial dimensions of this intermediate
result are then optionally cropped according to crops
to produce the output. This is the reverse functionality
to that of spaceToBatchND.
input
is an N
-dimensional tensor with shape inputShape = [batch] + spatialShape + remainingShape
, where
spatialShape
has M
dimensions.
The op is equivalent to the following steps:
input
to reshaped
of shape:[blockShape(0), ..., blockShape(M-1), batch / product(blockShape), inputShape(1), ..., inputShape(N-1)]
2. Permute dimensions of reshaped
to produce permuted
of shape:
[batch / product(blockShape), inputShape(1), blockShape(0), ..., inputShape(N-1), blockShape(M-1), inputShape(M+1), ..., inputShape(N-1)]
3. Reshape permuted
to produce reshapedPermuted
of shape:
[batch / product(blockShape), inputShape(1) * blockShape(0), ..., inputShape(M) * blockShape(M-1), ..., inputShape(M+1), ..., inputShape(N-1)]
4. Crop the start and end of dimensions [1, ..., M]
of reshapedPermuted
according to crops
to produce
the output of shape:
[batch / product(blockShape), inputShape(1) * blockShape(0) - crops(0, 0) - crops(0, 1), ..., inputShape(M) * blockShape(M-1) - crops(M-1, 0) - crops(M-1, 1), inputShape(M+1), ..., inputShape(N-1)]
Some exaples:
// === Example #1 === // input = [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] (shape = [4, 1, 1, 1]) // blockShape = [2, 2] // crops = [[0, 0], [0, 0]] batchToSpaceND(input, blockShape, crops) ==> [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // === Example #2 === // input = [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [4, 1, 1, 3]) // blockShape = [2, 2] // crops = [[0, 0], [0, 0]] batchToSpaceND(input, blockShape, crops) ==> [[[[1, 2, 3], [ 4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] (shape = [1, 2, 2, 3]) // === Example #3 === // input = [[[[1], [3]], [[ 9], [11]]], // [[[2], [4]], [[10], [12]]], // [[[5], [7]], [[13], [15]]], // [[[6], [8]], [[14], [16]]]] (shape = [4, 2, 2, 1]) // blockShape = [2, 2] // crops = [[0, 0], [0, 0]] batchToSpaceND(input, blockShape, crops) ==> [[[[ 1], [2], [3], [ 4]], [[ 5], [6], [7], [ 8]], [[ 9], [10], [11], [12]], [[13], [14], [15], [16]]]] (shape = [1, 4, 4, 1]) // === Example #4 === // input = [[[[0], [1], [3]]], [[[0], [ 9], [11]]], // [[[0], [2], [4]]], [[[0], [10], [12]]], // [[[0], [5], [7]]], [[[0], [13], [15]]], // [[[0], [6], [8]]], [[[0], [14], [16]]]] (shape = [8, 1, 3, 1]) // blockShape = [2, 2] // crops = [[0, 0], [2, 0]] batchToSpaceND(input, blockShape, crops) ==> [[[[[ 1], [2], [3], [ 4]], [[ 5], [6], [7], [ 8]]], [[[ 9], [10], [11], [12]], [[13], [14], [15], [16]]]] (shape = [2, 2, 4, 1])
N
-dimensional tensor with shape inputShape = [batch] + spatialShape + remainingShape
, where
spatialShape has M
dimensions.
One-dimensional tensor with shape [M]
whose elements must all be >= 1
.
Two-dimensional tensor with shape [M, 2]
whose elements must all be non-negative.
crops(i) = [cropStart, cropEnd]
specifies the amount to crop from input dimension i + 1
,
which corresponds to spatial dimension i
. It is required that
cropStart(i) + cropEnd(i) <= blockShape(i) * inputShape(i + 1)
.
Result as a new tensor.
The binCount
op counts the number of occurrences of each value in an integer tensor.
The binCount
op counts the number of occurrences of each value in an integer tensor.
If minLength
and maxLength
are not provided, the op returns a vector with length max(input) + 1
, if
input
is non-empty, and length 0
otherwise.
If weights
is not null
, then index i
of the output stores the sum of the value in weights
at each
index where the corresponding value in input
is equal to i
.
Tensor containing non-negative values.
If not null
, this tensor must have the same shape as input
. For each value in input
, the
corresponding bin count will be incremented by the corresponding weight instead of 1
.
If not null
, this ensures the output has length at least minLength
, padding with zeros at
the end, if necessary.
If not null
, this skips values in input
that are equal or greater than maxLength
,
ensuring that the output has length at most maxLength
.
If weights
is null
, this determines the data type used for the output tensor (i.e., the
tensor containing the bin counts).
Result as a new tensor.
$OpDocMathBitcast
$OpDocMathBitcast
Input tensor.
Target data type.
Result as a new tensor.
The booleanMask
op applies the provided boolean mask to input
.
The booleanMask
op applies the provided boolean mask to input
.
In general, 0 < mask.rank = K <= tensor.rank
, and mask
's shape must match the first K
dimensions of
tensor
's shape. We then have:
booleanMask(tensor, mask)(i, j1, --- , jd) = tensor(i1, --- , iK, j1, ---, jd)
, where (i1, ---, iK)
is the
i
th true
entry of mask
(in row-major order).
For example:
// 1-D example tensor = [0, 1, 2, 3] mask = [True, False, True, False] booleanMask(tensor, mask) ==> [0, 2] // 2-D example tensor = [[1, 2], [3, 4], [5, 6]] mask = [True, False, True] booleanMask(tensor, mask) ==> [[1, 2], [5, 6]]
N
-dimensional tensor.
K
-dimensional boolean tensor, where K <= N
and K
must be known statically.
Result as a new tensor.
The bucketize
op bucketizes a tensor based on the provided boundaries.
The bucketize
op bucketizes a tensor based on the provided boundaries.
For example:
// 'input' is [[-5, 10000], [150, 10], [5, 100]] // 'boundaries' are [0, 10, 100] bucketize(input, boundaries) ==> [[0, 3], [3, 2], [1, 3]]
Numeric tensor to bucketize.
Sorted sequence of numbers specifying the boundaries of the buckets.
Result as a new tensor.
$OpDocMathCast
$OpDocMathCast
Tensor to cast.
Target data type.
Result as a new tensor.
The ceil
op computes the smallest integer not greater than the current value of a tensor, element-wise.
The ceil
op computes the smallest integer not greater than the current value of a tensor, element-wise.
Input tensor.
Result as a new tensor.
The checkNumerics
op checks a tensor for NaN
and Inf
values.
The checkNumerics
op checks a tensor for NaN
and Inf
values.
When run, reports an InvalidArgument
error if input
has any values that are not-a-number (NaN
) or infinity
(Inf
). Otherwise, it acts as an identity op and passes input
to the output, as-is.
Input tensor.
Prefix to print for the error message.
Result as a new tensor which has the same value as the input tensor.
The complex
op converts two real tensors to a complex tensor.
The complex
op converts two real tensors to a complex tensor.
Given a tensor real
representing the real part of a complex number, and a tensor imag
representing the
imaginary part of a complex number, the op returns complex numbers element-wise of the form a + bj
, where *a*
represents the real
part and *b* represents the imag
part. The input tensors real
and imag
must have the
same shape and data type.
For example:
// 'real' is [2.25, 3.25] // 'imag' is [4.75, 5.75] complex(real, imag) ==> [[2.25 + 4.75j], [3.25 + 5.75j]]
Tensor containing the real component.
Tensor containing the imaginary component.
Result as a new tensor.
The complex
op converts two real tensors to a complex tensor.
The complex
op converts two real tensors to a complex tensor.
Given a tensor real
representing the real part of a complex number, and a tensor imag
representing the
imaginary part of a complex number, the op returns complex numbers element-wise of the form a + bj
, where *a*
represents the real
part and *b* represents the imag
part. The input tensors real
and imag
must have the
same shape and data type.
For example:
// 'real' is [2.25, 3.25] // 'imag' is [4.75, 5.75] complex(real, imag) ==> [[2.25 + 4.75j], [3.25 + 5.75j]]
Tensor containing the real component.
Tensor containing the imaginary component.
Result as a new tensor.
The concatenate
op concatenates tensors along one dimension.
The concatenate
op concatenates tensors along one dimension.
The op concatenates the list of tensors inputs
along the dimension axis
. If
inputs(i).shape = [D0, D1, ..., Daxis(i), ..., Dn]
, then the concatenated tensor will have shape
[D0, D1, ..., Raxis, ..., Dn]
, where Raxis = sum(Daxis(i))
. That is, the data from the input tensors is
joined along the axis
dimension.
For example:
// 't1' is equal to [[1, 2, 3], [4, 5, 6]] // 't2' is equal to [[7, 8, 9], [10, 11, 12]] concatenate(Array(t1, t2), 0) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] concatenate(Array(t1, t2), 1) ==> [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]] // 't3' has shape [2, 3] // 't4' has shape [2, 3] concatenate(Array(t3, t4), 0).shape ==> [4, 3] concatenate(Array(t3, t4), 1).shape ==> [2, 6]
Note that, if you want to concatenate along a new axis, it may be better to use the stack
op instead:
concatenate(tensors.map(t => expandDims(t, axis)), axis) == stack(tensors, axis)
Input tensors to be concatenated.
Dimension along which to concatenate the input tensors.
Result as a new tensor.
The conjugate
op returns the element-wise complex conjugate of a tensor.
The conjugate
op returns the element-wise complex conjugate of a tensor.
Given a numeric tensor input
, the op returns a tensor with numbers that are the complex conjugate of each
element in input
. If the numbers in input
are of the form a + bj
, where *a* is the real part and *b* is
the imaginary part, then the complex conjugate returned by this operation is of the form a - bj
.
For example:
// 'input' is [-2.25 + 4.75j, 3.25 + 5.75j] conjugate(input) ==> [-2.25 - 4.75j, 3.25 - 5.75j]
If input
is real-valued, then it is returned unchanged.
Input tensor.
Result as a new tensor.
The conv2D
op computes a 2-D convolution given 4-D input
and filter
tensors.
The conv2D
op computes a 2-D convolution given 4-D input
and filter
tensors.
Given an input tensor of shape [batch, inHeight, inWidth, inChannels]
and a filter / kernel tensor of shape
[filterHeight, filterWidth, inChannels, outChannels]
, the op performs the following:
[filterHeight * filterWidth * inChannels, outputChannels]
.
2. Extracts image patches from the input tensor to form a *virtual* tensor of shape
[batch, outHeight, outWidth, filterHeight * filterWidth * inChannels]
.
3. For each patch, right-multiplies the filter matrix and the image patch vector.For example, for the default NWCFormat:
output(b,i,j,k) = sum_{di,dj,q} input(b, stride1 * i + di, stride2 * j + dj, q) * filter(di,dj,q,k).
Must have strides[0] = strides[3] = 1
. For the most common case of the same horizontal and vertices strides,
strides = [1, stride, stride, 1]
.
4-D tensor whose dimension order is interpreted according to the value of dataFormat
.
4-D tensor with shape [filterHeight, filterWidth, inChannels, outChannels]
.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
The dilation factor for each dimension of input. If set to k > 1
, there will be k - 1
skipped cells between each filter element on that dimension. The dimension order is
determined by the value of dataFormat
. Dilations in the batch and depth dimensions must
be set to 1
.
Boolean value indicating whether or not to use CuDNN for the created op, if its placed on a GPU, as opposed to the TensorFlow implementation.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The conv2DBackpropFilter
op computes the gradient of the conv2D
op with respect to its filter tensor.
The conv2DBackpropFilter
op computes the gradient of the conv2D
op with respect to its filter tensor.
4-D tensor whose dimension order is interpreted according to the value of dataFormat
.
Integer vector representing the shape of the original filter, which is a 4-D tensor.
4-D tensor containing the gradients w.r.t. the output of the convolution and whose shape
depends on the value of dataFormat
.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
The dilation factor for each dimension of input. If set to k > 1
, there will be k - 1
skipped cells between each filter element on that dimension. The dimension order is
determined by the value of dataFormat
. Dilations in the batch and depth dimensions must
be set to 1
.
Boolean value indicating whether or not to use CuDNN for the created op, if its placed on a GPU, as opposed to the TensorFlow implementation.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The conv2DBackpropInput
op computes the gradient of the conv2D
op with respect to its input tensor.
The conv2DBackpropInput
op computes the gradient of the conv2D
op with respect to its input tensor.
Integer vector representing the shape of the original input, which is a 4-D tensor.
4-D tensor with shape [filterHeight, filterWidth, inChannels, outChannels]
.
4-D tensor containing the gradients w.r.t. the output of the convolution and whose shape
depends on the value of dataFormat
.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
The dilation factor for each dimension of input. If set to k > 1
, there will be k - 1
skipped cells between each filter element on that dimension. The dimension order is
determined by the value of dataFormat
. Dilations in the batch and depth dimensions must
be set to 1
.
Boolean value indicating whether or not to use CuDNN for the created op, if its placed on a GPU, as opposed to the TensorFlow implementation.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The cos
op computes the cosine of a tensor element-wise.
The cos
op computes the cosine of a tensor element-wise. I.e., y = \cos{x}
.
Input tensor.
Result as a new tensor.
The cosh
op computes the hyperbolic cosine of a tensor element-wise.
The cosh
op computes the hyperbolic cosine of a tensor element-wise. I.e., y = \cosh{x}
.
Input tensor.
Result as a new tensor.
The countNonZero
op computes the number of non-zero elements across axes of a tensor.
The countNonZero
op computes the number of non-zero elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
IMPORTANT NOTE: Floating point comparison to zero is done by exact floating point equality check. Small values are not rounded to zero for the purposes of the non-zero check.
For example:
// 'x' is [[0, 1, 0], [1, 1, 0]] countNonZero(x) ==> 3 countNonZero(x, 0) ==> [1, 2, 0] countNonZero(x, 1) ==> [1, 2] countNonZero(x, 1, keepDims = true) ==> [[1], [2]] countNonZero(x, [0, 1]) ==> 3
IMPORTANT NOTE: Strings are compared against zero-length empty string ""
. Any string with a size greater
than zero is already considered as nonzero.
For example:
// 'x' is ["", "a", " ", "b", ""] countNonZero(x) ==> 3 // "a", " ", and "b" are treated as nonzero strings.
Input tensor to reduce.
Integer array containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The crelu
op computes the concatenated rectified linear unit activation function.
The crelu
op computes the concatenated rectified linear unit activation function.
The op concatenates a ReLU which selects only the positive part of the activation with a ReLU which selects only the *negative* part of the activation. Note that as a result this non-linearity doubles the depth of the activations.
Source: [Understanding and Improving Convolutional Neural Networks via Concatenated Rectified Linear Units](https://arxiv.org/abs/1603.05201)
Input tensor.
Along along which the output values are concatenated along.
Result as a new tensor.
The cross
op computes the pairwise cross product between two tensors.
The cross
op computes the pairwise cross product between two tensors.
a
and b
must have the same shape; they can either be simple 3-element vectors, or have any shape
where the innermost dimension size is 3. In the latter case, each pair of corresponding 3-element vectors
is cross-multiplied independently.
First input tensor.
Second input tensor.
Result as a new tensor.
The cumprod
op computes the cumulative product of the tensor along an axis.
The cumprod
op computes the cumulative product of the tensor along an axis.
By default, the op performs an inclusive cumulative product, which means that the first element of the input is identical to the first element of the output:
cumprod([a, b, c]) ==> [a, a * b, a * b * c]
By setting the exclusive
argument to true
, an exclusive cumulative product is performed instead:
cumprod([a, b, c], exclusive = true) ==> [0, a, a * b]
By setting the reverse
argument to true
, the cumulative product is performed in the opposite direction:
cumprod([a, b, c], reverse = true) ==> [a * b * c, b * c, c]
This is more efficient than using separate Basic.reverse ops.
The reverse
and exclusive
arguments can also be combined:
cumprod([a, b, c], exclusive = true, reverse = true) ==> [b * c, c, 0]
Input tensor.
INT32
tensor containing the axis along which to perform the cumulative product.
Boolean value indicating whether to perform an exclusive cumulative product.
Boolean value indicating whether to perform a reverse cumulative product.
Result as a new tensor.
The cumsum
op computes the cumulative sum of the tensor along an axis.
The cumsum
op computes the cumulative sum of the tensor along an axis.
By default, the op performs an inclusive cumulative sum, which means that the first element of the input is identical to the first element of the output:
cumsum([a, b, c]) ==> [a, a + b, a + b + c]
By setting the exclusive
argument to true
, an exclusive cumulative sum is performed instead:
cumsum([a, b, c], exclusive = true) ==> [0, a, a + b]
By setting the reverse
argument to true
, the cumulative sum is performed in the opposite direction:
cumsum([a, b, c], reverse = true) ==> [a + b + c, b + c, c]
This is more efficient than using separate Basic.reverse ops.
The reverse
and exclusive
arguments can also be combined:
cumsum([a, b, c], exclusive = true, reverse = true) ==> [b + c, c, 0]
Input tensor.
Tensor containing the axis along which to perform the cumulative sum.
Boolean value indicating whether to perform an exclusive cumulative sum.
Boolean value indicating whether to perform a reverse cumulative sum.
Result as a new tensor.
The depthToSpace
op rearranges data from depth into blocks of spatial data.
The depthToSpace
op rearranges data from depth into blocks of spatial data.
More specifically, the op outputs a copy of the input tensor where values from the depth
dimension are moved
in spatial blocks to the height
and width
dimensions. blockSize
indicates the input block size and how the
data us moved:
blockSize * blockSize
from depth are rearranged into non-overlapping blocks of size
blockSize x blockSize
.inputDepth * blockSize
, whereas the height is inputHeight * blockSize
.blockSize * blockSize
. That is, assuming that input
is in the shape [batch, height, width, depth]
, the shape of the output will be:
[batch, height * blockSize, width * blockSize, depth / (block_size * block_size)]
.
This op is useful for resizing the activations between convolutions (but keeping all data), e.g., instead of pooling. It is also useful for training purely convolutional models.
Some examples:
// === Example #1 === // input = [[[[1, 2, 3, 4]]]] (shape = [1, 1, 1, 4]) // blockSize = 2 depthToSpace(input, blockSize) ==> [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // === Example #2 === // input = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]] (shape = [1, 1, 1, 12]) // blockSize = 2 depthToSpace(input, blockSize) ==> [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [1, 2, 2, 3]) // === Example #3 === // input = [[[[ 1, 2, 3, 4], // [ 5, 6, 7, 8]], // [[ 9, 10, 11, 12], // [13, 14, 15, 16]]]] (shape = [1, 2, 2, 4]) // blockSize = 2 depthToSpace(input, blockSize) ==> [[[[ 1], [ 2], [ 5], [ 6]], [[ 3], [ 4], [ 7], [ 8]], [[ 9], [10], [13], [14]], [[11], [12], [15], [16]]]] (shape = [1, 4, 4, 1,])
4
-dimensional input tensor with shape [batch, height, width, depth]
.
Block size which must be greater than 1
.
Format of the input and output data.
Result as a new tensor.
The diag
op constructs a diagonal tensor using the provided diagonal values.
The diag
op constructs a diagonal tensor using the provided diagonal values.
Given a diagonal
, the op returns a tensor with that diagonal
and everything else padded with zeros. The
diagonal is computed as follows:
Assume that diagonal
has shape [D1,..., DK]
. Then the output tensor, output
, is a rank-2K
tensor with
shape [D1, ..., DK, D1, ..., DK]
, where output(i1, ..., iK, i1, ..., iK) = diagonal(i1, ..., iK)
and 0
everywhere else.
For example:
// 'diagonal' is [1, 2, 3, 4] diag(diagonal) ==> [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]
This op is the inverse of diagPart.
Diagonal values, represented as a rank-K
tensor, where K
can be at most 3
.
Result as a new tensor.
The diagPart
op returns the diagonal part of a tensor.
The diagPart
op returns the diagonal part of a tensor.
The op returns a tensor with the diagonal
part of the input
. The diagonal
part is computed as follows:
Assume input
has shape [D1, ..., DK, D1, ..., DK]
. Then the output is a rank-K
tensor with shape
[D1,..., DK]
, where diagonal(i1, ..., iK) = output(i1, ..., iK, i1, ..., iK)
.
For example:
// 'input' is [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]] diagPart(input) ==> [1, 2, 3, 4]
This op is the inverse of diag.
Rank-K
input tensor, where K
is either 2
, 4
, or 6
.
Result as a new tensor.
The digamma
op computes the derivative of the logarithm of the absolute value of the Gamma function applied
element-wise on a tensor (i.e., the digamma or Psi function).
The digamma
op computes the derivative of the logarithm of the absolute value of the Gamma function applied
element-wise on a tensor (i.e., the digamma or Psi function). I.e., y = \partial\log{|\Gamma{x}|}
.
Input tensor.
Result as a new tensor.
The divide
op divides two tensors element-wise.
The divide
op divides two tensors element-wise. I.e., z = x / y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The dropout
op computes a dropout layer.
The dropout
op computes a dropout layer.
With probability keepProbability
, the op outputs the input element scaled up by 1 / keepProbability
,
otherwise it outputs 0
. The scaling is such that the expected sum remains unchanged.
By default, each element is kept or dropped independently. If noiseShape
is specified, it must be
[broadcastable](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) to the shape of input
, and only
dimensions with noiseShape(i) == x.shape(i)
will make independent decisions. For example, if
x.shape = [k, l, m, n]
and noiseShape = [k, 1, 1, n]
, each k
and n
component will be kept independently
and each l
and m
component will be kept or not kept together.
Input tensor.
Probability (i.e., number in the interval (0, 1]
) that each element is kept.
If true
, the outputs will be divided by the keep probability.
Rank-1 tensor representing the shape for the randomly generated keep/drop flags.
Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.
Result as a new tensor that has the same shape as input
.
The editDistance
op computes the Levenshtein distance between sequences.
The editDistance
op computes the Levenshtein distance between sequences.
The op takes variable-length sequences (hypothesis
and truth
), each provided as a SparseTensor
, and
computes the Levenshtein distance between them. The op can also normalize the edit distance using the length of
truth
by setting normalize
to true
.
For example:
// 'hypothesis' is a tensor of shape `[2, 1]` with variable-length values: // [0, 0] = ["a"] // [0, 1] = ["b"] val hypothesis = SparseOutput(Tensor(Tensor(0, 0, 0), Tensor(1, 0, 0)), Tensor("a", "b"), Tensor(2, 1, 1)) // 'truth' is a tensor of shape `[2, 2]` with variable-length values: // [0, 0] = [] // [0, 1] = ["a"] // [1, 0] = ["b", "c"] // [1, 1] = ["a"] val truth = SparseOutput( Tensor(Tensor(0, 1, 0), Tensor(1, 0, 0), Tensor(1, 0, 1), Tensor(1, 1, 0)), Tensor("a", "b", "c", "a"), Tensor(2, 2, 2)) val normalize = true // 'output' is a tensor of shape `[2, 2]` with edit distances normalized by the `truth` lengths, and contains // the values `[[inf, 1.0], [0.5, 1.0]]`. The reason behind each value is: // - (0, 0): no truth, // - (0, 1): no hypothesis, // - (1, 0): addition, // - (1, 1): no hypothesis. val output = editDistance(hypothesis, truth, normalize)
Sparse tensor that contains the hypothesis sequences.
Sparse tensor that contains the truth sequences.
Optional boolean value indicating whether to normalize the Levenshtein distance by the
length of truth
.
Result as a new tensor.
The elu
op computes the exponential linear unit activation function.
The elu
op computes the exponential linear unit activation function.
The exponential linear unit activation function is defined as elu(x) = x
, if x > 0
, and
elu(x) = exp(x) - 1
, otherwise.
Source: [Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)](http://arxiv.org/abs/1511.07289)
Input tensor.
Result as a new tensor.
The equal
op computes the truth value of x == y
element-wise.
The equal
op computes the truth value of x == y
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The erf
op computes the Gaussian error function element-wise on a tensor.
The erf
op computes the Gaussian error function element-wise on a tensor.
Input tensor.
Result as a new tensor.
The erfc
op computes the complementary Gaussian error function element-wise on a tensor.
The erfc
op computes the complementary Gaussian error function element-wise on a tensor.
Input tensor.
Result as a new tensor.
The exp
op computes the exponential of a tensor element-wise.
The exp
op computes the exponential of a tensor element-wise. I.e., y = \exp{x} = e^x
.
Input tensor.
Result as a new tensor.
The expandDims
op inserts a dimension of size 1 into the tensor's shape and returns the result as a new
tensor.
The expandDims
op inserts a dimension of size 1 into the tensor's shape and returns the result as a new
tensor.
Given a tensor input
, the op inserts a dimension of size 1 at the dimension index axis
of the tensor's
shape. The dimension index axis
starts at zero; if you specify a negative number for axis
it is counted
backwards from the end.
This op is useful if you want to add a batch dimension to a single element. For example, if you have a single
image of shape [height, width, channels]
, you can make it a batch of 1 image with expandDims(image, 0)
,
which will make the shape equal to [1, height, width, channels]
.
For example:
* // 't1' is a tensor of shape [2] t1.expandDims(0).shape == Shape(1, 2) t1.expandDims(1).shape == Shape(2, 1) t1.expandDims(-1).shape == Shape(2, 1) // 't2' is a tensor of shape [2, 3, 5] t2.expandDims(0).shape == Shape(1, 2, 3, 5) t2.expandDims(2).shape == Shape(2, 3, 1, 5) t2.expandDims(3).shape == Shape(2, 3, 5, 1)
This op requires that -1 - input.rank <= axis <= input.rank
.
This is related to squeeze
, which removes dimensions of size 1.
Input tensor.
Dimension index at which to expand the shape of input
.
Result as a new tensor.
The expm1
op computes the exponential of a tensor minus 1
element-wise.
The expm1
op computes the exponential of a tensor minus 1
element-wise. I.e., y = \exp{x} - 1
.
Input tensor.
Result as a new tensor.
The floor
op computes the largest integer not greater than the current value of a tensor, element-wise.
The floor
op computes the largest integer not greater than the current value of a tensor, element-wise.
Input tensor.
Result as a new tensor.
The floorMod
op computes the remainder of the division between two tensors element-wise.
The floorMod
op computes the remainder of the division between two tensors element-wise.
When x < 0
xor y < 0
is true, the op follows Python semantics in that the result here is
consistent with a flooring divide. E.g., floor(x / y) * y + mod(x, y) = x
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The gather
op gathers slices from input
axis axis
, according to indices
.
The gather
op gathers slices from input
axis axis
, according to indices
.
indices
must be an integer tensor of any dimension (usually 0-D or 1-D). The op produces an output tensor with
shape input.shape[::axis] + indices.shape + input.shape(axis + 1::)
, where:
// Scalar indices (output has rank = rank(input) - 1) output(a_0, ..., a_n, b_0, ..., b_n) = input(a_0, ..., a_n, indices, b_0, ..., b_n) // Vector indices (output has rank = rank(input)) output(a_0, ..., a_n, i, b_0, ..., b_n) = input(a_0, ..., a_n, indices(i), b_0, ..., b_n) // Higher rank indices (output has rank = rank(input) + rank(indices) - 1) output(a_0, ..., a_n, i, ..., j, b_0, ..., b_n) = input(a_0, ..., a_n, indices(i, ..., j), b_0, ..., b_n)
If indices
is a permutation and indices.length == input.shape(0)
, then this op will permute input
accordingly.
Tensor from which to gather values.
Tensor containing indices to gather.
Tensor containing the axis along which to gather.
Result as a new tensor.
The gatherND
op gathers values or slices from input
according to indices
.
The gatherND
op gathers values or slices from input
according to indices
.
indices
is an integer tensor containing indices into input
. The last dimension of indices
can be equal to
at most the rank of input
, indices.shape(-1) <= input.rank
. The last dimension of indices
corresponds to
elements (if indices.shape(-1) == input.rank
), or slices (if indices.shape(-1) < input.rank
) along dimension
indices.shape(-1)
of input
. The output has shape indices.shape(::-1) + input.shape(indices.shape(-1)::)
.
Some examples follow.
Simple indexing into a matrix:
input = [['a', 'b'], ['c', 'd']] indices = [[0, 0], [1, 1]] output = ['a', 'd']
Slice indexing into a matrix:
input = [['a', 'b'], ['c', 'd']] indices = [[1], [0]] output = [['c', 'd'], ['a', 'b']]
Indexing into a three-dimensional tensor:
input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[1]] output = [[['a1', 'b1'], ['c1', 'd1']]] input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[0, 1], [1, 0]] output = [['c0', 'd0'], ['a1', 'b1']] input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[0, 0, 1], [1, 0, 1]] output = ['b0', 'b1']
Batched indexing into a matrix:
input = [['a', 'b'], ['c', 'd']] indices = [[[0, 0]], [[0, 1]]] output = [['a'], ['b']]
Batched slice indexing into a matrix:
input = [['a', 'b'], ['c', 'd']] indices = [[[1]], [[0]]] output = [[['c', 'd']], [['a', 'b']]]
Batched indexing into a three-dimensional tensor:
input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[[1]], [[0]]] output = [[[['a1', 'b1'], ['c1', 'd1']]], [[['a0', 'b0'], ['c0', 'd0']]]] input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]] output = [[['c0', 'd0'], ['a1', 'b1']], [['a0', 'b0'], ['c1', 'd1']]] input = [[['a0', 'b0'], ['c0', 'd0']], [['a1', 'b1'], ['c1', 'd1']]] indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]] output = [['b0', 'b1'], ['d0', 'c1']]
Tensor from which to gather values.
Tensor containing indices to gather.
Result as a new tensor which contains the values from input
gathered from indices given by indices
,
with shape indices.shape(::-1) + input.shape(indices.shape(-1)::)
.
OpDocMathGreater
OpDocMathGreater
First input tensor.
Second input tensor.
Result as a new tensor.
OpDocMathGreaterEqual
OpDocMathGreaterEqual
First input tensor.
Second input tensor.
Result as a new tensor.
The igamma
op computes the lower regularized incomplete Gamma function Q(a, x)
.
The igamma
op computes the lower regularized incomplete Gamma function Q(a, x)
.
The lower regularized incomplete Gamma function is defined as:
P(a, x) = gamma(a, x) / Gamma(a) = 1 - Q(a, x)
, where:
Gamma(a, x) = \int_{0}{x} t{a-1} exp(-t) dt
is the lower incomplete Gamma function.
Note that, above, Q(a, x)
(Igammac
) is the upper regularized complete Gamma function.
First input tensor.
Second input tensor.
Result as a new tensor.
The igammac
op computes the upper regularized incomplete Gamma function Q(a, x)
.
The igammac
op computes the upper regularized incomplete Gamma function Q(a, x)
.
The upper regularized incomplete Gamma function is defined as:
Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)
, where:
Gamma(a, x) = \int_{x}{\infty} t{a-1} exp(-t) dt
is the upper incomplete Gama function.
Note that, above, P(a, x)
(Igamma
) is the lower regularized complete Gamma function.
First input tensor.
Second input tensor.
Result as a new tensor.
The inTopK
op checks whether the targets
are in the top K
predictions
.
The inTopK
op checks whether the targets
are in the top K
predictions
.
The op outputs a boolean tensor with shape [batchSize]
, with entry output(i)
being true
if the target
class is among the top k
predictions, among all predictions for example i
. Note that the behavior of
inTopK differs from topK in its handling of ties; if multiple classes have the same prediction value and
straddle the top-k
boundary, then all of those classes are considered to be in the top k
.
More formally, let:
predictions(i, ::)
be the predictions for all classes for example i
,targets(i)
be the target class for example i
, andoutput(i)
be the output for example i
.
Then output(i) = predictions(i, targets(i)) \in TopKIncludingTies(predictions(i))
.Tensor containing the predictions.
Tensor containing the targets.
Scalar tensor containing the number of top elements to look at.
Result as a new tensor.
The incompleteBeta
op computes the regularized incomplete beta integral I_x(a, b)
.
The incompleteBeta
op computes the regularized incomplete beta integral I_x(a, b)
.
The regularized incomplete beta integral is defined as:
I_x(a, b) = \frac{B(x; a, b)}{B(a, b)}
, where:
B(x; a, b) = \int_0x t{a-1} (1 - t)^{b-1} dt
is the incomplete beta function and B(a, b)
is the *complete* beta function.
First input tensor.
Second input tensor.
Third input tensor.
Result as a new tensor.
The indexedSlicesMask
op masks elements of indexed slices tensors.
The indexedSlicesMask
op masks elements of indexed slices tensors.
Given an indexed slices tensor instance input
, this function returns another indexed slices tensor
that contains a subset of the slices of input
. Only the slices at indices not specified in maskIndices
are
returned.
This is useful when you need to extract a subset of slices from an indexed slices tensor.
For example:
// 'input' contains slices at indices [12, 26, 37, 45] from a large tensor with shape [1000, 10] input.indices ==> [12, 26, 37, 45] input.values.shape ==> [4, 10] // `output` will be the subset of `input` slices at its second and third indices, and so we want to mask its // first and last indices (which are at absolute indices 12 and 45) val output = tf.indexedSlicesMask(input, [12, 45]) output.indices ==> [26, 37] output.values.shape ==> [2, 10]
Input indexed slices.
One-dimensional tensor containing the indices of the elements to mask.
Result as a new tensor indexed slices object.
The invertPermutation
op computes the inverse permutation of a tensor.
The invertPermutation
op computes the inverse permutation of a tensor.
This op computes the inverse of an index permutation. It takes a one-dimensional integer tensor input
, which
represents indices of a zero-based array, and swaps each value with its index position. In other words, for an
output tensor y
and an input tensor x
, this op computes y(x(i)) = i
, for i
in
[0, 1, ..., x.length - 1]
.
For example:
// Tensor 't' is [3, 4, 0, 2, 1] invertPermutation(t) ==> [2, 4, 3, 0, 1]
One-dimensional input tensor.
Result as a new tensor.
The isFinite
op returns a boolean tensor indicating which elements of a tensor are finite-valued.
The isFinite
op returns a boolean tensor indicating which elements of a tensor are finite-valued.
Input tensor.
Result as a new tensor.
The isInf
op returns a boolean tensor indicating which elements of a tensor are Inf-valued.
The isInf
op returns a boolean tensor indicating which elements of a tensor are Inf-valued.
Input tensor.
Result as a new tensor.
The isNaN
op returns a boolean tensor indicating which elements of a tensor are NaN-valued.
The isNaN
op returns a boolean tensor indicating which elements of a tensor are NaN-valued.
Input tensor.
Result as a new tensor.
The l2Loss
op computes half of the L2 norm of a tensor without the square root.
The l2Loss
op computes half of the L2 norm of a tensor without the square root.
The output is equal to sum(input^2) / 2
.
Input tensor.
Result as a new tensor.
The l2Normalize
op normalizes along axes axes
using an L2 norm.
The l2Normalize
op normalizes along axes axes
using an L2 norm.
For a 1-D tensor with axes = 0
, the op computes:
output = x / sqrt(max(sum(x^2), epsilon))
For higher-dimensional x
, the op independently normalizes each 1-D slice along axes axes
.
Input tensor.
Tensor containing the axes along which to normalize.
Lower bound value for the norm. The created op will use sqrt(epsilon)
as the divisor, if
norm < sqrt(epsilon)
.
Result as a new tensor.
OpDocMathLess
OpDocMathLess
First input tensor.
Second input tensor.
Result as a new tensor.
OpDocMathLessEqual
OpDocMathLessEqual
First input tensor.
Second input tensor.
Result as a new tensor.
The linear
op computes x * weights + bias
.
The linear
op computes x * weights + bias
.
Input tensor.
Weights tensor.
Bias tensor.
Result as a new tensor.
The linspace
op generates values in an interval.
The linspace
op generates values in an interval.
The op generates a sequence of numberOfValues
evenly-spaced values beginning at start
. If
numberOfValues > 1
, the values in the sequence increase by (stop - start) / (numberOfValues - 1)
, so that the
last value is exactly equal to stop
.
For example:
linspace(10.0, 12.0, 3) ==> [10.0 11.0 12.0] }} @group MathOps @param start Rank 0 (i.e., scalar) tensor that contains the starting value of the number sequence. @param stop Rank 0 (i.e., scalar) tensor that contains the ending value (inclusive) of the number sequence. @param numberOfValues Rank 0 (i.e., scalar) tensor that contains the number of values in the number sequence. @return Result as a new tensor.
The listDiff
op computes the difference between two lists of numbers or strings.
The listDiff
op computes the difference between two lists of numbers or strings.
Given a list x
and a list y
, the op returns a list out
that represents all values that are in x
but not
in y
. The returned list output
is sorted in the same order that the numbers appear in x
(duplicates are
preserved). The op also returns a list indices
that represents the position of each out
element in x
. In
other words, output(i) = x(indices(i))
, for i
in [0, 1, ..., output.length - 1]
.
For example, given inputs x = [1, 2, 3, 4, 5, 6]
and y = [1, 3, 5]
, this op would return
output = [2, 4, 6]
and indices = [1, 3, 5]
.
One-dimensional tensor containing the values to keep.
One-dimensional tensor containing the values to remove.
Data type to use for the output indices of this op.
Tuple containing output
and indices
, from the method description.
The listDiff
op computes the difference between two lists of numbers or strings.
The listDiff
op computes the difference between two lists of numbers or strings.
Given a list x
and a list y
, the op returns a list out
that represents all values that are in x
but not
in y
. The returned list output
is sorted in the same order that the numbers appear in x
(duplicates are
preserved). The op also returns a list indices
that represents the position of each out
element in x
. In
other words, output(i) = x(indices(i))
, for i
in [0, 1, ..., output.length - 1]
.
For example, given inputs x = [1, 2, 3, 4, 5, 6]
and y = [1, 3, 5]
, this op would return
output = [2, 4, 6]
and indices = [1, 3, 5]
.
One-dimensional tensor containing the values to keep.
One-dimensional tensor containing the values to remove.
Tuple containing output
and indices
, from the method description.
The localResponseNormalization
op treats the input 4-D tensor as a 3-D array of 1-D vectors (along the last
dimension), and each vector is normalized independently.
The localResponseNormalization
op treats the input 4-D tensor as a 3-D array of 1-D vectors (along the last
dimension), and each vector is normalized independently. Within a given vector, each component is divided by the
weighted, squared sum of the inputs within depthRadius
. In detail:
sqrSum[a, b, c, d] = sum(input[a, b, c, d - depthRadius : d + depthRadius + 1] ** 2) output = input / (bias + alpha * sqrSum) ** beta
For details, see Krizhevsky et al., ImageNet Classification with Deep Convolutional Neural Networks (NIPS 2012).
Input tensor.
Half-width of the 1-D normalization window.
Offset (usually positive to avoid dividing by 0).
Scale factor (usually positive).
Exponent.
Created op output.
The log
op computes the logarithm of a tensor element-wise.
The log
op computes the logarithm of a tensor element-wise. I.e., y = \log{x}
.
Input tensor.
Result as a new tensor.
The log1p
op computes the logarithm of a tensor plus 1
element-wise.
The log1p
op computes the logarithm of a tensor plus 1
element-wise. I.e., y = \log{1 + x}
.
Input tensor.
Result as a new tensor.
The logGamma
op computes the logarithm of the absolute value of the Gamma function applied element-wise on a
tensor.
The logGamma
op computes the logarithm of the absolute value of the Gamma function applied element-wise on a
tensor. I.e., y = \log{|\Gamma{x}|}
.
Input tensor.
Result as a new tensor.
The logPoissonLoss
op computes the log-Poisson loss between logPredictions
and targets
.
The logPoissonLoss
op computes the log-Poisson loss between logPredictions
and targets
.
The op computes the log-likelihood loss between the predictions and the targets under the assumption that the
targets have a Poisson distribution. **Caveat:** By default, this is not the exact loss, but the loss minus a
constant term (log(z!)
). That has no effect for optimization purposes, but it does not play well with relative
loss comparisons. To compute an approximation of the log factorial term, please set computeFullLoss
to true
,
to enable Stirling's Approximation.
For brevity, let c = log(x) = logPredictions
, z = targets
. The log-Poisson loss is defined as:
-log(exp(-x) * (xz) / z!)
= -log(exp(-x) * (xz)) + log(z!)~ -log(exp(-x)) - log(x^z) [z * log(z) - z + 0.5 * log(2 * pi * z)]
(Note that the second term is Stirling's
Approximation for
log(z!). It is
invariant to
x and does not affect
optimization, though it is important for
correct relative loss comparisons. It is
only computed when
computeFullLoss == true)
= x - z * log(x) [+ z * log(z) - z + 0.5 * log(2 * pi * z)]
= exp(c) - z * c [+ z * log(z) - z + 0.5 * log(2 * pi * z)].
Tensor containing the log-predictions.
Tensor with the same shape as logPredictions
, containing the target values.
If true
, Stirling's Approximation is used to approximate the full loss. Defaults to
false
, meaning that the constant term is ignored.
Result as a new tensor.
The logSigmoid
op computes the log-sigmoid function element-wise on a tensor.
The logSigmoid
op computes the log-sigmoid function element-wise on a tensor.
Specifically, y = log(1 / (1 + exp(-x)))
. For numerical stability, we use y = -tf.nn.softplus(-x)
.
Input tensor.
Result as a new tensor.
The logSoftmax
op computes log-softmax activations.
The logSoftmax
op computes log-softmax activations.
For each batch i
and class j
we have log_softmax = logits - log(sum(exp(logits), axis))
, where axis
indicates the axis the log-softmax should be performed on.
Tensor containing the logits.
Axis along which to perform the log-softmax. Defaults to -1
denoting the last axis.
Result as a new tensor.
The logSumExp
op computes the log-sum-exp of elements across axes of a tensor.
The logSumExp
op computes the log-sum-exp of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[0, 0, 0], [0, 0, 0]] logSumExp(x) ==> log(6) logSumExp(x, 0) ==> [log(2), log(2), log(2)] logSumExp(x, 1) ==> [log(3), log(3)] logSumExp(x, 1, keepDims = true) ==> [[log(3)], [log(3)]] logSumExp(x, [0, 1]) ==> log(6)
Input tensor to reduce.
Integer sequence containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The logicalAnd
op computes the truth value of x && y
element-wise.
The logicalAnd
op computes the truth value of x && y
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The logicalNot
op computes the truth value of !x
element-wise.
The logicalNot
op computes the truth value of !x
element-wise.
Input tensor.
Result as a new tensor.
The logicalOr
op computes the truth value of x || y
element-wise.
The logicalOr
op computes the truth value of x || y
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The logicalXOr
op computes the truth value of (x || y) && !(x && y)
element-wise.
The logicalXOr
op computes the truth value of (x || y) && !(x && y)
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The localResponseNormalization
op treats the input 4-D tensor as a 3-D array of 1-D vectors (along the last
dimension), and each vector is normalized independently.
The localResponseNormalization
op treats the input 4-D tensor as a 3-D array of 1-D vectors (along the last
dimension), and each vector is normalized independently. Within a given vector, each component is divided by the
weighted, squared sum of the inputs within depthRadius
. In detail:
sqrSum[a, b, c, d] = sum(input[a, b, c, d - depthRadius : d + depthRadius + 1] ** 2) output = input / (bias + alpha * sqrSum) ** beta
For details, see Krizhevsky et al., ImageNet Classification with Deep Convolutional Neural Networks (NIPS 2012).
Input tensor.
Half-width of the 1-D normalization window.
Offset (usually positive to avoid dividing by 0).
Scale factor (usually positive).
Exponent.
Created op output.
The matmul
op multiples two matrices.
The matmul
op multiples two matrices.
The inputs must, following any transpositions, be tensors of rank >= 2, where the inner 2 dimensions specify valid matrix multiplication arguments and any further outer dimensions match.
Note that this op corresponds to a matrix product and not an element-wise product. For example:
output[..., i, j] = sum_k (a[..., i, k] * b[..., k, j])
, for all indices i
and j
.
Both matrices must be of the same data type. The supported types are: BFLOAT16
, FLOAT16
, FLOAT32
,
FLOAT64
, INT32
, COMPLEX64
, and COMPLEX128
.
Either matrix can be transposed and/or conjugated on the fly by setting one of the corresponding flags to
true
. These are set to false
by default.
If one or both of the matrices contain a lot of zeros, a more efficient multiplication algorithm can be used
by setting the corresponding aIsSparse
or bIsSparse
flag to true
. These are also set to false
by
default. This optimization is only available for plain matrices (i.e., rank-2 tensors) with data type
BFLOAT16
or FLOAT32
. The break-even for using this versus a dense matrix multiply on one platform was
30% zero values in the sparse matrix. The gradient computation of the sparse op will only take advantage of
sparsity in the input gradient when that gradient comes from a ReLU.
For example:
// 2-D tensor 'a' is [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] // 2-D tensor 'b' is [[7.0, 8.0], [9.0, 10.0], [11.0, 12.0]] matmul(a, b) ==> [[58.0, 64.0], [139.0, 154.0]] // 3-D tensor 'a' is [[[ 1.0, 2.0, 3.0], // [ 4.0, 5.0, 6.0]], // [[ 7.0, 8.0, 9.0], // [10.0, 11.0, 12.0]]] // 3-D tensor 'b' is [[[13.0, 14.0], // [15.0, 16.0], // [17.0, 18.0]], // [[19.0, 20.0], // [21.0, 22.0], // [23.0, 24.0]]] matmul(a, b) ==> [[[ 94.0, 100.0], [229.0, 244.0]], [[508.0, 532.0], [697.0, 730.0]]]
First input tensor.
Second input tensor.
If true
, a
is transposed before the multiplication.
If true
, b
is transposed before the multiplication.
If true
, a
is conjugated before the multiplication.
If true
, b
is conjugated before the multiplication.
If true
, a
is treated as a sparse matrix (i.e., it is assumed it contains many zeros).
If true
, b
is treated as a sparse matrix (i.e., it is assumed it contains many zeros).
Result as a new tensor.
The matrixBandPart
op copies a tensor, while setting everything outside a central band in each innermost
matrix of the tensor, to zero.
The matrixBandPart
op copies a tensor, while setting everything outside a central band in each innermost
matrix of the tensor, to zero.
Assuming that input
has k
dimensions, [I, J, K, ..., M, N]
, the output is a tensor with the same shape,
where band[i, j, k, ..., m, n] == indicatorBand(m, n) * input[i, j, k, ..., m, n]
. The indicator function is
defined as:
indicatorBand(m, n) = (numSubDiagonals < 0 || m - n <= numSubDiagonals) && (numSuperDiagonals < 0 || n - m <= numSuperDiagonals)
For example:
// 'input' is: // [[ 0, 1, 2, 3] // [-1, 0, 1, 2] // [-2, -1, 0, 1] // [-3, -2, -1, 0]] matrixBandPart(input, 1, -1) ==> [[ 0, 1, 2, 3] [-1, 0, 1, 2] [ 0, -1, 0, 1] [ 0, 0, -1, 0]] matrixBandPart(input, 2, 1) ==> [[ 0, 1, 0, 0] [-1, 0, 1, 0] [-2, -1, 0, 1] [ 0, -2, -1, 0]]
Useful special cases:
matrixBandPart(input, 0, -1) ==> Upper triangular part matrixBandPart(input, -1, 0) ==> Lower triangular part matrixBandPart(input, 0, 0) ==> Diagonal
Input tensor.
Scalar tensor that contains the number of sub-diagonals to keep. If negative, the entire lower triangle is kept.
Scalar tensor that contains the number of super-diagonals to keep. If negative, the entire upper triangle is kept.
Result as a new tensor containing the expected banded tensor and has rank K
and same shape as input
.
The matrixDiag
op returns a batched diagonal tensor with the provided batched diagonal values.
The matrixDiag
op returns a batched diagonal tensor with the provided batched diagonal values.
Given a diagonal
, the op returns a tensor with that diagonal
and everything else padded with zeros. Assuming
that diagonal
has k
dimensions [I, J, K, ..., N]
, the output is a tensor of rank k + 1
with dimensions
[I, J, K, ..., N, N]
, where: output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n]
.
For example:
// 'diagonal' is [[1, 2, 3, 4], [5, 6, 7, 8]] (shape = [2, 4]) matrixDiag(diagonal) ==> [[[1, 0, 0, 0] [0, 2, 0, 0] [0, 0, 3, 0] [0, 0, 0, 4]], [[5, 0, 0, 0] [0, 6, 0, 0] [0, 0, 7, 0] [0, 0, 0, 8]]] // with shape [2, 4, 4]
Rank-K
input tensor, where K >= 1
.
Result as a new tensor with rank equal to K + 1
and shape equal to the shape of diagonal
, with its
last dimension duplicated.
The matrixDiagPart
op returns the batched diagonal part of a batched tensor.
The matrixDiagPart
op returns the batched diagonal part of a batched tensor.
The op returns a tensor with the diagonal
part of the batched input
. Assuming that input
has k
dimensions, [I, J, K, ..., M, N]
, then the output is a tensor of rank k - 1
with dimensions
[I, J, K, ..., min(M, N)]
, where diagonal[i, j, k, ..., n] == input[i, j, k, ..., n, n]
.
Note that input
must have rank of at least 2
.
For example:
// 'input' is: // [[[1, 0, 0, 0] // [0, 2, 0, 0] // [0, 0, 3, 0] // [0, 0, 0, 4]], // [[5, 0, 0, 0] // [0, 6, 0, 0] // [0, 0, 7, 0] // [0, 0, 0, 8]]] with shape [2, 4, 4] matrixDiagPart(input) ==> [[1, 2, 3, 4], [5, 6, 7, 8]] // with shape [2, 4]
Rank-K
tensor, where K >= 2
.
Result as a new tensor containing the diagonal(s) and having shape equal to
input.shape[:-2] + [min(input.shape[-2:])]
.
The matrixSetDiag
op returns a batched matrix tensor with new batched diagonal values.
The matrixSetDiag
op returns a batched matrix tensor with new batched diagonal values.
Given input
and diagonal
, the op returns a tensor with the same shape and values as input
, except for the
main diagonal of its innermost matrices. These diagonals will be overwritten by the values in diagonal
.
Assuming that input
has k + 1
dimensions, [I, J, K, ..., M, N]
, and diagonal
has k
dimensions,
[I, J, K, ..., min(M, N)]
, then the output is a tensor of rank k + 1
with dimensions [I, J, K, ..., M, N]
,
where:
output[i, j, k, ..., m, n] == diagonal[i, j, k, ..., n]
, for m == n
, andoutput[i, j, k, ..., m, n] == input[i, j, k, ..., m, n]
, for m != n
.Rank-K+1
tensor, where K >= 2
.
Rank-K
tensor, where K >= 1
.
Result as a new tensor with rank equal to K + 1
and shape equal to the shape of input
.
The matrixTranpose
op transposes the last two dimensions of tensor input
.
The matrixTranpose
op transposes the last two dimensions of tensor input
.
For example:
// Tensor 'x' is [[1, 2, 3], [4, 5, 6]] matrixTranspose(x) ==> [[1, 4], [2, 5], [3, 6]] // Tensor 'x' has shape [1, 2, 3, 4] matrixTranspose(x).shape ==> [1, 2, 4, 3]
Note that Math.matmul provides named arguments allowing for transposing the matrices involved in the multiplication. This is done with minimal cost, and is preferable to using this function. For example:
matmul(a, b, transposeB = true) // is preferable to: matmul(a, matrixTranspose(b))
Input tensor to transpose.
If true
, then the complex conjugate of the transpose result is returned.
Result as a new tensor.
InvalidShapeException
If the input tensor has rank <= 2.
The max
op computes the maximum of elements across axes of a tensor.
The max
op computes the maximum of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[1.0, 1.0], [2.0, 2.0]] max(x) ==> 2.0 max(x, 0) ==> [2.0, 2.0] max(x, 1) ==> [1.0, 2.0]
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The maxPool
op performs max pooling on the input tensor.
The maxPool
op performs max pooling on the input tensor.
4-D tensor whose dimension order is interpreted according to the value of dataFormat
.
The size of the pooling window for each dimension of the input tensor.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The maxPoolGrad
op computes the gradient of the maxPool
op.
The maxPoolGrad
op computes the gradient of the maxPool
op.
Original input tensor.
Original output tensor.
4-D tensor containing the gradients w.r.t. the output of the max pooling and whose shape
depends on the value of dataFormat
.
The size of the pooling window for each dimension of the input tensor.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The maxPoolGradGrad
op computes the gradient of the maxPoolGrad
op.
The maxPoolGradGrad
op computes the gradient of the maxPoolGrad
op.
Original input tensor.
Original output tensor.
4-D tensor containing the gradients w.r.t. the output of the max pooling and whose shape
depends on the value of dataFormat
.
The size of the pooling window for each dimension of the input tensor.
Stride of the sliding window along the second dimension of input
.
Stride of the sliding window along the third dimension of input
.
Padding mode to use.
Format of the input and output data.
Result as a new 4-D tensor whose dimension order depends on the value of dataFormat
.
The maximum
op returns the element-wise maximum between two tensors.
The maximum
op returns the element-wise maximum between two tensors. I.e., z = x > y ? x : y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The mean
op computes the mean of elements across axes of a tensor.
The mean
op computes the mean of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[1.0, 1.0], [2.0, 2.0]] mean(x) ==> 1.5 mean(x, 0) ==> [1.5, 1.5] mean(x, 1) ==> [1.0, 2.0]
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The min
op computes the minimum of elements across axes of a tensor.
The min
op computes the minimum of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[1.0, 1.0], [2.0, 2.0]] min(x) ==> 1.0 min(x, 0) ==> [1.0, 1.0] min(x, 1) ==> [1.0, 2.0]
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The minimum
op returns the element-wise minimum between two tensors.
The minimum
op returns the element-wise minimum between two tensors. I.e., z = x < y ? x : y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The mod
op computes the remainder of the division between two tensors element-wise.
The mod
op computes the remainder of the division between two tensors element-wise.
The op emulates C semantics in that the result is consistent with a truncating divide.
E.g., truncate(x / y) * y + truncateMod(x, y) = x
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The multiply
op multiplies two tensors element-wise.
The multiply
op multiplies two tensors element-wise. I.e., z = x * y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The negate
op computes the numerical negative value of a tensor element-wise.
The negate
op computes the numerical negative value of a tensor element-wise. I.e., y = -x
.
Input tensor.
Result as a new tensor.
The notEqual
op computes the truth value of x != y
element-wise.
The notEqual
op computes the truth value of x != y
element-wise.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The oneHot
op returns a one-hot tensor.
The oneHot
op returns a one-hot tensor.
The locations represented by indices in indices
take value onValue
, while all other locations take value
offValue
. onValue
and offValue
must have matching data types. If dataType
is also provided, they must be
the same data type as specified by dataType
.
If the input indices
is rank N
, the output will have rank N+1
. The new axis is created at dimension axis
(which defaults to the last axis).
If indices
is a scalar the output shape will be a vector of length depth
.
If indices
is a vector of length features
, the output shape will be:
[features, depth]
, if axis == -1
, and[depth, features]
, if axis == 0
. If indices
is a matrix (batch) with shape [batch, features]
, the output shape will be:
[batch, features, depth]
, if axis == -1
,[batch, depth, features]
, if axis == 1
, and[depth, batch, features]
, if axis == 0
. If dataType
is not provided, the function will attempt to assume the data type of onValue
or offValue
, if
one or both are passed in. If none of onValue
, offValue
, or dataType
are provided, dataType
will default
to the FLOAT32
data type.
Note: If a non-numeric data type output is desired (e.g., STRING
or BOOLEAN
), both onValue
and offValue
**must** be provided to oneHot
.
For example:
// 'indices' = [0, 2, -1, 1] // 'depth' = 3 // 'onValue' = 5.0 // 'offValue' = 0.0 // 'axis' = -1 // The output tensor has shape [4, 3] oneHot(indices, depth, onValue, offValue, axis) ==> [[5.0, 0.0, 0.0], // oneHot(0) [0.0, 0.0, 5.0], // oneHot(2) [0.0, 0.0, 0.0], // oneHot(-1) [0.0, 5.0, 0.0]] // oneHot(1) // 'indices' = [[0, 2], [1, -1]] // 'depth' = 3 // 'onValue' = 1.0 // 'offValue' = 0.0 // 'axis' = -1 // The output tensor has shape [2, 2, 3] oneHot(indices, depth, onValue, offValue, axis) ==> [[[1.0, 0.0, 0.0], // oneHot(0) [0.0, 0.0, 1.0]], // oneHot(2) [[0.0, 1.0, 0.0], // oneHot(1) [0.0, 0.0, 0.0]]] // oneHot(-1)
Tensor containing the indices for the "on" values.
Scalar tensor defining the depth of the one-hot dimension.
Scalar tensor defining the value to fill in the output i
th value, when indices[j] = i
.
Defaults to the value 1
with type dataType
.
Scalar tensor defining the value to fill in the output i
th value, when indices[j] != i
.
Defaults to the value 0
with type dataType
.
Axis to fill. Defaults to -1
, representing the last axis.
Data type of the output tensor. If not provided, the function will attempt to assume the data
type of onValue
or offValue
, if one or both are passed in. If none of onValue
, offValue
,
or dataType
are provided, dataType
will default to the FLOAT32
data type.
Result as a new tensor.
The pad
op pads a tensor with zeros.
The pad
op pads a tensor with zeros.
The op pads input
with values specified by the padding mode, mode
, according to the paddings
you specify.
paddings
is an integer tensor with shape [n, 2]
, where n
is the rank of input
. For each dimension D
of
input
, paddings(D, 0)
indicates how many zeros to add before the contents of input
in that dimension, and
paddings(D, 1)
indicates how many zeros to add after the contents of input
in that dimension.
If mode
is ReflectivePadding then both paddings(D, 0)
and paddings(D, 1)
must be no greater than
input.shape(D) - 1
. If mode
is SymmetricPadding then both paddings(D, 0)
and paddings(D, 1)
must be
no greater than input.shape(D)
.
The padded size of each dimension D
of the output is equal to
paddings(D, 0) + input.shape(D) + paddings(D, 1)
.
For example:
// 'input' = [[1, 2, 3], [4, 5, 6]] // 'paddings' = [[1, 1], [2, 2]] pad(input, paddings, ConstantPadding(0)) ==> [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 2, 3, 0, 0], [0, 0, 4, 5, 6, 0, 0], [0, 0, 0, 0, 0, 0, 0]] pad(input, paddings, ReflectivePadding) ==> [[6, 5, 4, 5, 6, 5, 4], [3, 2, 1, 2, 3, 2, 1], [6, 5, 4, 5, 6, 5, 4], [3, 2, 1, 2, 3, 2, 1]] pad(input, paddings, SymmetricPadding) ==> [[2, 1, 1, 2, 3, 3, 2], [2, 1, 1, 2, 3, 3, 2], [5, 4, 4, 5, 6, 6, 5], [5, 4, 4, 5, 6, 6, 5]]
Input tensor to be padded.
Tensor containing the paddings.
Padding mode to use.
Result as a new tensor.
The parallelStack
op stacks a list of rank-R
tensors into one rank-(R+1)
tensor, in parallel.
The parallelStack
op stacks a list of rank-R
tensors into one rank-(R+1)
tensor, in parallel.
The op packs the list of tensors in inputs
into a tensor with rank one higher than each tensor in inputs
, by
packing them along the first dimension. Given a list of N
tensors of shape [A, B, C]
, the output tensor will
have shape [N, A, B, C]
.
For example:
// 'x' is [1, 4] // 'y' is [2, 5] // 'z' is [3, 6] parallelStack(Array(x, y, z)) ==> [[1, 4], [2, 5], [3, 6]]
The op requires that the shape of all input tensors is known at graph construction time.
The difference between stack
and parallelStack
is that stack
requires all of the inputs be computed before
the operation will begin executing, but does not require that the input shapes be known during graph
construction. parallelStack
will copy pieces of the input into the output as they become available. In some
situations this can provide a performance benefit.
Input tensors to be stacked.
Result as a new tensor.
The polygamma
op computes the polygamma function \psi^{(n)}(x)
.
The polygamma
op computes the polygamma function \psi^{(n)}(x)
.
The polygamma function is defined as:
\psi{(n)}(x) = \frac{dn}{dx^n} \psi(x)
, where
\psi(x) is the digamma function.
First input tensor.
Second input tensor.
Result as a new tensor.
The pow
op computes the power of one tensor raised to another, element-wise.
The pow
op computes the power of one tensor raised to another, element-wise.
Given a tensor x
and a tensor y
, the op computes x^y
for the corresponding elements in
x
and
y.
For example:
// Tensor 'x' is [[2, 2], [3, 3]] // Tensor 'y' is [[8, 16], [2, 3]] pow(x, y) ==> [[256, 65536], [9, 27]]
First input tensor.
Second input tensor.
Result as a new tensor.
The preventGradient
op triggers an error if a gradient is requested.
The preventGradient
op triggers an error if a gradient is requested.
When executed in a graph, this op outputs its input tensor as-is.
When building ops to compute gradients, the TensorFlow gradient system ill return an error when trying to lookup the gradient of this op, because no gradient must ever be registered for this function. This op exists to prevent subtle bugs from silently returning unimplemented gradients in some corner cases.
Input tensor.
Message to print along with the error.
Result as a new tensor which has the same value as the input tensor.
The prod
op computes the product of elements across axes of a tensor.
The prod
op computes the product of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[1, 1, 1]], [1, 1, 1]] prod(x) ==> 1 prod(x, 0) ==> [1, 1, 1] prod(x, 1) ==> [1, 1] prod(x, 1, keepDims = true) ==> [[1], [1]] prod(x, [0, 1]) ==> 1
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The randomNormal
op outputs random values drawn from a Normal distribution.
The randomNormal
op outputs random values drawn from a Normal distribution.
The generated values follow a Normal distribution with mean mean
and standard deviation standardDeviation
.
Data type for the output tensor.
Rank-1 tensor containing the shape of the output tensor. Defaults to a scalar tensor.
Scalar tensor containing the mean of the Normal distribution. Defaults to 0
.
Scalar tensor containing the standard deviation of the Normal distribution. Defaults to
1
.
Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.
Result as a new tensor.
The randomShuffle
op randomly shuffles a tensor along its first axis.
The randomShuffle
op randomly shuffles a tensor along its first axis.
The tensor is shuffled along axis 0
, such that each value(j)
is mapped to one and only one output(i)
. For
example, a mapping that might occur for a 3x2 tensor is:
[[1, 2], [[5, 6], [3, 4], ==> [1, 2], [5, 6]] [3, 4]]
Tensor to be shuffled.
Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.
Result as a new tensor.
The randomTruncatedNormal
op outputs random values drawn from a truncated Normal distribution.
The randomTruncatedNormal
op outputs random values drawn from a truncated Normal distribution.
The generated values follow a Normal distribution with mean mean
and standard deviation standardDeviation
,
except that values whose magnitude is more than two standard deviations from the mean are dropped and resampled.
Data type for the output tensor.
Rank-1 tensor containing the shape of the output tensor. Defaults to a scalar tensor.
Scalar tensor containing the mean of the Normal distribution. Defaults to 0
.
Scalar tensor containing the standard deviation of the Normal distribution. Defaults to
1
.
Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.
Result as a new tensor.
The randomUniform
op outputs random values drawn from a uniform distribution.
The randomUniform
op outputs random values drawn from a uniform distribution.
The generated values follow a uniform distribution in the range [minValue, maxValue)
. The lower bound
minValue
is included in the range, while the upper bound maxValue
is not.
In the integer case, the random integers are slightly biased unless maxValue - minValue
is an exact power of
two. The bias is small for values of maxValue - minValue
significantly smaller than the range of the output
(either 232
, depending on the data type). or
264
Data type for the output tensor.
Rank-1 tensor containing the shape of the output tensor. Defaults to a scalar tensor.
Scalar tensor containing the inclusive lower bound on the random of random values to generate.
Defaults to 0
.
Scalar tensor containing the exclusive upper bound on the random of random values to generate.
Defaults to 1
.
Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.
Result as a new tensor.
The range
op constructs a sequence of numbers.
The range
op constructs a sequence of numbers.
The op creates a sequence of numbers that begins at start
and extends by increments of delta
up to but not
including limit
. The data type of the resulting tensor is inferred from the inputs unless it is provided
explicitly.
For example:
// 'start' is 3 // 'limit' is 18 // 'delta' is 3 range(start, limit, delta) ==> [3, 6, 9, 12, 15] // 'start' is 3 // 'limit' is 1 // 'delta' is -0.5 range(start, limit, delta) ==> [3.0, 2.5, 2.0, 1.5]
Rank 0 (i.e., scalar) tensor that contains the starting value of the number sequence.
Rank 0 (i.e., scalar) tensor that contains the ending value (exclusive) of the number sequence.
Rank 0 (i.e., scalar) tensor that contains the difference between consecutive numbers in the sequence.
Result as a new tensor.
The rank
op returns the rank of a tensor.
The rank
op returns the rank of a tensor.
The op returns an integer representing the rank of input
.
For example:
// 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] // 't' has shape [2, 2, 3] rank(t) ==> 3
Note that the rank of a tensor is not the same as the rank of a matrix. The rank of a tensor is the number of indices required to uniquely select each element of the tensor. Rank is also known as order, degree, or number of dimensions.
Tensor whose rank to return.
Result as a new tensor.
The realDivide
op divides two real tensors element-wise.
The realDivide
op divides two real tensors element-wise.
If x
and y
are real-valued tensors, the op will return the floating-point division.
I.e., z = x / y
, for x
and y
being real tensors.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The reciprocal
op computes the reciprocal value of a tensor element-wise.
The reciprocal
op computes the reciprocal value of a tensor element-wise. I.e., y = 1 / x
.
Input tensor.
Result as a new tensor.
The relu
op computes the rectified linear unit activation function.
The relu
op computes the rectified linear unit activation function.
The rectified linear unit activation function is defined as relu(x) = max(x, 0)
.
Input tensor.
Slope of the negative section, also known as leakage parameter. If other than 0.0f
, the negative
part will be equal to alpha * x
instead of 0
. Defaults to 0
.
Result as a new tensor.
The relu6
op computes the rectified linear unit 6 activation function.
The relu6
op computes the rectified linear unit 6 activation function.
The rectified linear unit 6 activation function is defined as relu6(x) = min(max(x, 0), 6)
.
Source: [Convolutional Deep Belief Networks on CIFAR-10. A. Krizhevsky](http://www.cs.utoronto.ca/~kriz/conv-cifar10-aug2010.pdf)
Input tensor.
Result as a new tensor.
The requiredSpaceToBatchPaddingsAndCrops
op calculates the paddings and crops required to make blockShape
divide inputShape
.
The requiredSpaceToBatchPaddingsAndCrops
op calculates the paddings and crops required to make blockShape
divide inputShape
.
This function can be used to calculate a suitable paddings
/crops
argument for use with the
spaceToBatchND/batchToSpaceND functions.
The returned tensors, paddings
and crops
satisfy:
paddings(i, 0) == basePaddings(i, 0)
,0 <= paddings(i, 1) - basePaddings(i, 1) < blockShape(i)
,(inputShape(i) + paddings(i, 0) + paddings(i, 1)) % blockShape(i) == 0
,crops(i, 0) == 0
, andcrops(i, 1) == paddings(i, 1) - basePaddings(i, 1)
.Tensor with shape [N]
.
Tensor with shape [N]
.
Optional tensor with shape [N, 2]
that specifies the minimum amount of padding to use. All
elements must be non-negative. Defaults to a tensor containing all zeros.
Tuple containing the paddings and crops required.
InvalidShapeException
If inputShape
, blockShape
, or basePaddings
, has invalid shape.
The reshape
op reshapes a tensor.
The reshape
op reshapes a tensor.
Given input
, the op returns a tensor that has the same values as input
but has shape shape
. If one
component of shape
is the special value -1
, then the size of that dimension is computed so that the total
size remains constant. In particular, a shape
of [-1]
flattens a tensor into a one-dimensional tensor. At
most one component of shape
can be set to -1
.
If shape
is a one-dimensional or higher tensor, then the operation returns a tensor with shape shape
filled
with the values of input
. In this case, the number of elements implied by shape
must be the same as the
number of elements in input
.
For example:
// Tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9] => It has shape [9] reshape(t, [3, 3]) ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9]] // Tensor 't' is [[[1, 1], [2, 2]], // [[3, 3], [4, 4]]] => It has shape [2, 2, 2] reshape(t, [2, 4] ==> [[1, 1, 2, 2], [3, 3, 4, 4]] // Tensor 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]], [[5, 5, 5], [6, 6, 6]]] => It has shape [3, 2, 3] reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6] // '-1' can also be used to infer the shape. Some examples follow. // '-1' is inferred to be 9: reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]] // '-1' is inferred to be 2: reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]] // '-1' is inferred to be 3: reshape(t, [ 2, -1, 3]) ==> [[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]] // Tensor 't' is [7] // An empty shape passed to 'reshape' will result in a scalar reshape(t, []) ==> 7
Input tensor.
Shape of the output tensor.
Result as a new tensor.
The reverse
op reverses specific dimensions of a tensor.
The reverse
op reverses specific dimensions of a tensor.
Given an input
tensor, and an integer array of axes representing the set of dimensions of input
to reverse,
this op reverses each dimension i
of input
, for which there exists j
such that axes(j) == i
.
input
can have up to 8 dimensions. The number of dimensions specified in axes
may be 0 or more entries. If
an index is specified more than once, an 'InvalidArgument' error will be raised.
For example:
// Tensor 't' is [[[[ 0, 1, 2, 3], // [ 4, 5, 6, 7], // [ 8, 9, 10, 11]], // [[12, 13, 14, 15], // [16, 17, 18, 19], // [20, 21, 22, 23]]]] => It has shape [1, 2, 3, 4] // 'axes' is [3] or [-1] reverse(t, axes) ==> [[[[ 3, 2, 1, 0], [ 7, 6, 5, 4], [ 11, 10, 9, 8]], [[15, 14, 13, 12], [19, 18, 17, 16], [23, 22, 21, 20]]]] // 'axes' is [1] or [-3] reverse(t, axes) ==> [[[[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]], [[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]]] // 'axes' is [2] or [-2] reverse(t, axes) ==> [[[[ 8, 9, 10, 11], [ 4, 5, 6, 7], [ 0, 1, 2, 3]], [[20, 21, 22, 23], [16, 17, 18, 19], [12, 13, 14, 15]]]]
Input tensor to reverse. It must have rank at most 8.
Dimensions of the input tensor to reverse.
Result as a new tensor which has the same shape as input
.
The reverseSequence
op reverses variable length slices.
The reverseSequence
op reverses variable length slices.
The op first slices input
along the dimension batchAxis
, and for each slice i
, it reverses the first
sequenceLengths(i)
elements along the dimension sequenceAxis
.
The elements of sequenceLengths
must obey sequenceLengths(i) <= input.shape(sequenceAxis)
, and it must be a
vector of length input.shape(batchAxis)
.
The output slice i
along dimension batchAxis
is then given by input slice i
, with the first
sequenceLengths(i)
slices along dimension sequenceAxis
reversed.
For example:
// Given: // sequenceAxis = 1 // batchAxis = 0 // input.shape = [4, 8, ...] // sequenceLengths = [7, 2, 3, 5] // slices of 'input' are reversed on 'sequenceAxis', but only up to 'sequenceLengths': output(0, 0::7, ---) == input(0, 6::-1::, ---) output(1, 0::2, ---) == input(1, 1::-1::, ---) output(2, 0::3, ---) == input(2, 2::-1::, ---) output(3, 0::5, ---) == input(3, 4::-1::, ---) // while entries past 'sequenceLengths' are copied through: output(0, 7::, ---) == input(0, 7::, ---) output(1, 7::, ---) == input(1, 7::, ---) output(2, 7::, ---) == input(2, 7::, ---) output(3, 7::, ---) == input(3, 7::, ---) // In contrast, given: // sequenceAxis = 0 // batchAxis = 2 // input.shape = [8, ?, 4, ...] // sequenceLengths = [7, 2, 3, 5] // slices of 'input' are reversed on 'sequenceAxis', but only up to 'sequenceLengths': output(0::7, ::, 0, ---) == input(6::-1::, ::, 0, ---) output(0::2, ::, 1, ---) == input(1::-1::, ::, 1, ---) output(0::3, ::, 2, ---) == input(2::-1::, ::, 2, ---) output(0::5, ::, 3, ---) == input(4::-1::, ::, 3, ---) // while entries past 'sequenceLengths' are copied through: output(7::, ::, 0, ---) == input(7::, ::, 0, ---) output(2::, ::, 1, ---) == input(2::, ::, 1, ---) output(3::, ::, 2, ---) == input(3::, ::, 2, ---) output(5::, ::, 3, ---) == input(5::, ::, 3, ---)
Input tensor to reverse.
One-dimensional tensor with length input.shape(batchAxis)
and
max(sequenceLengths) <= input.shape(sequenceAxis)
.
Tensor dimension which is partially reversed.
Tensor dimension along which the reversal is performed.
Result as a new tensor which has the same shape as input
.
The round
op computes the round value of a tensor element-wise.
The round
op computes the round value of a tensor element-wise.
Rounds half to even. Also known as bankers rounding. If you want to round according to the current system rounding mode use the roundInt op instead.
For example:
// 'a' is [0.9, 2.5, 2.3, 1.5, -4.5] round(a) ==> [1.0, 2.0, 2.0, 2.0, -4.0]
Input tensor.
Result as a new tensor.
The roundInt
op computes the round value of a tensor element-wise.
The roundInt
op computes the round value of a tensor element-wise.
If the result is midway between two representable values, the even representable is chosen.
For example:
roundInt(-1.5) ==> -2.0 roundInt(0.5000001) ==> 1.0 roundInt([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) ==> [-2., -2., -0., 0., 2., 2., 2.]
Input tensor.
Result as a new tensor.
The rsqrt
op computes the reciprocal of the square root of a tensor element-wise.
The rsqrt
op computes the reciprocal of the square root of a tensor element-wise. I.e.,
y = 1 / \sqrt{x} = 1 / x^{1/2}
.
Input tensor.
Result as a new tensor.
The scalarMul
op multiplies a scalar tensor with another, potentially sparse, tensor.
The scalarMul
op multiplies a scalar tensor with another, potentially sparse, tensor.
This function is intended for use in gradient code which might deal with OutputIndexedSlices objects, which are easy to multiply by a scalar but more expensive to multiply with arbitrary tensors.
Scalar tensor.
Tensor to multiply the scalar tensor with.
Result as a new tensor.
The scatterND
op scatters updates
into a new (initially zero-valued) tensor, according to indices
.
The scatterND
op scatters updates
into a new (initially zero-valued) tensor, according to indices
.
The op creates a new tensor by applying sparse updates
to individual values or slices within a zero-valued
tensor of the given shape
, according to indices. It is the inverse of the gatherND op, which extracts
values or slices from a given tensor.
WARNING: The order in which the updates are applied is non-deterministic, and so the output will be
non-deterministic if indices
contains duplicates.
indices
is an integer tensor containing indices into a new tensor of shape shape
. The last dimension of
indices
can be at most the rank of shape
: indices.shape(-1) <= shape.rank
. The last dimension of indices
corresponds to indices into elements (if indices.shape(-1) == shape.rank
) or slices (if
indices.shape(-1) < shape.rank
) along dimension indices.shape(-1)
of shape
.
updates
is a tensor with shape indices.shape(::-1) + shape(indices.shape(-1)::)
.
The simplest form of scatter is to insert individual elements in a tensor by index. For example, say we want to
insert 4
scattered elements in a rank-1
tensor with 8
elements.
In Scala, this scatter operation would look like this:
val indices = constant(Tensor(Tensor(4), Tensor(3), Tensor(1), Tensor(7))) val updates = constant(Tensor(9, 10, 11, 12)) val shape = constant(Tensor(8)) scatterND(indices, updates, shape) ==> [0, 11, 0, 10, 9, 0, 0, 12]
We can also, insert entire slices of a higher rank tensor all at once. For example, say we want to insert two
slices in the first dimension of a rank-3
tensor with two matrices of new values.
In Scala, this scatter operation would look like this:
val indices = constant(Tensor(Tensor(0), Tensor(2))) val updates = constant(Tensor(Tensor(Tensor(5, 5, 5, 5), Tensor(6, 6, 6, 6), Tensor(7, 7, 7, 7), Tensor(8, 8, 8, 8)) Tensor(Tensor(5, 5, 5, 5), Tensor(6, 6, 6, 6), Tensor(7, 7, 7, 7), Tensor(8, 8, 8, 8)))) val shape = constant(Tensor(4, 4, 4)) scatterND(indices, updates, shape) ==> [[[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]]
Indices tensor.
Updates to scatter into the output tensor.
One-dimensional tensor specifying the shape of the output tensor.
Result as a new tensor.
The segmentMax
op computes the max along segments of a tensor.
The segmentMax
op computes the max along segments of a tensor.
The op computes a tensor such that output(i) = \max_{j...} data(j,...)
where the max is over all j
such that segmentIndices(j) == i
. Unlike unsortedSegmentMax
, segmentIndices
need be sorted.
If the max if empty for a given segment index i
, output(i)
is set to 0
.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices. Values should be sorted and can be repeated.
Result as a new tensor.
The segmentMean
op computes the mean along segments of a tensor.
The segmentMean
op computes the mean along segments of a tensor.
The op computes a tensor such that output(i) = \frac{sum_{j...} data(j,...)}{N}
where the sum is over
all j
such that segmentIndices(j) == i
and N
is the total number of values being summed. Unlike
unsortedSegmentMean
, segmentIndices
need to be sorted.
If the sum if empty for a given segment index i
, output(i)
is set to 0
.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices. Values should be sorted and can be repeated.
Result as a new tensor.
The segmentMin
op computes the min along segments of a tensor.
The segmentMin
op computes the min along segments of a tensor.
The op computes a tensor such that output(i) = \min_{j...} data(j,...)
where the min is over all j
such that segmentIndices(j) == i
. Unlike unsortedSegmentMin
, segmentIndices
need be sorted.
If the min if empty for a given segment index i
, output(i)
is set to 0
.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices. Values should be sorted and can be repeated.
Result as a new tensor.
The segmentProd
op computes the product along segments of a tensor.
The segmentProd
op computes the product along segments of a tensor.
The op computes a tensor such that output(i) = \prod_{j...} data(j,...)
where the product is over all j
such that segmentIndices(j) == i
. Unlike unsortedSegmentProd
, segmentIndices
need be sorted.
If the product if empty for a given segment index i
, output(i)
is set to 1
.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices. Values should be sorted and can be repeated.
Result as a new tensor.
The segmentSum
op computes the sum along segments of a tensor.
The segmentSum
op computes the sum along segments of a tensor.
The op computes a tensor such that output(i) = \sum_{j...} data(j,...)
where the sum is over all j
such
that segmentIndices(j) == i
. Unlike unsortedSegmentSum
, segmentIndices
need be sorted.
If the sum if empty for a given segment index i
, output(i)
is set to 0
.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices. Values should be sorted and can be repeated.
Result as a new tensor.
The select
op selects elements from x
or y
, depending on condition
.
The select
op selects elements from x
or y
, depending on condition
.
The x
, and y
tensors must have the same shape. The output tensor will also have the same shape.
The condition
tensor must be a scalar if x
and y
are scalars. If x
and y
are vectors or higher rank,
then condition
must be either a scalar, or a vector with size matching the first dimension of x
, or it must
have the same shape as x
.
The condition
tensor acts as a mask that chooses, based on the value at each element, whether the
corresponding element / row in the output should be taken from x
(if true) or y
(if false).
If condition
is a vector and x
and y
are higher rank matrices, then it chooses which row (outer dimension)
to copy from x
and y
. If condition
has the same shape as x
and y
, then it chooses which element to
copy from x
and y
.
For example:
// 'condition' tensor is [[true, false], [false, true]] // 'x' is [[1, 2], [3, 4]] // 'y' is [[5, 6], [7, 8]] select(condition, x, y) ==> [[1, 6], [7, 4]] // 'condition' tensor is [true, false] // 'x' is [[1, 2], [3, 4]] // 'y' is [[5, 6], [7, 8]] select(condition, x, y) ==> [[1, 2], [7, 8]]
Boolean condition tensor.
Tensor which may have the same shape as condition
. If condition
has rank 1
, then t
may
have a higher rank, but its first dimension must match the size of condition
.
Tensor with the same data type and shape as t
.
Result as a new tensor.
The selu
op computes the scaled exponential linear unit activation function.
The selu
op computes the scaled exponential linear unit activation function.
The scaled exponential linear unit activation function is defined as selu(x) = scale * x
, if x > 0
, and
elu(x) = scale * alpha * (exp(x) - 1)
, otherwise, where scale = 1.0507
and alpha = 1.7581
.
Source: [Self-Normalizing Neural Networks](https://arxiv.org/abs/1706.02515)
Input tensor.
Result as a new tensor.
The sequenceLoss
op computes an optionally weighted loss for a sequence of predicted logits.
The sequenceLoss
op computes an optionally weighted loss for a sequence of predicted logits.
Depending on the values of averageAcrossTimeSteps
and averageAcrossBatch
, the returned tensor will have rank
0, 1, or 2 as these arguments reduce the cross-entropy each label, which has shape
[batchSize, sequenceLength]
, over their respective dimensions. For examplem if averageAcrossTimeSteps
is
true
and averageAcrossBatch
is false
, then the returned tensor will have shape [batchSize]
.
Tensor of shape [batchSize, sequenceLength, numClasses]
containing unscaled log
probabilities.
Tensor of shape [batchSize, sequenceLength]
containing the true label at each
time step.
Optionally, a tensor of shape [batchSize, sequenceLength]
containing weights to
use for each prediction. When using weights
as masking, set all valid time steps
to 1 and all padded time steps to 0 (e.g., a mask returned by tf.sequenceMask
).
If true
, the loss is summed across the sequence dimension and divided by the
total label weight across all time steps.
If true
, the loss is summed across the batch dimension and divided by the batch
size.
Loss function to use that takes the predicted logits and the true labels as inputs
and returns the loss value. Defaults to sparseSoftmaxCrossEntropy
.
Result as a new tensor.
InvalidShapeException
If any of logits
, labels
, or weights
has invalid shape.
The sequenceMask
op returns a mask tensor representing the first N
positions of each row of a matrix.
The sequenceMask
op returns a mask tensor representing the first N
positions of each row of a matrix.
For example:
// 'lengths' = [1, 3, 2] // 'maxLength' = 5 sequenceMask(lengths, maxLength) ==> [[true, false, false, false, false], [true, true, true, false, false], [true, true, false, false, false]]
One-dimensional integer tensor containing the lengths to keep for each row. If maxLength
is
provided, then all values in lengths
must be smaller than maxLength
.
Scalar integer tensor representing the maximum length of each row. Defaults to the maximum value
in lengths
.
Result as a new tensor.
IllegalArgumentException
If maxLength
is not a scalar.
The shape
op returns the shape of a tensor.
The shape
op returns the shape of a tensor.
The op returns a one-dimensional tensor representing the shape of input
.
For example:
// 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] shape(t) ==> [2, 2, 3]
Tensor whose shape to return.
Optional data type to use for the output of this op.
Result as a new tensor.
The shape
op returns the shape of a tensor.
The shape
op returns the shape of a tensor.
The op returns a one-dimensional tensor representing the shape of input
.
For example:
// 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] shape(t) ==> [2, 2, 3]
Tensor whose shape to return.
Result as a new tensor.
The shapeN
op returns the shape of an array of tensors.
The shapeN
op returns the shape of an array of tensors.
The op returns an array of one-dimensional tensors, each one representing the shape of the corresponding tensor
in inputs
.
Tensors whose shapes to return.
Optional data type to use for the outputs of this op.
Result as a sequence of new tensors.
The shapeN
op returns the shape of an array of tensors.
The shapeN
op returns the shape of an array of tensors.
The op returns an array of one-dimensional tensors, each one representing the shape of the corresponding tensor
in inputs
.
Tensors whose shapes to return.
Result as a sequence of new tensors.
The sigmoid
op computes the sigmoid function element-wise on a tensor.
The sigmoid
op computes the sigmoid function element-wise on a tensor.
Specifically, y = 1 / (1 + exp(-x))
.
Input tensor.
Result as a new tensor.
The sigmoidCrossEntropy
op computes the sigmoid cross entropy between logits
and labels
.
The sigmoidCrossEntropy
op computes the sigmoid cross entropy between logits
and labels
.
The op measures the probability error in discrete classification tasks in which each class is independent and not mutually exclusive. For instance, one could perform multi-label classification where a picture can contain both an elephant and a dog at the same time.
For brevity, let x = logits
and z = labels
. The sigmoid cross entropy (also known as logistic loss) is
defined as:
z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x))
= (1 - z) * x + log(1 + exp(-x))
= x - x * z + log(1 + exp(-x))
For x < 0
, to avoid numerical overflow in exp(-x)
, we reformulate the above to:
x - x * z + log(1 + exp(-x))
= log(exp(x)) - x * z + log(1 + exp(-x))
= - x * z + log(1 + exp(x))
Hence, to ensure stability and avoid numerical overflow, the implementation uses this equivalent formulation:
max(x, 0) - x * z + log(1 + exp(-abs(x)))
If weights
is not null
, then the positive examples are weighted. A value weights > 1
decreases the false
negative count, hence increasing recall. Conversely setting weights < 1
decreases the false positive count and
increases precision. This can be seen from the fact that weight
is introduced as a multiplicative coefficient
for the positive targets term in the loss expression (where q = weights
, for brevity):
qz * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= qz * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x)))
= qz * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x)))
= qz * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x))
= (1 - z) * x + (qz + 1 - z) * log(1 + exp(-x))
= (1 - z) * x + (1 + (q - 1) * z) * log(1 + exp(-x))
Setting l = 1 + (q - 1) * z
, to ensure stability and avoid numerical overflow, the implementation uses this
equivalent formulation:
(1 - z) * x + l * (max(-x, 0) + log(1 + exp(-abs(x))))
logits
and labels
must have the same shape.
Tensor of shape [D0, D1, ..., Dr-1, numClasses]
, containing unscaled log probabilities.
Tensor of shape [D0, D1, ..., Dr-1, numClasses]]
, where each row must be a valid probability
distribution.
Optionally, a coefficient to use for the positive examples.
Result as a new tensor, with rank one less than that of logits
and the same data type as logits
,
containing the sigmoid cross entropy loss.
The sign
op computes an element-wise indication of the sign of a tensor.
The sign
op computes an element-wise indication of the sign of a tensor.
I.e., y = sign(x) = -1
if x < 0
; 0
if x == 0
; 1
if x > 0
.
Zero is returned for NaN
inputs.
For complex numbers, y = sign(x) = x / |x|
if x != 0
, otherwise y = 0
.
Input tensor.
Result as a new tensor.
The sin
op computes the sine of a tensor element-wise.
The sin
op computes the sine of a tensor element-wise. I.e., y = \sin{x}
.
Input tensor.
Result as a new tensor.
The sinh
op computes the hyperbolic sine of a tensor element-wise.
The sinh
op computes the hyperbolic sine of a tensor element-wise. I.e., y = \sinh{x}
.
Input tensor.
Result as a new tensor.
The size
op returns the size of a tensor.
The size
op returns the size of a tensor.
The op returns a number representing the number of elements in input
.
For example:
// 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]] size(t) ==> 12
Tensor whose size to return.
Optional data type to use for the output of this op.
Result as a new tensor.
The size
op returns the size of a tensor.
The size
op returns the size of a tensor.
The op returns a number representing the number of elements in input
.
For example:
// 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]] size(t) ==> 12
Tensor whose size to return.
Result as a new tensor.
The softmax
op computes softmax activations.
The softmax
op computes softmax activations.
For each batch i
and class j
we have softmax = exp(logits) / sum(exp(logits), axis)
, where axis
indicates the axis the softmax should be performed on.
Tensor containing the logits.
Axis along which to perform the softmax. Defaults to -1
denoting the last axis.
Result as a new tensor.
The softmaxCrossEntropy
op computes the softmax cross entropy between logits
and labels
.
The softmaxCrossEntropy
op computes the softmax cross entropy between logits
and labels
.
The op measures the probabilistic error in discrete classification tasks in which the classes are mutually exclusive (each entry belongs to exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
Back-propagation will happen into both logits
and labels
. To disallow back-propagation into labels
, pass
the label tensors through a stopGradients
op before feeding it to this function.
NOTE: While the classes are mutually exclusive, their probabilities need not be. All that is required is
that each row of labels
is a valid probability distribution. If they are not, the computation of the gradient
will be incorrect. If using exclusive labels
(wherein one and only one class is true at a time), see
sparseSoftmaxCrossEntropy.
WARNING: The op expects unscaled logits, since it performs a softmax
on logits
internally for
efficiency. Do not call this op with the output of softmax
, as it will produce incorrect results.
logits
and labels
must have the same shape. A common use case if to have logits
and labels
of shape
[batchSize, numClasses]
, but higher dimensions are also supported.
logits
and labels
must have data type FLOAT16, FLOAT32, or FLOAT64.
Tensor of shape [D0, D1, ..., Dr-1, numClasses]
, containing unscaled log probabilities.
Tensor of shape [D0, D1, ..., Dr-1, numClasses]
, where each row must be a valid probability
distribution.
The class axis, along which the softmax is computed. Defaults to -1
, which is the last axis.
Result as a new tensor, with rank one less than that of logits
and the same data type as logits
,
containing the softmax cross entropy loss.
The softplus
op computes the softplus activation function.
The softplus
op computes the softplus activation function.
The softplus activation function is defined as softplus(x) = log(exp(x) + 1)
.
Input tensor.
Result as a new tensor.
The softsign
op computes the softsign activation function.
The softsign
op computes the softsign activation function.
The softsign activation function is defined as softsign(x) = x / (abs(x) + 1)
.
Input tensor.
Result as a new tensor.
The spaceToBatch
op zero-pads and then rearranges (permutes) blocks of spatial data into batches.
The spaceToBatch
op zero-pads and then rearranges (permutes) blocks of spatial data into batches.
More specifically, the op outputs a copy of the input tensor where values from the height
and width
dimensions are moved to the batch
dimension. After the zero-padding, both height
and width
of the input
must be divisible by blockSize
(which must be greater than 1
). This is the reverse functionality to that of
batchToSpace.
input
is a 4
-dimensional input tensor with shape [batch, height, width, depth]
.
paddings
has shape [2, 2]
. It specifies the padding of the input with zeros across the spatial dimensions as
follows: paddings = padBottom], [padLeft, padRight
. The effective spatial dimensions of the
zero-padded input tensor will be:
heightPad = padTop + height + padBottom
widthPad = padLeft + width + padRight
blockSize
indicates the block size:
blockSize x blockSize
in the height and width dimensions are rearranged
into the batch dimension at each location.batch * blockSize * blockSize
.heightPad
and widthPad
must be divisible by blockSize
. The shape of the output will be:
[batch * blockSize * blockSize, heightPad / blockSize, widthPad / blockSize, depth]
Some examples:
// === Example #1 === // input = [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // blockSize = 2 // paddings = [[0, 0], [0, 0]] spaceToBatch(input, blockSize, paddings) ==> [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] (shape = [4, 1, 1, 1]) // === Example #2 === // input = [[[[1, 2, 3], [4, 5, 6]], // [[7, 8, 9], [10, 11, 12]]]] (shape = [1, 2, 2, 3]) // blockSize = 2 // paddings = [[0, 0], [0, 0]] spaceToBatch(input, blockSize, paddings) ==> [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [4, 1, 1, 3]) // === Example #3 === // input = [[[[ 1], [2], [3], [ 4]], // [[ 5], [6], [7], [ 8]], // [[ 9], [10], [11], [12]], // [[13], [14], [15], [16]]]] (shape = [1, 4, 4, 1]) // blockSize = 2 // paddings = [[0, 0], [0, 0]] spaceToBatch(input, blockSize, paddings) ==> [[[[1], [3]], [[ 9], [11]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] (shape = [4, 2, 2, 1]) // === Example #4 === // input = [[[[ 1], [2], [3], [ 4]], // [[ 5], [6], [7], [ 8]]], // [[[ 9], [10], [11], [12]], // [[13], [14], [15], [16]]]] (shape = [2, 2, 4, 1]) // blockSize = 2 // paddings = [[0, 0], [2, 0]] spaceToBatch(input, blockSize, paddings) ==> [[[[0], [1], [3]]], [[[0], [ 9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] (shape = [8, 1, 3, 1])
4
-dimensional input tensor with shape [batch, height, width, depth]
.
Block size which must be greater than 1
.
2
-dimensional tensor containing non-negative integers with shape [2, 2]
.
Result as a new tensor.
The spaceToBatchND
op divides "spatial" dimensions [1, ..., M]
of input
into a grid of blocks with shape
blockShape
, and interleaves these blocks with the "batch" dimension (0
) such that, in the output, the
spatial dimensions [1, ..., M]
correspond to the position within the grid, and the batch dimension combines
both the position within a spatial block and the original batch position.
The spaceToBatchND
op divides "spatial" dimensions [1, ..., M]
of input
into a grid of blocks with shape
blockShape
, and interleaves these blocks with the "batch" dimension (0
) such that, in the output, the
spatial dimensions [1, ..., M]
correspond to the position within the grid, and the batch dimension combines
both the position within a spatial block and the original batch position. Prior to division into blocks, the
spatial dimensions of the input are optionally zero padded according to paddings
. This is the reverse
functionality to that of batchToSpaceND.
input
is an N
-dimensional tensor with shape inputShape = [batch] + spatialShape + remainingShape
, where
spatialShape
has M
dimensions.
The op is equivalent to the following steps:
paddedShape
.
2. Reshape padded
to reshapedPadded
of shape:[batch] + [[paddedShape(1) / blockShape(0), blockShape(0), ..., paddedShape(M) / blockShape(M-1), blockShape(M-1)]` + remainingShape
3. Permute the dimensions of reshapedPadded
to produce permutedReshapedPadded
of shape:
blockShape + [batch] + [paddedShape(1) / blockShape(0), ..., paddedShape(M) / blockShape(M-1)] + remainingShape
4. Reshape permutedReshapedPadded
to flatten blockShape
into the batch dimension, producing an output
tensor of shape:
[batch * product(blockShape)] + [paddedShape(1) / blockShape(0), ..., paddedShape(M) / blockShape(M-1)] + remainingShape
Among others, this op is useful for reducing atrous convolution to regular convolution.
Some examples:
// === Example #1 === // input = [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // blockShape = [2, 2] // paddings = [[0, 0], [0, 0]] spaceToBatchND(input, blockShape, paddings) ==> [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] (shape = [4, 1, 1, 1]) // === Example #2 === // input = [[[[1, 2, 3], [4, 5, 6]], // [[7, 8, 9], [10, 11, 12]]]] (shape = [1, 2, 2, 3]) // blockShape = [2, 2] // paddings = [[0, 0], [0, 0]] spaceToBatchND(input, blockShape, paddings) ==> [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [4, 1, 1, 3]) // === Example #3 === // input = [[[[ 1], [2], [3], [ 4]], // [[ 5], [6], [7], [ 8]], // [[ 9], [10], [11], [12]], // [[13], [14], [15], [16]]]] (shape = [1, 4, 4, 1]) // blockShape = [2, 2] // paddings = [[0, 0], [0, 0]] spaceToBatchND(input, blockShape, paddings) ==> [[[[1], [3]], [[ 9], [11]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] (shape = [4, 2, 2, 1]) // === Example #4 === // input = [[[[ 1], [2], [3], [ 4]], // [[ 5], [6], [7], [ 8]]], // [[[ 9], [10], [11], [12]], // [[13], [14], [15], [16]]]] (shape = [2, 2, 4, 1]) // blockShape = [2, 2] // paddings = [[0, 0], [2, 0]] spaceToBatchND(input, blockShape, paddings) ==> [[[[0], [1], [3]]], [[[0], [ 9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] (shape = [8, 1, 3, 1])
N
-dimensional tensor with shape inputShape = [batch] + spatialShape + remainingShape
, where
spatialShape has M
dimensions.
One-dimensional tensor with shape [M]
whose elements must all be >= 1
.
Two-dimensional tensor with shape [M, 2]
whose elements must all be non-negative.
paddings(i) = [padStart, padEnd]
specifies the padding for input dimension i + 1
, which
corresponds to spatial dimension i
. It is required that blockShape(i)
divides
inputShape(i + 1) + padStart + padEnd
.
Result as a new tensor.
The spaceToDepth
op that rearranges blocks of spatial data, into depth.
The spaceToDepth
op that rearranges blocks of spatial data, into depth.
More specifically, the op outputs a copy of the input tensor where values from the height
and width
dimensions are moved to the depth
dimension. blockSize
indicates the input block size and how the data is
moved:
blockSize x blockSize
in the height and width dimensions are rearranged
into the depth dimension at each location.inputDepth * blockSize * blockSize
.height
and width
must be divisible by blockSize
. That is, assuming that input
is in the shape [batch, height, width, depth]
, the shape of the output will be:
[batch, height / blockSize, width / blockSize, depth * block_size * block_size]
.
This op is useful for resizing the activations between convolutions (but keeping all data), e.g., instead of pooling. It is also useful for training purely convolutional models.
Some examples:
// === Example #1 === // input = [[[[1], [2]], [[3], [4]]]] (shape = [1, 2, 2, 1]) // blockSize = 2 spaceToDepth(input, blockSize) ==> [[[[1, 2, 3, 4]]]] (shape = [1, 1, 1, 4]) // === Example #2 === // input = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] (shape = [1, 2, 2, 3]) // blockSize = 2 spaceToDepth(input, blockSize) ==> [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]] (shape = [1, 1, 1, 12]) // === Example #3 === // input = [[[[ 1], [ 2], [ 5], [ 6]], // [[ 3], [ 4], [ 7], [ 8]], // [[ 9], [10], [13], [14]], // [[11], [12], [15], [16]]]] (shape = [1, 4, 4, 1]) // blockSize = 2 spaceToDepth(input, blockSize) ==> [[[[ 1, 2, 3, 4], [ 5, 6, 7, 8]], [[ 9, 10, 11, 12], [13, 14, 15, 16]]]] (shape = [1, 2, 2, 4])
4
-dimensional input tensor with shape [batch, height, width, depth]
.
Block size which must be greater than 1
.
Format of the input and output data.
Result as a new tensor.
The sparseSegmentMean
op computes the mean along sparse segments of a tensor.
The sparseSegmentMean
op computes the mean along sparse segments of a tensor.
The op is similar to that of segmentMean, with the difference that segmentIndices
can have rank less
than data
's first dimension, selecting a subset of dimension 0
, specified by indices
. segmentIndices
is
allowed to have missing indices, in which case the output will be zeros at those indices. In those cases,
numSegments
is used to determine the size of the output.
For example:
// 'c' is [[1, 2, 3, 4], [-1, -2, -3, -4], [5, 6, 7, 8]] // Select two rows, one segment. sparseSegmentMean(c, Tensor(0, 1), Tensor(0, 0)) ==> [[0, 0, 0, 0]] // Select two rows, two segments. sparseSegmentMean(c, Tensor(0, 1), Tensor(0, 1)) ==> [[1, 2, 3, 4], [-1, -2, -3, -4]] // Select all rows, two segments. sparseSegmentMean(c, Tensor(0, 1, 2), Tensor(0, 0, 1)) ==> [[0, 0, 0, 0], [5, 6, 7, 8]] // which is equivalent to: segmentMean(c, Tensor(0, 0, 1))
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
One-dimensional tensor with rank equal to that of segmentIndices
.
Segment indices. Values should be sorted and can be repeated.
Optional scalar indicating the size of the output tensor.
Result as a new tensor.
The sparseSegmentSum
op computes the sum along sparse segments of a tensor.
The sparseSegmentSum
op computes the sum along sparse segments of a tensor.
The op is similar to that of segmentSum, with the difference that segmentIndices
can have rank less
than data
's first dimension, selecting a subset of dimension 0
, specified by indices
. segmentIndices
is
allowed to have missing indices, in which case the output will be zeros at those indices. In those cases,
numSegments
is used to determine the size of the output.
For example:
// 'c' is [[1, 2, 3, 4], [-1, -2, -3, -4], [5, 6, 7, 8]] // Select two rows, one segment. sparseSegmentSum(c, Tensor(0, 1), Tensor(0, 0)) ==> [[0, 0, 0, 0]] // Select two rows, two segments. sparseSegmentSum(c, Tensor(0, 1), Tensor(0, 1)) ==> [[1, 2, 3, 4], [-1, -2, -3, -4]] // Select all rows, two segments. sparseSegmentSum(c, Tensor(0, 1, 2), Tensor(0, 0, 1)) ==> [[0, 0, 0, 0], [5, 6, 7, 8]] // which is equivalent to: segmentSum(c, Tensor(0, 0, 1))
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
One-dimensional tensor with rank equal to that of segmentIndices
.
Segment indices. Values should be sorted and can be repeated.
Optional scalar indicating the size of the output tensor.
Result as a new tensor.
The sparseSegmentSumSqrtN
op computes the sum along sparse segments of a tensor, divided by the square
root of the number of elements being summed.
The sparseSegmentSumSqrtN
op computes the sum along sparse segments of a tensor, divided by the square
root of the number of elements being summed. segmentIndices
is allowed to have missing indices, in which case
the output will be zeros at those indices. In those cases, numSegments
is used to determine the size of the
output.
Similar to sparseSegmentSum.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
One-dimensional tensor with rank equal to that of segmentIndices
.
Segment indices. Values should be sorted and can be repeated.
Optional scalar indicating the size of the output tensor.
Result as a new tensor.
The sparseSoftmaxCrossEntropy
op computes the sparse softmax cross entropy between logits
and labels
.
The sparseSoftmaxCrossEntropy
op computes the sparse softmax cross entropy between logits
and labels
.
The op measures the probabilistic error in discrete classification tasks in which the classes are mutually exclusive (each entry belongs to exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
NOTE: For the op, the probability of a given label is considered exclusive. That is, soft classes are not
allowed, and the labels
vector must provide a single specific index for the true class for each row of
logits
(i.e., each batch instance). For soft softmax classification with a probability distribution for each
entry, see softmaxCrossEntropy.
WARNING: The op expects unscaled logits, since it performs a softmax
on logits
internally for
efficiency. Do not call this op with the output of softmax
, as it will produce incorrect results.
A common use case if to have logits
of shape [batchSize, numClasses]
and labels
of shape [batchSize]
,
but higher dimensions are also supported.
logits
must have data type FLOAT16, FLOAT32, or FLOAT64, and labels
must have data type
INT32 or INT64.
Tensor of shape [D0, D1, ..., Dr-1, numClasses]
(where r
is the rank of labels
and of the
result), containing unscaled log probabilities.
Tensor of shape [D0, D1, ..., Dr-1]
(where r
is the rank of labels
and of the result). Each
entry in labels
must be an index in [0, numClasses)
. Other values will raise an exception when
this op is run on a CPU, and return NaN
values for the corresponding loss and gradient rows when
this op is run on a GPU.
The class axis, along which the softmax is computed. Defaults to -1
, which is the last axis.
Result as a new tensor, with the same shape as labels
and the same data type as logits
, containing the
softmax cross entropy loss.
The split
op splits a tensor into sub-tensors.
The split
op splits a tensor into sub-tensors.
The op splits input
along dimension axis
into splitSizes.length
smaller tensors. The shape of the i
-th
smaller tensor has the same size as the input
except along dimension axis
where the size is equal to
splitSizes(i)
.
For example:
// 't' is a tensor with shape [5, 30] // Split 't' into 3 tensors with sizes [4, 5, 11] along dimension 1: val splits = split(t, splitSizes = [4, 15, 11], axis = 1) splits(0).shape ==> [5, 4] splits(1).shape ==> [5, 15] splits(2).shape ==> [5, 11]
Input tensor to split.
Sizes for the splits to obtain.
Dimension along which to split the input tensor.
Result as a new tensor.
The splitEvenly
op splits a tensor into sub-tensors.
The splitEvenly
op splits a tensor into sub-tensors.
The op splits input
along dimension axis
into numSplits
smaller tensors. It requires that numSplits
evenly splits input.shape(axis)
.
For example:
// 't' is a tensor with shape [5, 30] // Split 't' into 3 tensors along dimension 1: val splits = split(t, numSplits = 3, axis = 1) splits(0).shape ==> [5, 10] splits(1).shape ==> [5, 10] splits(2).shape ==> [5, 10]
Input tensor to split.
Number of splits to obtain along the axis
dimension.
Dimension along which to split the input tensor.
Result as a sequence of new tensors.
The sqrt
op computes the square root of a tensor element-wise.
The sqrt
op computes the square root of a tensor element-wise. I.e., y = \sqrt{x} = x^{1/2}
.
Input tensor.
Result as a new tensor.
The square
op computes the square of a tensor element-wise.
The square
op computes the square of a tensor element-wise. I.e., y = x * x = x^2
.
Input tensor.
Result as a new tensor.
The squaredDifference
op computes the squared difference between two tensors element-wise.
The squaredDifference
op computes the squared difference between two tensors element-wise.
I.e., z = (x - y) * (x - y)
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The squeeze
op removes dimensions of size 1 from the shape of a tensor and returns the result as a new tensor.
The squeeze
op removes dimensions of size 1 from the shape of a tensor and returns the result as a new tensor.
Given a tensor input
, the op returns a tensor of the same data type, with all dimensions of size 1 removed.
If axes
is specified, then only the dimensions specified by that array will be removed. In that case, all
these dimensions need to have size 1.
For example:
// 't' is a tensor of shape [1, 2, 1, 3, 1, 1] t.squeeze().shape == Shape(2, 3) t.squeeze(Array(2, 4)).shape == Shape(1, 2, 3, 1)
Input tensor.
Dimensions of size 1 to squeeze. If this argument is not provided, then all dimensions of size 1 will be squeezed.
Result as a new tensor.
The stack
op stacks a list of rank-R
tensors into one rank-(R+1)
tensor.
The stack
op stacks a list of rank-R
tensors into one rank-(R+1)
tensor.
The op packs the list of tensors in inputs
into a tensor with rank one higher than each tensor in inputs
, by
packing them along the axis
dimension. Given a list of N
tensors of shape [A, B, C]
:
axis == 0
, then the output tensor will have shape [N, A, B, C]
.axis == 1
, then the output tensor will have shape [A, N, B, C]
.axis == -1
, then the output tensor will have shape [A, B, C, N]
.For example:
// 'x' is [1, 4] // 'y' is [2, 5] // 'z' is [3, 6] stack(Array(x, y, z)) ==> [[1, 4], [2, 5], [3, 6]] // Packed along the first dimension. stack(Array(x, y, z), axis = 1) ==> [[1, 2, 3], [4, 5, 6]] // Packed along the second dimension.
This op is the opposite of unstack
.
Input tensors to be stacked.
Dimension along which to stack the input tensors.
Result as a new tensor.
The stopGradient
op stops gradient execution, but otherwise acts as an identity op.
The stopGradient
op stops gradient execution, but otherwise acts as an identity op.
When executed in a graph, this op outputs its input tensor as-is.
When building ops to compute gradients, this op prevents the contribution of its inputs to be taken into account. Normally, the gradient generator adds ops to a graph to compute the derivatives of a specified 'loss' by recursively finding out inputs that contributed to its computation. If you insert this op in the graph its inputs are masked from the gradient generator. They are not taken into account for computing gradients.
This is useful any time you want to compute a value with TensorFlow but need to pretend that the value was a constant. Some examples include:
Input tensor.
Result as a new tensor which has the same value as the input tensor.
The subtract
op subtracts two tensors element-wise.
The subtract
op subtracts two tensors element-wise. I.e., z = x - y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The sum
op computes the sum of elements across axes of a tensor.
The sum
op computes the sum of elements across axes of a tensor.
Reduces input
along the axes given in axes
. Unless keepDims
is true
, the rank of the tensor is reduced
by 1 for each entry in axes
. If keepDims
is true
, the reduced axes are retained with size 1.
If axes
is null
, then all axes are reduced, and a tensor with a single element is returned.
For example:
// 'x' is [[1, 1, 1]], [1, 1, 1]] sum(x) ==> 6 sum(x, 0) ==> [2, 2, 2] sum(x, 1) ==> [3, 3] sum(x, 1, keepDims = true) ==> [[3], [3]] sum(x, [0, 1]) ==> 6
Input tensor to reduce.
Integer tensor containing the axes to reduce. If null
, then all axes are reduced.
If true
, retain the reduced axes.
Result as a new tensor.
The tan
op computes the tangent of a tensor element-wise.
The tan
op computes the tangent of a tensor element-wise. I.e., y = \tan{x}
.
Input tensor.
Result as a new tensor.
The tanh
op computes the hyperbolic tangent of a tensor element-wise.
The tanh
op computes the hyperbolic tangent of a tensor element-wise. I.e., y = \tanh{x}
.
Input tensor.
Result as a new tensor.
Dynamic version (i.e., where axesA
and axesB
may be tensors) of the tensorDot
op.
Dynamic version (i.e., where axesA
and axesB
may be tensors) of the tensorDot
op.
The tensorDot
op computes the tensor contraction of two tensors along the specified axes.
A tensor contraction sums the product of elements from a
and b
over the indices specified by axesA
and
axesB
. The axis axesA(i)
of a
must have the same dimension as the axis axesB(i)
of b
for all i
in
[0, aAxes.size)
. The tensors/sequences (depending on whether the dynamic version of the op is being used)
axesA
and axesB
must have identical length and consist of unique integers that specify valid axes for each
of the tensors. This operation corresponds to numpy.tensordot(a, b, axes)
in Python.
If numAxes
is provided instead of axesA
and axesB
, then the contraction is performed over the last
numAxes
axes of a
and the first numAxes
axes of b
, in order.
Example 1: When a
and b
are matrices (rank 2), the case numAxes = 1
is equivalent to matrix
multiplication.
Example 2: When a
and b
are matrices (rank 2), the case axesA = [1]
and axesB = [0]
is equivalent to
matrix multiplication.
Example 3: Suppose that a_{ijk}
and b_{lmn}
represent two tensors of rank 3. Then, the case axesA = [0]
and axesB = [2]
results in the rank 4 tensor c_{jklm}
whose entry corresponding to the indices
(j, k, l, m)
is given by: c_{jklm} = \sum_i a_{ijk} b_{lmi}
. In general,
rank(result) = rank(a) + rank(b) - 2 * axesA.size
.
First tensor.
Second tensor.
Axes to contract in a
.
Axes to contract in b
.
Created op output.
InvalidShapeException
If axesA
or axesB
is not a scalar.
Dynamic version (i.e., where numAxes
may be a tensor) of the tensorDot
op.
Dynamic version (i.e., where numAxes
may be a tensor) of the tensorDot
op.
The tensorDot
op computes the tensor contraction of two tensors along the specified axes.
A tensor contraction sums the product of elements from a
and b
over the indices specified by axesA
and
axesB
. The axis axesA(i)
of a
must have the same dimension as the axis axesB(i)
of b
for all i
in
[0, aAxes.size)
. The tensors/sequences (depending on whether the dynamic version of the op is being used)
axesA
and axesB
must have identical length and consist of unique integers that specify valid axes for each
of the tensors. This operation corresponds to numpy.tensordot(a, b, axes)
in Python.
If numAxes
is provided instead of axesA
and axesB
, then the contraction is performed over the last
numAxes
axes of a
and the first numAxes
axes of b
, in order.
Example 1: When a
and b
are matrices (rank 2), the case numAxes = 1
is equivalent to matrix
multiplication.
Example 2: When a
and b
are matrices (rank 2), the case axesA = [1]
and axesB = [0]
is equivalent to
matrix multiplication.
Example 3: Suppose that a_{ijk}
and b_{lmn}
represent two tensors of rank 3. Then, the case axesA = [0]
and axesB = [2]
results in the rank 4 tensor c_{jklm}
whose entry corresponding to the indices
(j, k, l, m)
is given by: c_{jklm} = \sum_i a_{ijk} b_{lmi}
. In general,
rank(result) = rank(a) + rank(b) - 2 * axesA.size
.
First tensor.
Second tensor.
Number of axes to contract.
Created op output.
InvalidShapeException
If numAxes
is not a scalar.
The tile
op tiles the provided input tensor.
The tile
op tiles the provided input tensor.
The op creates a new tensor by replicating input
multiples
times. The output tensor's i
th dimension has
input.shape(i) * multiples(i)
elements, and the values of input
are replicated multiples(i)
times along
the i
th dimension. For example, tiling [a b c d]
by [2]
produces [a b c d a b c d]
.
Tensor to tile.
One-dimensional tensor containing the tiling multiples. Its length must be the same as the rank
of input
.
Result as a new tensor.
The topK
op finds values and indices of the k
largest entries for the last dimension of input
.
The topK
op finds values and indices of the k
largest entries for the last dimension of input
.
If input
is a vector (i.e., rank-1 tensor), the op finds the k
largest entries in the vector and outputs
their values and their indices as vectors. Thus, values(j)
will be the j
-th largest entry in input
, and
indices(j)
will be its index.
For matrices (and respectively, higher rank input tensors), the op computes the top k
entries in each row
(i.e., vector along the last dimension of the tensor). Thus,
values.shape = indices.shape = input.shape(0 :: -1) + k
.
If two elements are equal, the lower-index element appears first.
Input tensor whose last axis has size at least k
.
Scalar tensor containing the number of top elements to look for along the last axis of input
.
If true
, the resulting k
elements will be sorted by their values in descending order.
Tuple containing the created tensors: (i) values
: the k
largest elements along each last
dimensional slice, and (ii) indices
: the indices of values
within the last axis of input
.
The trace
op computes the trace of a tensor.
The trace
op computes the trace of a tensor.
The trace of a tensor is defined as the sum along the main diagonal of each inner-most matrix in it.
If the tensor is of rank k
with shape [I, J, K, ..., L, M, N]
, then output is a tensor of rank
k - 2
with dimensions [I, J, K, ..., L]
where:
output[i, j, k, ..., l] = trace(x[i, j, i, ..., l, :, :])
.
For example:
// 'x' is [[1, 2], [3, 4]] trace(x) ==> 5 // 'x' is [[1, 2, 3], [4, 5, 6], [7, 8, 9]] trace(x) ==> 15 // 'x' is [[[ 1, 2, 3], // [ 4, 5, 6], // [ 7, 8, 9]], // [[-1, -2, -3], // [-4, -5, -6], // [-7, -8, -9]]] trace(x) ==> [15, -15]
Input tensor.
Result as a new tensor.
The transpose
op permutes the dimensions of a tensor according to a provided permutation.
The transpose
op permutes the dimensions of a tensor according to a provided permutation.
The returned tensor's dimension i
will correspond to input
dimension permutation(i)
. If permutation
is
not provided, then it is set to (n - 1, ..., 0)
, where n
is the rank of the input tensor. Hence by default,
the op performs a regular matrix transpose on two-dimensional input tensors.
For example:
// Tensor 'x' is [[1, 2, 3], [4, 5, 6]] transpose(x) ==> [[1, 4], [2, 5], [3, 6]] transpose(x, permutation = Array(1, 0)) ==> [[1, 4], [2, 5], [3, 6]] // Tensor 'x' is [[[1, 2, 3], // [4, 5, 6]], // [[7, 8, 9], // [10, 11, 12]]] transpose(x, permutation = Array(0, 2, 1)) ==> [[[1, 4], [2, 5], [3, 6]], [[7, 10], [8, 11], [9, 12]]]
Input tensor to transpose.
Permutation of the input tensor dimensions.
If true
, then the complex conjugate of the transpose result is returned.
Result as a new tensor.
The truncateDivide
op truncate-divides two tensors element-wise.
The truncateDivide
op truncate-divides two tensors element-wise.
Truncation designates that negative numbers will round fractional quantities toward zero. I.e. -7 / 5 = 1
.
This matches C semantics but it is different than Python semantics. See floorDivide
for a division function
that matches Python semantics.
I.e., z = x / y
, for x
and y
being integer tensors.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The truncateMod
op computes the remainder of the division between two tensors element-wise.
The truncateMod
op computes the remainder of the division between two tensors element-wise.
The op emulates C semantics in that the result here is consistent with a truncating divide.
E.g., truncate(x / y) * y + truncateMod(x, y) = x
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
The unique
op finds unique elements in a one-dimensional tensor.
The unique
op finds unique elements in a one-dimensional tensor.
The op returns a tensor output
containing all of the unique elements of input
sorted in the same order that
they occur in input
. This op also returns a tensor indices
the same size as input
that contains the
index of each value of input
in the unique output output
. In other words output(indices(i)) = input(i)
,
for i
in [0, 1, ..., input.rank - 1]
.
For example:
// Tensor 't' is [1, 1, 2, 4, 4, 4, 7, 8, 8] val (output, indices) = unique(t) // 'output' is [1, 2, 4, 7, 8] // 'indices' is [0, 0, 1, 2, 2, 2, 3, 4, 4]
One-dimensional input tensor.
Data type of the returned indices.
Tuple containing output
and indices
.
The unique
op finds unique elements in a one-dimensional tensor.
The unique
op finds unique elements in a one-dimensional tensor.
The op returns a tensor output
containing all of the unique elements of input
sorted in the same order that
they occur in input
. This op also returns a tensor indices
the same size as input
that contains the
index of each value of input
in the unique output output
. In other words output(indices(i)) = input(i)
,
for i
in [0, 1, ..., input.rank - 1]
.
For example:
// Tensor 't' is [1, 1, 2, 4, 4, 4, 7, 8, 8] val (output, indices) = unique(t) // 'output' is [1, 2, 4, 7, 8] // 'indices' is [0, 0, 1, 2, 2, 2, 3, 4, 4]
One-dimensional input tensor.
Tuple containing output
and indices
.
The uniqueWithCounts
finds unique elements in a one-dimensional tensor.
The uniqueWithCounts
finds unique elements in a one-dimensional tensor.
The op returns a tensor output
containing all of the unique elements of input
sorted in the same order that
they occur in input
. This op also returns a tensor indices
the same size as input
that contains the
index of each value of input
in the unique output output
. Finally, it returns a third tensor counts
that
contains the count of each element of output
in input
.
For example:
// Tensor 't' is [1, 1, 2, 4, 4, 4, 7, 8, 8] val (output, indices, counts) = uniqueWithCounts(t) // 'output' is [1, 2, 4, 7, 8] // 'indices' is [0, 0, 1, 2, 2, 2, 3, 4, 4] // 'counts' is [2, 1, 3, 1, 2]
One-dimensional input tensor.
Data type of the returned indices.
Tuple containing output
, indices
, and counts
.
The uniqueWithCounts
finds unique elements in a one-dimensional tensor.
The uniqueWithCounts
finds unique elements in a one-dimensional tensor.
The op returns a tensor output
containing all of the unique elements of input
sorted in the same order that
they occur in input
. This op also returns a tensor indices
the same size as input
that contains the
index of each value of input
in the unique output output
. Finally, it returns a third tensor counts
that
contains the count of each element of output
in input
.
For example:
// Tensor 't' is [1, 1, 2, 4, 4, 4, 7, 8, 8] val (output, indices, counts) = uniqueWithCounts(t) // 'output' is [1, 2, 4, 7, 8] // 'indices' is [0, 0, 1, 2, 2, 2, 3, 4, 4] // 'counts' is [2, 1, 3, 1, 2]
One-dimensional input tensor.
Tuple containing output
, indices
, and counts
.
The unsortedSegmentMax
op computes the max along segments of a tensor.
The unsortedSegmentMax
op computes the max along segments of a tensor.
The op computes a tensor such that output(i) = \max_{j...} data(j...)
where the max is over all j
such that segmentIndices(j) == i
. Unlike segmentMax
, segmentIndices
need not be sorted and need not
cover all values in the full range of valid values.
If the max if empty for a given segment index i
, output(i)
is set to 0
.
segmentsNumber
should equal the number of distinct segment indices.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices.
Number of segments.
Result as a new tensor.
The unsortedSegmentSum
op computes the sum along segments of a tensor.
The unsortedSegmentSum
op computes the sum along segments of a tensor.
The op computes a tensor such that output(i) = \sum_{j...} data(j...)
where the sum is over all j
such that segmentIndices(j) == i
. Unlike segmentSum
, segmentIndices
need not be sorted and need not
cover all values in the full range of valid values.
If the sum if empty for a given segment index i
, output(i)
is set to 0
.
segmentsNumber
should equal the number of distinct segment indices.
The result tensor has the same data type as data
, but its first dimension size is equal to the number of
distinct segment indices.
Data (must have a numeric data type -- i.e., representing a number).
Segment indices.
Number of segments.
Result as a new tensor.
The unstack
op unpacks the provided dimension of a rank-R
tensor into a list of rank-(R-1)
tensors.
The unstack
op unpacks the provided dimension of a rank-R
tensor into a list of rank-(R-1)
tensors.
The op unpacks number
tensors from input
by chipping it along the axis
dimension. If number == -1
(i.e.,
unspecified), its value is inferred from the shape of input
. If input.shape(axis)
is not known, then an
IllegalArgumentException is thrown.
For example, given a tensor of shape [A, B, C, D]
:
axis == 0
, then the i
th tensor in the output is the slice input(i, ::, ::, ::)
and each tensor in the
output will have shape [B, C, D]
.axis == 1
, then the i
th tensor in the output is the slice input(::, i, ::, ::)
and each tensor in the
output will have shape [A, C, D]
.axis == -1
, then the i
th tensor in the output is the slice input(::, ::, ::, i)
and each tensor in
the output will have shape [A, B, C]
. This op is the opposite of stack
.
Rank R > 0
Tensor
to be unstacked.
Number of tensors to unstack. If set to -1
(the default value), its value will be inferred.
Dimension along which to unstack the input tensor.
Result as a sequence of new tensors.
The where
op returns locations of true
values in a boolean tensor.
The where
op returns locations of true
values in a boolean tensor.
The op returns the coordinates of true elements in input
. The coordinates are returned in a 2-D tensor where
the first dimension (rows) represents the number of true elements, and the second dimension (columns) represents
the coordinates of the true elements. Note that the shape of the output tensor can vary depending on how many
true values there are in input
. Indices are output in row-major order.
For example:
// 'input' tensor is [[true, false] // [true, false]] // 'input' has two 'true' values and so the output has two coordinates // 'input' has rank 2 and so each coordinate has two indices where(input) ==> [[0, 0], [1, 0]] // `input` tensor is [[[true, false] // [true, false]] // [[false, true] // [false, true]] // [[false, false] // [false, true]]] // 'input' has 5 'true' values and so the output has 5 coordinates // 'input' has rank 3 and so each coordinate has three indices where(input) ==> [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1], [2, 1, 1]]
Input boolean tensor.
Result as a new tensor.
The zerosFraction
op computes the fraction of zeros in input
.
The zerosFraction
op computes the fraction of zeros in input
.
If input
is empty, the result is NaN
.
This is useful in summaries to measure and report sparsity.
Input tensor.
Result as a new tensor.
The zeta
op computes the Hurwitz zeta function \zeta(x, q)
.
The zeta
op computes the Hurwitz zeta function \zeta(x, q)
.
The Hurwitz zeta function is defined as:
\zeta(x, q) = \sum_{n=0}{\infty} (q + n){-x}
.
First input tensor.
Second input tensor.
Result as a new tensor.
The floorDivide
op floor-divides two tensors element-wise.
The floorDivide
op floor-divides two tensors element-wise. I.e., z = x // y
.
NOTE: This op supports broadcasting. More information about broadcasting can be found [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
First input tensor.
Second input tensor.
Result as a new tensor.
(Since version 0.1) Use truncateDivide
instead.