Type RaggedTensor
Namespace tensorflow
Parent PythonObjectContainer
Interfaces CompositeTensor, IRaggedTensor
Represents a ragged tensor. A `RaggedTensor` is a tensor with one or more *ragged dimensions*, which are
dimensions whose slices may have different lengths. For example, the inner
(column) dimension of `rt=[[3, 1, 4, 1], [], [5, 9, 2], [6], []]` is ragged,
since the column slices (`rt[0, :]`,..., `rt[4, :]`) have different lengths.
Dimensions whose slices all have the same length are called *uniform
dimensions*. The outermost dimension of a `RaggedTensor` is always uniform,
since it consists of a single slice (and so there is no possibility for
differing slice lengths). The total number of dimensions in a `RaggedTensor` is called its *rank*,
and the number of ragged dimensions in a `RaggedTensor` is called its
*ragged-rank*. A `RaggedTensor`'s ragged-rank is fixed at graph creation
time: it can't depend on the runtime values of `Tensor`s, and can't vary
dynamically for different session runs. ### Potentially Ragged Tensors Many ops support both `Tensor`s and `RaggedTensor`s. The term "potentially
ragged tensor" may be used to refer to a tensor that might be either a
`Tensor` or a `RaggedTensor`. The ragged-rank of a `Tensor` is zero. ### Documenting RaggedTensor Shapes When documenting the shape of a RaggedTensor, ragged dimensions can be
indicated by enclosing them in parentheses. For example, the shape of
a 3-D `RaggedTensor` that stores the fixed-size word embedding for each
word in a sentence, for each sentence in a batch, could be written as
`[num_sentences, (num_words), embedding_size]`. The parentheses around
`(num_words)` indicate that dimension is ragged, and that the length
of each element list in that dimension may vary for each item. ### Component Tensors Internally, a `RaggedTensor` consists of a concatenated list of values that
are partitioned into variable-length rows. In particular, each `RaggedTensor`
consists of: * A `values` tensor, which concatenates the variable-length rows into a
flattened list. For example, the `values` tensor for
`[[3, 1, 4, 1], [], [5, 9, 2], [6], []]` is `[3, 1, 4, 1, 5, 9, 2, 6]`. * A `row_splits` vector, which indicates how those flattened values are
divided into rows. In particular, the values for row `rt[i]` are stored
in the slice `rt.values[rt.row_splits[i]:rt.row_splits[i+1]]`. Example:
### Alternative Row-Partitioning Schemes In addition to `row_splits`, ragged tensors provide support for four other
row-partitioning schemes: * `row_lengths`: a vector with shape `[nrows]`, which specifies the length
of each row. * `value_rowids` and `nrows`: `value_rowids` is a vector with shape
`[nvals]`, corresponding one-to-one with `values`, which specifies
each value's row index. In particular, the row `rt[row]` consists of the
values `rt.values[j]` where `value_rowids[j]==row`. `nrows` is an
integer scalar that specifies the number of rows in the
`RaggedTensor`. (`nrows` is used to indicate trailing empty rows.) * `row_starts`: a vector with shape `[nrows]`, which specifies the start
offset of each row. Equivalent to `row_splits[:-1]`. * `row_limits`: a vector with shape `[nrows]`, which specifies the stop
offset of each row. Equivalent to `row_splits[1:]`. Example: The following ragged tensors are equivalent, and all represent the
nested list `[[3, 1, 4, 1], [], [5, 9, 2], [6], []]`.
### Multiple Ragged Dimensions `RaggedTensor`s with multiple ragged dimensions can be defined by using
a nested `RaggedTensor` for the `values` tensor. Each nested `RaggedTensor`
adds a single ragged dimension.
The factory function `RaggedTensor.from_nested_row_splits` may be used to
construct a `RaggedTensor` with multiple ragged dimensions directly, by
providing a list of `row_splits` tensors:
### Uniform Inner Dimensions `RaggedTensor`s with uniform inner dimensions can be defined
by using a multidimensional `Tensor` for `values`.
### RaggedTensor Shape Restrictions The shape of a RaggedTensor is currently restricted to have the following
form: * A single uniform dimension
* Followed by one or more ragged dimensions
* Followed by zero or more uniform dimensions. This restriction follows from the fact that each nested `RaggedTensor`
replaces the uniform outermost dimension of its `values` with a uniform
dimension followed by a ragged dimension.
Show Example
>>> print(tf.RaggedTensor.from_row_splits( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_splits=[0, 4, 4, 7, 8, 8]))
Methods
- __getitem__
- bounding_shape
- bounding_shape
- bounding_shape_dyn
- from_nested_row_lengths_dyn<TClass>
- from_nested_row_lengths<TClass>
- from_nested_row_lengths<TClass>
- from_nested_row_lengths<TClass>
- from_nested_row_splits_dyn<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_row_splits<TClass>
- from_nested_value_rowids_dyn<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_nested_value_rowids<TClass>
- from_row_lengths_dyn<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_lengths<TClass>
- from_row_limits_dyn<TClass>
- from_row_limits<TClass>
- from_row_limits<TClass>
- from_row_limits<TClass>
- from_row_limits<TClass>
- from_row_splits_dyn<TClass>
- from_row_splits<TClass>
- from_row_splits<TClass>
- from_row_splits<TClass>
- from_row_splits<TClass>
- from_row_splits<TClass>
- from_row_starts_dyn<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_row_starts<TClass>
- from_sparse_dyn<TClass>
- from_sparse<TClass>
- from_tensor_dyn<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_tensor<TClass>
- from_value_rowids_dyn<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- from_value_rowids<TClass>
- nested_row_lengths
- nested_row_lengths_dyn
- nested_value_rowids
- nested_value_rowids_dyn
- nrows
- nrows
- nrows
- nrows_dyn
- row_lengths
- row_lengths_dyn
- row_limits
- row_limits_dyn
- row_starts
- row_starts_dyn
- to_sparse
- to_sparse_dyn
- to_tensor
- to_tensor
- to_tensor
- to_tensor
- to_tensor
- to_tensor_dyn
- value_rowids
- value_rowids_dyn
- with_flat_values
- with_flat_values
- with_flat_values_dyn
- with_row_splits_dtype
- with_row_splits_dtype_dyn
- with_values
- with_values
- with_values
- with_values_dyn
Properties
Public instance methods
object __getitem__(IGraphNodeBase key)
Returns the specified piece of this RaggedTensor. Supports multidimensional indexing and slicing, with one restriction:
indexing into a ragged inner dimension is not allowed. This case is
problematic because the indicated value may exist in some rows but not
others. In such cases, it's not obvious whether we should (1) report an
IndexError; (2) use a default value; or (3) skip that value and return a
tensor with fewer rows than we started with. Following the guiding
principles of Python ("In the face of ambiguity, refuse the temptation to
guess"), we simply disallow this operation. Any dimensions added by `array_ops.newaxis` will be ragged if the following
dimension is ragged.
Parameters
-
IGraphNodeBase
key - Indicates which piece of the RaggedTensor to return, using standard
Python semantics (e.g., negative values index from the end). `key`
may have any of the following types: * `int` constant
* Scalar integer `Tensor`
* `slice` containing integer constants and/or scalar integer
`Tensor`s
* `Ellipsis`
*
tf.newaxis
* `tuple` containing any of the above (for multidimentional indexing)
Returns
-
object
- A `Tensor` or `RaggedTensor` object. Values that include at least one ragged dimension are returned as `RaggedTensor`. Values that include no ragged dimensions are returned as `Tensor`. See above for examples of expressions that return `Tensor`s vs `RaggedTensor`s.
object bounding_shape(IEnumerable<int> axis, string name, object out_type)
Returns the tight bounding box shape for this `RaggedTensor`.
Parameters
-
IEnumerable<int>
axis - An integer scalar or vector indicating which axes to return the bounding box for. If not specified, then the full bounding box is returned.
-
string
name - A name prefix for the returned tensor (optional).
-
object
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
Returns
-
object
- An integer `Tensor` (`dtype=self.row_splits.dtype`). If `axis` is not specified, then `output` is a vector with `output.shape=[self.shape.ndims]`. If `axis` is a scalar, then the `output` is a scalar. If `axis` is a vector, then `output` is a vector, where `output[i]` is the bounding size for dimension `axis[i]`. #### Example: ```python >>> rt = ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]]) >>> rt.bounding_shape() [5, 4] ```
object bounding_shape(int axis, string name, object out_type)
Returns the tight bounding box shape for this `RaggedTensor`.
Parameters
-
int
axis - An integer scalar or vector indicating which axes to return the bounding box for. If not specified, then the full bounding box is returned.
-
string
name - A name prefix for the returned tensor (optional).
-
object
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
Returns
-
object
- An integer `Tensor` (`dtype=self.row_splits.dtype`). If `axis` is not specified, then `output` is a vector with `output.shape=[self.shape.ndims]`. If `axis` is a scalar, then the `output` is a scalar. If `axis` is a vector, then `output` is a vector, where `output[i]` is the bounding size for dimension `axis[i]`. #### Example: ```python >>> rt = ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]]) >>> rt.bounding_shape() [5, 4] ```
object bounding_shape_dyn(object axis, object name, object out_type)
Returns the tight bounding box shape for this `RaggedTensor`.
Parameters
-
object
axis - An integer scalar or vector indicating which axes to return the bounding box for. If not specified, then the full bounding box is returned.
-
object
name - A name prefix for the returned tensor (optional).
-
object
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
Returns
-
object
- An integer `Tensor` (`dtype=self.row_splits.dtype`). If `axis` is not specified, then `output` is a vector with `output.shape=[self.shape.ndims]`. If `axis` is a scalar, then the `output` is a scalar. If `axis` is a vector, then `output` is a vector, where `output[i]` is the bounding size for dimension `axis[i]`. #### Example: ```python >>> rt = ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]]) >>> rt.bounding_shape() [5, 4] ```
ValueTuple<object> nested_row_lengths(string name)
Returns a tuple containing the row_lengths for all ragged dimensions. `rt.nested_row_lengths()` is a tuple containing the `row_lengths` tensors
for all ragged dimensions in `rt`, ordered from outermost to innermost.
Parameters
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
ValueTuple<object>
- A `tuple` of 1-D integer `Tensors`. The length of the tuple is equal to `self.ragged_rank`.
object nested_row_lengths_dyn(object name)
Returns a tuple containing the row_lengths for all ragged dimensions. `rt.nested_row_lengths()` is a tuple containing the `row_lengths` tensors
for all ragged dimensions in `rt`, ordered from outermost to innermost.
Parameters
-
object
name - A name prefix for the returned tensors (optional).
Returns
-
object
- A `tuple` of 1-D integer `Tensors`. The length of the tuple is equal to `self.ragged_rank`.
ValueTuple<object> nested_value_rowids(string name)
Returns a tuple containing the value_rowids for all ragged dimensions. `rt.nested_value_rowids` is a tuple containing the `value_rowids` tensors
for
all ragged dimensions in `rt`, ordered from outermost to innermost. In
particular, `rt.nested_value_rowids = (rt.value_rowids(),) + value_ids`
where: * `value_ids = ()` if `rt.values` is a `Tensor`.
* `value_ids = rt.values.nested_value_rowids` otherwise.
Parameters
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
ValueTuple<object>
- A `tuple` of 1-D integer `Tensor`s. #### Example: ```python >>> rt = ragged.constant([[[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]]) >>> for i, ids in enumerate(rt.nested_value_rowids()): ... print('row ids for dimension %d: %s' % (i+1, ids)) row ids for dimension 1: [0] row ids for dimension 2: [0, 0, 0, 2, 2] row ids for dimension 3: [0, 0, 0, 0, 2, 2, 2, 3] ```
object nested_value_rowids_dyn(object name)
Returns a tuple containing the value_rowids for all ragged dimensions. `rt.nested_value_rowids` is a tuple containing the `value_rowids` tensors
for
all ragged dimensions in `rt`, ordered from outermost to innermost. In
particular, `rt.nested_value_rowids = (rt.value_rowids(),) + value_ids`
where: * `value_ids = ()` if `rt.values` is a `Tensor`.
* `value_ids = rt.values.nested_value_rowids` otherwise.
Parameters
-
object
name - A name prefix for the returned tensors (optional).
Returns
-
object
- A `tuple` of 1-D integer `Tensor`s. #### Example: ```python >>> rt = ragged.constant([[[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]]) >>> for i, ids in enumerate(rt.nested_value_rowids()): ... print('row ids for dimension %d: %s' % (i+1, ids)) row ids for dimension 1: [0] row ids for dimension 2: [0, 0, 0, 2, 2] row ids for dimension 3: [0, 0, 0, 0, 2, 2, 2, 3] ```
object nrows(DType out_type, string name)
Returns the number of rows in this ragged tensor. I.e., the size of the outermost dimension of the tensor.
Parameters
-
DType
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A scalar `Tensor` with dtype `out_type`. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.nrows() # rt has 5 rows. 5 ```
object nrows(dtype out_type, string name)
Returns the number of rows in this ragged tensor. I.e., the size of the outermost dimension of the tensor.
Parameters
-
dtype
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A scalar `Tensor` with dtype `out_type`. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.nrows() # rt has 5 rows. 5 ```
object nrows(PythonClassContainer out_type, string name)
Returns the number of rows in this ragged tensor. I.e., the size of the outermost dimension of the tensor.
Parameters
-
PythonClassContainer
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A scalar `Tensor` with dtype `out_type`. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.nrows() # rt has 5 rows. 5 ```
object nrows_dyn(object out_type, object name)
Returns the number of rows in this ragged tensor. I.e., the size of the outermost dimension of the tensor.
Parameters
-
object
out_type - `dtype` for the returned tensor. Defaults to `self.row_splits.dtype`.
-
object
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A scalar `Tensor` with dtype `out_type`. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.nrows() # rt has 5 rows. 5 ```
object row_lengths(int axis, string name)
Returns the lengths of the rows in this ragged tensor. `rt.row_lengths()[i]` indicates the number of values in the
`i`th row of `rt`.
Parameters
-
int
axis - An integer constant indicating the axis whose row lengths should be returned.
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A potentially ragged integer Tensor with shape `self.shape[:axis]`.
object row_lengths_dyn(ImplicitContainer<T> axis, object name)
Returns the lengths of the rows in this ragged tensor. `rt.row_lengths()[i]` indicates the number of values in the
`i`th row of `rt`.
Parameters
-
ImplicitContainer<T>
axis - An integer constant indicating the axis whose row lengths should be returned.
-
object
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A potentially ragged integer Tensor with shape `self.shape[:axis]`.
object row_limits(string name)
Returns the limit indices for rows in this ragged tensor. These indices specify where the values for each row end in
`self.values`. `rt.row_limits(self)` is equal to `rt.row_splits[:-1]`.
Parameters
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer Tensor with shape `[nrows]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.row_limits() # indices of row limits in rt.values tf.Tensor([4, 4, 7, 8, 8]) ```
object row_limits_dyn(object name)
Returns the limit indices for rows in this ragged tensor. These indices specify where the values for each row end in
`self.values`. `rt.row_limits(self)` is equal to `rt.row_splits[:-1]`.
Parameters
-
object
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer Tensor with shape `[nrows]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.row_limits() # indices of row limits in rt.values tf.Tensor([4, 4, 7, 8, 8]) ```
object row_starts(string name)
Returns the start indices for rows in this ragged tensor. These indices specify where the values for each row begin in
`self.values`. `rt.row_starts()` is equal to `rt.row_splits[:-1]`.
Parameters
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer Tensor with shape `[nrows]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.row_starts() # indices of row starts in rt.values tf.Tensor([0, 4, 4, 7, 8]) ```
object row_starts_dyn(object name)
Returns the start indices for rows in this ragged tensor. These indices specify where the values for each row begin in
`self.values`. `rt.row_starts()` is equal to `rt.row_splits[:-1]`.
Parameters
-
object
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer Tensor with shape `[nrows]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.row_starts() # indices of row starts in rt.values tf.Tensor([0, 4, 4, 7, 8]) ```
SparseTensor to_sparse(string name)
Converts this `RaggedTensor` into a
tf.SparseTensor
. Example:
Parameters
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
SparseTensor
- A SparseTensor with the same values as `self`.
Show Example
>>> rt = ragged.constant([[1, 2, 3], [4], [], [5, 6]]) >>> rt.to_sparse().eval() SparseTensorValue(indices=[[0, 0], [0, 1], [0, 2], [1, 0], [3, 0], [3, 1]], values=[1, 2, 3, 4, 5, 6], dense_shape=[4, 3])
object to_sparse_dyn(object name)
Converts this `RaggedTensor` into a
tf.SparseTensor
. Example:
Parameters
-
object
name - A name prefix for the returned tensors (optional).
Returns
-
object
- A SparseTensor with the same values as `self`.
Show Example
>>> rt = ragged.constant([[1, 2, 3], [4], [], [5, 6]]) >>> rt.to_sparse().eval() SparseTensorValue(indices=[[0, 0], [0, 1], [0, 2], [1, 0], [3, 0], [3, 1]], values=[1, 2, 3, 4, 5, 6], dense_shape=[4, 3])
Tensor to_tensor(IGraphNodeBase default_value, string name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
IGraphNodeBase
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
Tensor
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
Tensor to_tensor(bool default_value, string name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
bool
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
Tensor
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
Tensor to_tensor(string default_value, string name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
string
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
Tensor
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
Tensor to_tensor(int default_value, string name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
int
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
Tensor
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
Tensor to_tensor(IEnumerable<int> default_value, string name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
IEnumerable<int>
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
string
name - A name prefix for the returned tensors (optional).
Returns
-
Tensor
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
object to_tensor_dyn(object default_value, object name)
Converts this `RaggedTensor` into a
tf.Tensor
. Example:
Parameters
-
object
default_value - Value to set for indices not specified in `self`. Defaults to zero. `default_value` must be broadcastable to `self.shape[self.ragged_rank + 1:]`.
-
object
name - A name prefix for the returned tensors (optional).
Returns
-
object
- A `Tensor` with shape `ragged.bounding_shape(self)` and the values specified by the non-empty values in `self`. Empty values are assigned `default_value`.
Show Example
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
object value_rowids(string name)
Returns the row indices for the `values` in this ragged tensor. `rt.value_rowids()` corresponds one-to-one with the outermost dimension of
`rt.values`, and specifies the row containing each value. In particular,
the row `rt[row]` consists of the values `rt.values[j]` where
`rt.value_rowids()[j] == row`.
Parameters
-
string
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer `Tensor` with shape `self.values.shape[:1]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.value_rowids() tf.Tensor([0, 0, 0, 0, 2, 2, 2, 3]) # corresponds 1:1 with rt.values ```
object value_rowids_dyn(object name)
Returns the row indices for the `values` in this ragged tensor. `rt.value_rowids()` corresponds one-to-one with the outermost dimension of
`rt.values`, and specifies the row containing each value. In particular,
the row `rt[row]` consists of the values `rt.values[j]` where
`rt.value_rowids()[j] == row`.
Parameters
-
object
name - A name prefix for the returned tensor (optional).
Returns
-
object
- A 1-D integer `Tensor` with shape `self.values.shape[:1]`. The returned tensor is nonnegative, and is sorted in ascending order. #### Example: ```python >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) >>> rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) >>> rt.value_rowids() tf.Tensor([0, 0, 0, 0, 2, 2, 2, 3]) # corresponds 1:1 with rt.values ```
RaggedTensor with_flat_values(IGraphNodeBase new_values)
Returns a copy of `self` with `flat_values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
IGraphNodeBase
new_values - Potentially ragged tensor that should replace `self.flat_values`. Must have `rank > 0`, and must have the same number of rows as `self.flat_values`.
Returns
-
RaggedTensor
- A `RaggedTensor`. `result.rank = self.ragged_rank + new_values.rank`. `result.ragged_rank = self.ragged_rank + new_values.ragged_rank`.
RaggedTensor with_flat_values(RaggedTensor new_values)
Returns a copy of `self` with `flat_values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
RaggedTensor
new_values - Potentially ragged tensor that should replace `self.flat_values`. Must have `rank > 0`, and must have the same number of rows as `self.flat_values`.
Returns
-
RaggedTensor
- A `RaggedTensor`. `result.rank = self.ragged_rank + new_values.rank`. `result.ragged_rank = self.ragged_rank + new_values.ragged_rank`.
object with_flat_values_dyn(object new_values)
Returns a copy of `self` with `flat_values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
object
new_values - Potentially ragged tensor that should replace `self.flat_values`. Must have `rank > 0`, and must have the same number of rows as `self.flat_values`.
Returns
-
object
- A `RaggedTensor`. `result.rank = self.ragged_rank + new_values.rank`. `result.ragged_rank = self.ragged_rank + new_values.ragged_rank`.
RaggedTensor with_row_splits_dtype(DType dtype)
Returns a copy of this RaggedTensor with the given `row_splits` dtype. For RaggedTensors with multiple ragged dimensions, the `row_splits` for all
nested `RaggedTensor` objects are cast to the given dtype.
Returns
-
RaggedTensor
- A copy of this RaggedTensor, with the `row_splits` cast to the given type.
object with_row_splits_dtype_dyn(object dtype)
Returns a copy of this RaggedTensor with the given `row_splits` dtype. For RaggedTensors with multiple ragged dimensions, the `row_splits` for all
nested `RaggedTensor` objects are cast to the given dtype.
Returns
-
object
- A copy of this RaggedTensor, with the `row_splits` cast to the given type.
RaggedTensor with_values(IEnumerable<int> new_values)
Returns a copy of `self` with `values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
IEnumerable<int>
new_values - Potentially ragged tensor to use as the `values` for the returned `RaggedTensor`. Must have `rank > 0`, and must have the same number of rows as `self.values`.
Returns
-
RaggedTensor
- A `RaggedTensor`. `result.rank = 1 + new_values.rank`. `result.ragged_rank = 1 + new_values.ragged_rank`
RaggedTensor with_values(RaggedTensor new_values)
Returns a copy of `self` with `values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
RaggedTensor
new_values - Potentially ragged tensor to use as the `values` for the returned `RaggedTensor`. Must have `rank > 0`, and must have the same number of rows as `self.values`.
Returns
-
RaggedTensor
- A `RaggedTensor`. `result.rank = 1 + new_values.rank`. `result.ragged_rank = 1 + new_values.ragged_rank`
RaggedTensor with_values(IGraphNodeBase new_values)
Returns a copy of `self` with `values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
IGraphNodeBase
new_values - Potentially ragged tensor to use as the `values` for the returned `RaggedTensor`. Must have `rank > 0`, and must have the same number of rows as `self.values`.
Returns
-
RaggedTensor
- A `RaggedTensor`. `result.rank = 1 + new_values.rank`. `result.ragged_rank = 1 + new_values.ragged_rank`
object with_values_dyn(object new_values)
Returns a copy of `self` with `values` replaced by `new_value`. Preserves cached row-partitioning tensors such as `self.cached_nrows` and
`self.cached_value_rowids` if they have values.
Parameters
-
object
new_values - Potentially ragged tensor to use as the `values` for the returned `RaggedTensor`. Must have `rank > 0`, and must have the same number of rows as `self.values`.
Returns
-
object
- A `RaggedTensor`. `result.rank = 1 + new_values.rank`. `result.ragged_rank = 1 + new_values.ragged_rank`
Public static methods
object from_nested_row_lengths_dyn<TClass>(object flat_values, object nested_row_lengths, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` from a nested list of `row_lengths` tensors. Equivalent to:
Parameters
-
object
flat_values - A potentially ragged tensor.
-
object
nested_row_lengths - A list of 1-D integer tensors. The `i`th tensor is used as the `row_lengths` for the `i`th ragged dimension.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor` (or `flat_values` if `nested_row_lengths` is empty).
Show Example
result = flat_values for row_lengths in reversed(nested_row_lengths): result = from_row_lengths(result, row_lengths)
TClass from_nested_row_lengths<TClass>(IGraphNodeBase flat_values, IEnumerable<object> nested_row_lengths, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_lengths` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IEnumerable<object>
nested_row_lengths - A list of 1-D integer tensors. The `i`th tensor is used as the `row_lengths` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_lengths` is empty).
Show Example
result = flat_values for row_lengths in reversed(nested_row_lengths): result = from_row_lengths(result, row_lengths)
TClass from_nested_row_lengths<TClass>(IGraphNodeBase flat_values, ValueTuple<IEnumerable<object>, object> nested_row_lengths, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_lengths` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
ValueTuple<IEnumerable<object>, object>
nested_row_lengths - A list of 1-D integer tensors. The `i`th tensor is used as the `row_lengths` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_lengths` is empty).
Show Example
result = flat_values for row_lengths in reversed(nested_row_lengths): result = from_row_lengths(result, row_lengths)
TClass from_nested_row_lengths<TClass>(IGraphNodeBase flat_values, IGraphNodeBase nested_row_lengths, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_lengths` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_row_lengths - A list of 1-D integer tensors. The `i`th tensor is used as the `row_lengths` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_lengths` is empty).
Show Example
result = flat_values for row_lengths in reversed(nested_row_lengths): result = from_row_lengths(result, row_lengths)
object from_nested_row_splits_dyn<TClass>(object flat_values, object nested_row_splits, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
object
flat_values - A potentially ragged tensor.
-
object
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IEnumerable<PythonClassContainer> flat_values, IGraphNodeBase nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IEnumerable<PythonClassContainer>
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(CompositeTensor flat_values, IEnumerable<object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
CompositeTensor
flat_values - A potentially ragged tensor.
-
IEnumerable<object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(CompositeTensor flat_values, IGraphNodeBase nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
CompositeTensor
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IEnumerable<PythonClassContainer> flat_values, ValueTuple<IEnumerable<int>, object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IEnumerable<PythonClassContainer>
flat_values - A potentially ragged tensor.
-
ValueTuple<IEnumerable<int>, object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IGraphNodeBase flat_values, IEnumerable<object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IEnumerable<object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IGraphNodeBase flat_values, ValueTuple<IEnumerable<int>, object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
ValueTuple<IEnumerable<int>, object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IGraphNodeBase flat_values, IGraphNodeBase nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(PythonClassContainer flat_values, IEnumerable<object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
PythonClassContainer
flat_values - A potentially ragged tensor.
-
IEnumerable<object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(CompositeTensor flat_values, ValueTuple<IEnumerable<int>, object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
CompositeTensor
flat_values - A potentially ragged tensor.
-
ValueTuple<IEnumerable<int>, object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(PythonClassContainer flat_values, IGraphNodeBase nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
PythonClassContainer
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(IEnumerable<PythonClassContainer> flat_values, IEnumerable<object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
IEnumerable<PythonClassContainer>
flat_values - A potentially ragged tensor.
-
IEnumerable<object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
TClass from_nested_row_splits<TClass>(PythonClassContainer flat_values, ValueTuple<IEnumerable<int>, object> nested_row_splits, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `row_splits` tensors. Equivalent to:
Parameters
-
PythonClassContainer
flat_values - A potentially ragged tensor.
-
ValueTuple<IEnumerable<int>, object>
nested_row_splits - A list of 1-D integer tensors. The `i`th tensor is used as the `row_splits` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_row_splits` is empty).
Show Example
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
object from_nested_value_rowids_dyn<TClass>(object flat_values, object nested_value_rowids, object nested_nrows, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
object
flat_values - A potentially ragged tensor.
-
object
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
object
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IGraphNodeBase flat_values, IGraphNodeBase nested_value_rowids, IGraphNodeBase nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IGraphNodeBase
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IEnumerable<int> flat_values, IEnumerable<IGraphNodeBase> nested_value_rowids, IEnumerable<IGraphNodeBase> nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IEnumerable<int>
flat_values - A potentially ragged tensor.
-
IEnumerable<IGraphNodeBase>
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IEnumerable<IGraphNodeBase>
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IEnumerable<int> flat_values, IEnumerable<IGraphNodeBase> nested_value_rowids, IGraphNodeBase nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IEnumerable<int>
flat_values - A potentially ragged tensor.
-
IEnumerable<IGraphNodeBase>
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IGraphNodeBase
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IEnumerable<int> flat_values, IGraphNodeBase nested_value_rowids, IEnumerable<IGraphNodeBase> nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IEnumerable<int>
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IEnumerable<IGraphNodeBase>
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IGraphNodeBase flat_values, IEnumerable<IGraphNodeBase> nested_value_rowids, IEnumerable<IGraphNodeBase> nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IEnumerable<IGraphNodeBase>
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IEnumerable<IGraphNodeBase>
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IEnumerable<int> flat_values, IGraphNodeBase nested_value_rowids, IGraphNodeBase nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IEnumerable<int>
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IGraphNodeBase
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IGraphNodeBase flat_values, IEnumerable<IGraphNodeBase> nested_value_rowids, IGraphNodeBase nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IEnumerable<IGraphNodeBase>
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IGraphNodeBase
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
TClass from_nested_value_rowids<TClass>(IGraphNodeBase flat_values, IGraphNodeBase nested_value_rowids, IEnumerable<IGraphNodeBase> nested_nrows, string name, bool validate)
Creates a `RaggedTensor` from a nested list of `value_rowids` tensors. Equivalent to:
Parameters
-
IGraphNodeBase
flat_values - A potentially ragged tensor.
-
IGraphNodeBase
nested_value_rowids - A list of 1-D integer tensors. The `i`th tensor is used as the `value_rowids` for the `i`th ragged dimension.
-
IEnumerable<IGraphNodeBase>
nested_nrows - A list of integer scalars. The `i`th scalar is used as the `nrows` for the `i`th ragged dimension.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor` (or `flat_values` if `nested_value_rowids` is empty).
Show Example
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
object from_row_lengths_dyn<TClass>(object values, object row_lengths, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
object
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(IEnumerable<int> values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(string values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
string
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(string values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
string
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(object values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(object values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(RaggedTensor values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(IGraphNodeBase values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(DType values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
DType
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(RaggedTensor values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(int values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
int
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(int values, IGraphNodeBase row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
int
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(IEnumerable<int> values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(DType values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
DType
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
TClass from_row_lengths<TClass>(IGraphNodeBase values, IEnumerable<int> row_lengths, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_lengths`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_lengths - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative. `sum(row_lengths)` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_lengths(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_lengths=[4, 0, 3, 1, 0]))
```
Show Example
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
object from_row_limits_dyn<TClass>(object values, object row_limits, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` with rows partitioned by `row_limits`. Equivalent to: `from_row_splits(values, concat([0, row_limits]))`.
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
object
row_limits - A 1-D integer tensor with shape `[nrows]`. Must be sorted in ascending order. If `nrows>0`, then `row_limits[-1]` must be `nvals`.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_limits(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_limits=[4, 4, 7, 8, 8]))
```
TClass from_row_limits<TClass>(IEnumerable<int> values, IGraphNodeBase row_limits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_limits`. Equivalent to: `from_row_splits(values, concat([0, row_limits]))`.
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_limits - A 1-D integer tensor with shape `[nrows]`. Must be sorted in ascending order. If `nrows>0`, then `row_limits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_limits(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_limits=[4, 4, 7, 8, 8]))
```
TClass from_row_limits<TClass>(IEnumerable<int> values, IEnumerable<int> row_limits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_limits`. Equivalent to: `from_row_splits(values, concat([0, row_limits]))`.
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_limits - A 1-D integer tensor with shape `[nrows]`. Must be sorted in ascending order. If `nrows>0`, then `row_limits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_limits(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_limits=[4, 4, 7, 8, 8]))
```
TClass from_row_limits<TClass>(IGraphNodeBase values, IGraphNodeBase row_limits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_limits`. Equivalent to: `from_row_splits(values, concat([0, row_limits]))`.
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_limits - A 1-D integer tensor with shape `[nrows]`. Must be sorted in ascending order. If `nrows>0`, then `row_limits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_limits(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_limits=[4, 4, 7, 8, 8]))
```
TClass from_row_limits<TClass>(IGraphNodeBase values, IEnumerable<int> row_limits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_limits`. Equivalent to: `from_row_splits(values, concat([0, row_limits]))`.
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_limits - A 1-D integer tensor with shape `[nrows]`. Must be sorted in ascending order. If `nrows>0`, then `row_limits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_limits(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_limits=[4, 4, 7, 8, 8]))
```
object from_row_splits_dyn<TClass>(object values, object row_splits, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
object
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
TClass from_row_splits<TClass>(object values, ValueTuple<IEnumerable<object>, object> row_splits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
ValueTuple<IEnumerable<object>, object>
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
TClass from_row_splits<TClass>(object values, TensorSpec row_splits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
TensorSpec
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
TClass from_row_splits<TClass>(object values, IGraphNodeBase row_splits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
TClass from_row_splits<TClass>(object values, ndarray row_splits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
ndarray
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
TClass from_row_splits<TClass>(object values, IEnumerable<int> row_splits, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_splits`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_splits - A 1-D integer tensor with shape `[nrows+1]`. Must not be empty, and must be sorted in ascending order. `row_splits[0]` must be zero and `row_splits[-1]` must be `nvals`.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
object from_row_starts_dyn<TClass>(object values, object row_starts, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
object
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(RaggedTensor values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(IGraphNodeBase values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(PythonClassContainer values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
PythonClassContainer
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(int values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
int
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(PythonClassContainer values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
PythonClassContainer
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(IGraphNodeBase values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(TestCase values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
TestCase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(int values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
int
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(TestCase values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
TestCase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(IEnumerable<int> values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(IEnumerable<int> values, IGraphNodeBase row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
IEnumerable<int>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
TClass from_row_starts<TClass>(RaggedTensor values, IEnumerable<int> row_starts, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `row_starts`. Equivalent to: `from_row_splits(values, concat([row_starts, nvals]))`.
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<int>
row_starts - A 1-D integer tensor with shape `[nrows]`. Must be nonnegative and sorted in ascending order. If `nrows>0`, then `row_starts[0]` must be zero.
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`.
`result.ragged_rank = values.ragged_rank + 1`. #### Example:
```python
>>> print(tf.RaggedTensor.from_row_starts(
... values=[3, 1, 4, 1, 5, 9, 2, 6],
... row_starts=[0, 4, 4, 7, 8]))
```
object from_sparse_dyn<TClass>(object st_input, object name, ImplicitContainer<T> row_splits_dtype)
Converts a 2D
tf.SparseTensor
to a `RaggedTensor`. Each row of the `output` `RaggedTensor` will contain the explicit values
from the same row in `st_input`. `st_input` must be ragged-right. If not
it is not ragged-right, then an error will be generated. Example:
Currently, only two-dimensional `SparseTensors` are supported.
Parameters
-
object
st_input - The sparse tensor to convert. Must have rank 2.
-
object
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
object
- A `RaggedTensor` with the same values as `st_input`. `output.ragged_rank = rank(st_input) - 1`. `output.shape = [st_input.dense_shape[0], None]`.
Show Example
>>> st = SparseTensor(indices=[[0, 1], [0, 2], [0, 3], [1, 0], [3, 0]], ... values=[1, 2, 3, 4, 5], ... dense_shape=[4, 3]) >>> rt.RaggedTensor.from_sparse(st).eval().tolist() [[1, 2, 3], [4], [], [5]]
TClass from_sparse<TClass>(SparseTensor st_input, string name, ImplicitContainer<T> row_splits_dtype)
Converts a 2D
tf.SparseTensor
to a `RaggedTensor`. Each row of the `output` `RaggedTensor` will contain the explicit values
from the same row in `st_input`. `st_input` must be ragged-right. If not
it is not ragged-right, then an error will be generated. Example:
Currently, only two-dimensional `SparseTensors` are supported.
Parameters
-
SparseTensor
st_input - The sparse tensor to convert. Must have rank 2.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the same values as `st_input`. `output.ragged_rank = rank(st_input) - 1`. `output.shape = [st_input.dense_shape[0], None]`.
Show Example
>>> st = SparseTensor(indices=[[0, 1], [0, 2], [0, 3], [1, 0], [3, 0]], ... values=[1, 2, 3, 4, 5], ... dense_shape=[4, 3]) >>> rt.RaggedTensor.from_sparse(st).eval().tolist() [[1, 2, 3], [4], [], [5]]
object from_tensor_dyn<TClass>(object tensor, object lengths, object padding, ImplicitContainer<T> ragged_rank, object name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
object
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
object
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
ImplicitContainer<T>
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
object
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
object
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IEnumerable<int> lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IGraphNodeBase lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IEnumerable<int> lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IEnumerable<int> lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IEnumerable<int> lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IEnumerable<int> lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IEnumerable<int> lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, ValueTuple<IEnumerable<object>, object> lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IEnumerable<int> lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, ValueTuple<IEnumerable<object>, object> lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, ValueTuple<IEnumerable<object>, object> lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IEnumerable<int> lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IEnumerable<int>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, ValueTuple<IEnumerable<object>, object> lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IGraphNodeBase lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IGraphNodeBase lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IGraphNodeBase lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, ValueTuple<IEnumerable<object>, object> lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(object tensor, IGraphNodeBase lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
object
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, ValueTuple<IEnumerable<object>, object> lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IGraphNodeBase lengths, int padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IGraphNodeBase lengths, int padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
int
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, ValueTuple<IEnumerable<object>, object> lengths, IGraphNodeBase padding, int ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
int
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, ValueTuple<IEnumerable<object>, object> lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
ValueTuple<IEnumerable<object>, object>
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
TClass from_tensor<TClass>(IEnumerable<IGraphNodeBase> tensor, IGraphNodeBase lengths, IGraphNodeBase padding, Dimension ragged_rank, string name, ImplicitContainer<T> row_splits_dtype)
Converts a
tf.Tensor
into a `RaggedTensor`. The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If `lengths` is specified, then the
output tensor will satisfy `output[row] = tensor[row][:lengths[row]]`. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If `padding` is specified, then any row *suffix*
consisting entirely of `padding` will be excluded from the returned
`RaggedTensor`. If neither `lengths` nor `padding` is specified, then the
returned `RaggedTensor` will have no absent/default values. Examples:
Parameters
-
IEnumerable<IGraphNodeBase>
tensor - The `Tensor` to convert. Must have rank `ragged_rank + 1` or higher.
-
IGraphNodeBase
lengths - An optional set of row lengths, specified using a 1-D integer `Tensor` whose length is equal to `tensor.shape[0]` (the number of rows in `tensor`). If specified, then `output[row]` will contain `tensor[row][:lengths[row]]`. Negative lengths are treated as zero. You may optionally pass a list or tuple of lengths to this argument, which will be used as nested row lengths to construct a ragged tensor with multiple ragged dimensions.
-
IGraphNodeBase
padding - An optional padding value. If specified, then any row suffix consisting entirely of `padding` will be excluded from the returned RaggedTensor. `padding` is a `Tensor` with the same dtype as `tensor` and with `shape=tensor.shape[ragged_rank + 1:]`.
-
Dimension
ragged_rank - Integer specifying the ragged rank for the returned `RaggedTensor`. Must be greater than zero.
-
string
name - A name prefix for the returned tensors (optional).
-
ImplicitContainer<T>
row_splits_dtype - `dtype` for the returned `RaggedTensor`'s `row_splits`
tensor. One of
tf.int32
ortf.int64
.
Returns
-
TClass
- A `RaggedTensor` with the specified `ragged_rank`. The shape of the returned ragged tensor is compatible with the shape of `tensor`.
Show Example
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt)>>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) >>> tf.RaggedTensor.from_tensor(dt, padding=0) >>> dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) >>> tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
object from_value_rowids_dyn<TClass>(object values, object value_rowids, object nrows, object name, ImplicitContainer<T> validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
object
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
object
name - A name prefix for the RaggedTensor (optional).
-
ImplicitContainer<T>
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
object
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IEnumerable<IGraphNodeBase> values, IGraphNodeBase value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<IGraphNodeBase>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IGraphNodeBase values, IndexedSlices value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IndexedSlices
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(object values, PythonClassContainer value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
PythonClassContainer
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IEnumerable<IGraphNodeBase> values, PythonClassContainer value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<IGraphNodeBase>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
PythonClassContainer
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IEnumerable<IGraphNodeBase> values, int value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<IGraphNodeBase>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
int
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IEnumerable<IGraphNodeBase> values, IEnumerable<object> value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<IGraphNodeBase>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<object>
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IEnumerable<IGraphNodeBase> values, IndexedSlices value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IEnumerable<IGraphNodeBase>
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IndexedSlices
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IGraphNodeBase values, int value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
int
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IGraphNodeBase values, IEnumerable<PythonClassContainer> value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<PythonClassContainer>
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(RaggedTensor values, IEnumerable<PythonClassContainer> value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<PythonClassContainer>
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(RaggedTensor values, IndexedSlices value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IndexedSlices
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(object values, IGraphNodeBase value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(RaggedTensor values, int value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
int
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(object values, int value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
int
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(object values, IndexedSlices value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IndexedSlices
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(RaggedTensor values, IGraphNodeBase value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IGraphNodeBase values, PythonClassContainer value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
PythonClassContainer
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(object values, IEnumerable<PythonClassContainer> value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
object
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IEnumerable<PythonClassContainer>
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(RaggedTensor values, PythonClassContainer value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
RaggedTensor
values - A potentially ragged tensor with shape `[nvals,...]`.
-
PythonClassContainer
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
TClass from_value_rowids<TClass>(IGraphNodeBase values, IGraphNodeBase value_rowids, object nrows, string name, bool validate)
Creates a `RaggedTensor` with rows partitioned by `value_rowids`. The returned `RaggedTensor` corresponds with the python list defined by:
Parameters
-
IGraphNodeBase
values - A potentially ragged tensor with shape `[nvals,...]`.
-
IGraphNodeBase
value_rowids - A 1-D integer tensor with shape `[nvals]`, which corresponds one-to-one with `values`, and specifies each value's row index. Must be nonnegative, and must be sorted in ascending order.
-
object
nrows - An integer scalar specifying the number of rows. This should be specified if the `RaggedTensor` may containing empty training rows. Must be greater than `value_rowids[-1]` (or zero if `value_rowids` is empty). Defaults to `value_rowids[-1]` (or zero if `value_rowids` is empty).
-
string
name - A name prefix for the RaggedTensor (optional).
-
bool
validate - If true, then use assertions to check that the arguments form a valid `RaggedTensor`.
Returns
-
TClass
- A `RaggedTensor`. `result.rank = values.rank + 1`. `result.ragged_rank = values.ragged_rank + 1`.
Show Example
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
Public properties
object dtype get;
The `DType` of values in this tensor.
object dtype_dyn get;
The `DType` of values in this tensor.
Tensor flat_values get;
The innermost `values` tensor for this ragged tensor. Concretely, if `rt.values` is a `Tensor`, then `rt.flat_values` is
`rt.values`; otherwise, `rt.flat_values` is `rt.values.flat_values`. Conceptually, `flat_values` is the tensor formed by flattening the
outermost dimension and all of the ragged dimensions into a single
dimension. `rt.flat_values.shape = [nvals] + rt.shape[rt.ragged_rank + 1:]`
(where `nvals` is the number of items in the flattened dimensions).
object flat_values_dyn get;
The innermost `values` tensor for this ragged tensor. Concretely, if `rt.values` is a `Tensor`, then `rt.flat_values` is
`rt.values`; otherwise, `rt.flat_values` is `rt.values.flat_values`. Conceptually, `flat_values` is the tensor formed by flattening the
outermost dimension and all of the ragged dimensions into a single
dimension. `rt.flat_values.shape = [nvals] + rt.shape[rt.ragged_rank + 1:]`
(where `nvals` is the number of items in the flattened dimensions).
object Item get;
ValueTuple<object> nested_row_splits get;
A tuple containing the row_splits for all ragged dimensions. `rt.nested_row_splits` is a tuple containing the `row_splits` tensors for
all ragged dimensions in `rt`, ordered from outermost to innermost. In
particular, `rt.nested_row_splits = (rt.row_splits,) + value_splits` where: * `value_splits = ()` if `rt.values` is a `Tensor`.
* `value_splits = rt.values.nested_row_splits` otherwise.
object nested_row_splits_dyn get;
A tuple containing the row_splits for all ragged dimensions. `rt.nested_row_splits` is a tuple containing the `row_splits` tensors for
all ragged dimensions in `rt`, ordered from outermost to innermost. In
particular, `rt.nested_row_splits = (rt.row_splits,) + value_splits` where: * `value_splits = ()` if `rt.values` is a `Tensor`.
* `value_splits = rt.values.nested_row_splits` otherwise.
object PythonObject get;
int ragged_rank get;
The number of ragged dimensions in this ragged tensor.
object ragged_rank_dyn get;
The number of ragged dimensions in this ragged tensor.
object row_splits get;
The row-split indices for this ragged tensor's `values`. `rt.row_splits` specifies where the values for each row begin and end in
`rt.values`. In particular, the values for row `rt[i]` are stored in
the slice `rt.values[rt.row_splits[i]:rt.row_splits[i+1]]`.
object row_splits_dyn get;
The row-split indices for this ragged tensor's `values`. `rt.row_splits` specifies where the values for each row begin and end in
`rt.values`. In particular, the values for row `rt[i]` are stored in
the slice `rt.values[rt.row_splits[i]:rt.row_splits[i+1]]`.
TensorShape shape get;
The statically known shape of this ragged tensor.
object shape_dyn get;
The statically known shape of this ragged tensor.
object values get;
The concatenated rows for this ragged tensor. `rt.values` is a potentially ragged tensor formed by flattening the two
outermost dimensions of `rt` into a single dimension. `rt.values.shape = [nvals] + rt.shape[2:]` (where `nvals` is the
number of items in the outer two dimensions of `rt`). `rt.ragged_rank = self.ragged_rank - 1`
object values_dyn get;
The concatenated rows for this ragged tensor. `rt.values` is a potentially ragged tensor formed by flattening the two
outermost dimensions of `rt` into a single dimension. `rt.values.shape = [nvals] + rt.shape[2:]` (where `nvals` is the
number of items in the outer two dimensions of `rt`). `rt.ragged_rank = self.ragged_rank - 1`