Multiplies all slices of Tensor
x
and y
(each slice can be
viewed as an element of a batch), and arranges the individual results
in a single output tensor of the same batch size.
BucketizedCol operation represents discretized dense input.
BucketizedCol operation represents discretized dense input.
The Operation can handle single or multi feature column, as long as the boundaries is same between feature columns.
Buckets include the left boundary, and exclude the right boundary. Namely, boundaries=Array(0, 1, 10) generates buckets (-inf,0),[0,1),[1,10),[10,+inf)
For example, boundaries = Array(0, 10, 100) and input tensor is an 2D 3x2 DenseTensor: -1, 1 101, 10 5, 100
the output tensor should be an 2D 3x2 DenseTensor 0, 1 3, 2 1, 3
Numeric type. Parameter tensor numeric type. Only support float/double now
Casts a tensor to a new type.
Casts a tensor to a new type.
Parameter tensor numeric type. Only support float/double now
A new type was cast to
CategoricalColHashBucket operation can convert feature string to a Sparse/Dense Tensor
CategoricalColHashBucket operation can convert feature string to a Sparse/Dense Tensor
SparseTensor if isSparse = true DenseTensor if isSparse = false
the input is a Tensor[String] with shape batch * 1.
This operation distributes your inputs into a finite number of buckets by hashing
The Operation support the feature column with single-value or multi-value
The output_id = Hash(input_feature_string) % hashBucketSize, ranging 0 to hashBucketSize-1
The missing values in input Tensor can be represented by -1 for int and ' for string
Numeric type. Parameter tensor numeric type. Only support float/double now
CategoricalColVocaList operation having an vocabulary mapping feature string to Integer ID
CategoricalColVocaList operation having an vocabulary mapping feature string to Integer ID
By default, out-of-vocabulary values are ignored. Use either (but not both) of num_oov_buckets and default_value to specify how to include out-of-vocabulary values.
if isSetDefault=false && num_oov_buckets=0 the out-of-vocabulary values will be filtered. if isSetDefault enabled, the defalut value len(vocabulary_list) will be set. if num_oov_buckets enabled, all out-of-vocabulary inputs will be assigned IDs in the range [len(vocabulary_list), len(vocabulary_list)+num_oov_buckets) based on a hash of the input value
A positive num_oov_buckets can not be specified with default_value.
the input Tensor[String] can be 1-D or 2-D Tensor.
The Operation support the feature column with single-value or multi-value
The missing values in input Tensor can be represented by -1 for int and ' for string
Numeric type. Parameter tensor numeric type. Only support float/double now
CrossCol operation preforms crosses of categorical features.
CrossCol operation preforms crosses of categorical features.
The transformation can be thought of as Hash(cartesian product of features) % hashBucketSize)
The input Table contains more than or equal to 2 Tensor[String]. Each Tensor[String] represents a categorical feature column. Each row in Tensor[String] represents the string of value, which supports single-value and multi-value joined by strDelimiter.
As for the SparseTensor, it should be transformed to Tensor[String] before feeding into the Operation
For example, if the two input tensors with size=3 are: "A,D", "B", "A,C" "1", "2", "3,4"
the output tensor should be an 2D 3 x maxLength SparseTensor: [0, 0]: Hash32("1", Hash32("D")) % hashBucketSize [0, 1]: Hash32("1", Hash32("A")) % hashBucketSize [1, 0]: Hash32("2", Hash32("B")) % hashBucketSize [2, 0]: Hash32("3", Hash32("C")) % hashBucketSize [2, 1]: Hash32("4", Hash32("C")) % hashBucketSize [2, 2]: Hash32("3", Hash32("A")) % hashBucketSize [2, 3]: Hash32("4", Hash32("A")) % hashBucketSize
Numeric type. Parameter tensor numeric type. Only support float/double now
Compute the cross entropy loss and the gradients.
Compute the cross entropy loss and the gradients.
Numeric type. Only support float/double now
Computes the grayscale dilation of 4-D input
and 3-D filter
tensors.
Computes the grayscale dilation of 4-D input
and 3-D filter
tensors.
This layer takes a Table of two tensors as inputs, namely input
and filter
.
The input
tensor has shape [batch, in_height, in_width, depth]
and the filter
tensor has shape [filter_height, filter_width, depth]
, i.e., each input channel is
processed independently of the others with its own structing fucntion. The output
tensor
has shape [batch, out_height, out_width, depth]
. The spatial dimensions of the output
tensor depend on the padding
algorithm. We currently only support the "NHWC" DataFormat.
In detail, the grayscale morphological 2-D dilation is the max-sum correlation
output[b, y, x, c] = max_{dy, dx} input[b, strides[1] * y + rates[1] * dy, strides[2] * x + rates[2] * dx, c] + filter[dy, dx, c]
Max-pooling is a special case when the filter has size equal to the pooling kernel size and contains all zeros.
Note on duality: The dilation of input
by the filter
is equal to the negation of the
erosion of -input
by the reflected filter
.
Gather slices from first input tensor according to the second input tensor.
Gather slices from first input tensor according to the second input tensor. Input should be two tensors, the first one is the tensor which to gather values; the second one is Index tensor.
Indicator operation represents multi-hot representation of given Tensor.
Indicator operation represents multi-hot representation of given Tensor.
The Input Tensor should be a 2-D Sparse Tensor. And used to transform the output tensor of CategoricalCol* ops.
The output tensor should be a DenseTensor with shape (batch, feaLen).
For example, A input SparseTensor as follows: indices(0) = Array(0, 0, 1, 2, 2) indices(1) = Array(0, 3, 1, 1, 2) values = Array(1, 2, 2, 3, 3) shape = Array(3, 4)
the output tensor should be an 2D 3x4 DenseTensor with isCount = true 0.0, 1.0, 1.0, 0.0 0.0, 0.0, 1.0, 0.0 0.0, 0.0, 0.0, 2.0
Numeric type. Parameter tensor numeric type. Only support float/double now
Kv2Tensor operation convert a kv feature column to a SparseTensor or DenseTensor
Kv2Tensor operation convert a kv feature column to a SparseTensor or DenseTensor
DenseTensor if transType = 0 SparseTensor if transType = 1
The input contains 2 elements which are kvTensor
, feaLen
:
kvTensor shape will be batch*1 and element is a kv string, only support one feature now
depth: the length of the value set of the feature
the output shape will be batch*feaLen if transType = 0 the output shape will be a SparseTensor with dense shape batch*feaLen if transType = 1
Numeric type. Parameter tensor numeric type. Only support float/double now
Numeric type. Output tensor numeric type. Only support float/double now
Computes the maximum of elements across dimensions of a tensor.
Computes the maximum of elements across dimensions of a tensor. The input of Max should be two tensor, the first one is data, the second one is the dimension to compute maximum.
MkString operation converts a SparseTensor/DenseTensor to a Dense Tensor[String]
MkString operation converts a SparseTensor/DenseTensor to a Dense Tensor[String]
the output shape will be 1-D Tensor[String].
Numeric type. Parameter tensor numeric type. Only support float/double now
Wrap a nn module to an Operation
Wrap a nn module to an Operation
Numeric type. Only support float/double now
OneHot operation returns a one-hot tensor
OneHot operation returns a one-hot tensor
The input contains 4 elements which are indices
, depth
, onValue
and offValue
*[]:
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 dtype is also provided, they must be the same data type as specified by D
.
If on_value is not provided, it will default to the value 1 with type dtype
If off_value is not provided, it will default to the value 0 with type dtype
If the input indices is rank N, the output will have rank N+1. The new axis is created at dimension axis (default: the new axis is appended at the end).
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 x depth if axis == -1 depth x features if axis == 0
If indices is a matrix (batch) with shape [batch, features], the output shape will be:
batch x features x depth if axis == -1 batch x depth x features if axis == 1 depth x batch x features if axis == 0
Numeric type. Parameter tensor numeric type. Only support float/double now
Numeric type. Output tensor numeric type. Only support float/double now
Operation is an abstract class which represents a forward only layer.
Operation is an abstract class which represents a forward only layer. An operations has only forward functions and without backward functions. An operations should be only used in graph and make sure the backward graph won't contain operations.
Input data type
Numeric type. Only support float/double now
Computes the sum along segments of a tensor.
Selects elements from input, depending on given condition.
Selects elements from input, depending on given condition. The input is a table (condition, t, e)
Numeric type. Only support float/double now
Select and copy a Tensor from a Table with a key.
Select and copy a Tensor from a Table with a key.
And do tensor transformation if transformer is defined.
If isTensorKey is false
, the real key is the value of keyTensor.
Otherwise, the real key is keyTensor.
Numeric type
This operation extracts a slice of size size from a tensor input starting at the location specified by begin.
This operation extracts a slice of size size from a tensor input starting at the location specified by begin. The slice size is represented as a tensor shape, where size[i] is the number of elements of the 'i'th dimension of input that you want to slice The starting location (begin) for the slice is represented as an offset in each dimension of input. In other words, begin[i] is the offset into the 'i'th dimension of input that you want to slice from.
Numeric type. Only support float/double now
Returns (x - y)(x - y) element-wise.
TensorOp is an Operation with Tensor[T]-formatted
input and output,
which provides shortcuts to build Operations for tensor transformation
by closures.
TensorOp is an Operation with Tensor[T]-formatted
input and output,
which provides shortcuts to build Operations for tensor transformation
by closures.
TensorOp will make a deep copy of input Tensor before transformation,
so transformation will take no side effect. For now, SparseTensors
are not supported.
Chained feature is supported in TensorOp.
And common tensor actions are provided with a chained style.
For instance:
one case: val (transformer1, transformer2, transformer3) = ... val (op1, op2, op3) = (TensorOp[Float](transformer1), .., ..) val op = op1 -> op2 -> op3 `equals` val op = TensorOp[Float]((t: Tensor[Float], ev: TensorNumeric[Float]) => { transformer3(transformer2(transformer1(t, ev), ev), ev) }) another case: val op = (TensorOp[Float]() * 2.3f + 1.23f) / 1.11f - 0.66f `equals` val transformer = (t: Tensor[T], _) => t.mul(2.3f).add(1.23f).div(1.11f).sub(0.66f) val op = TensorOp[Float](transformer)
Numeric type
This operation creates a new tensor by replicating input multiples times.
This operation creates a new tensor by replicating input multiples times. The output tensor's i'th dimension has input.dims(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 [1, 2] produces [a b c d a b c d].
Numeric type. Only support float/double now
Multiplies all slices of
Tensor
x
andy
(each slice can be viewed as an element of a batch), and arranges the individual results in a single output tensor of the same batch size. Each of the individual slices can optionally be adjointed (to adjoint a matrix means to transpose and conjugate it) before multiplication by setting theadj_x
oradj_y
flag toTrue
, which are by defaultFalse
.