# Module: tf.ragged

<br />

|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/ragged) |

Ragged Tensors.

This package defines ops for manipulating ragged tensors ([`tf.RaggedTensor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/RaggedTensor)),
which are tensors with non-uniform shapes. In particular, each `RaggedTensor`
has 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. For a more detailed
description of ragged tensors, see the [`tf.RaggedTensor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/RaggedTensor) class documentation
and the [Ragged Tensor Guide](https://www.tensorflow.org/guide/ragged_tensors).

### Additional ops that support `RaggedTensor`

Arguments that accept `RaggedTensor`s are marked in **bold**.

- [`tf.batch_gather`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/batch_gather)(**params** , **indices** , name=`None`)
- [`tf.bitwise.bitwise_and`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/bitwise_and)(**x** , **y** , name=`None`)
- [`tf.bitwise.bitwise_or`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/bitwise_or)(**x** , **y** , name=`None`)
- [`tf.bitwise.bitwise_xor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/bitwise_xor)(**x** , **y** , name=`None`)
- [`tf.bitwise.invert`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/invert)(**x** , name=`None`)
- [`tf.bitwise.left_shift`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/left_shift)(**x** , **y** , name=`None`)
- [`tf.bitwise.right_shift`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/bitwise/right_shift)(**x** , **y** , name=`None`)
- [`tf.cast`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/cast)(**x** , dtype, name=`None`)
- [`tf.clip_by_value`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/clip_by_value)(**t** , clip_value_min, clip_value_max, name=`None`)
- [`tf.concat`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/concat)(**values** , axis, name=`'concat'`)
- [`tf.debugging.check_numerics`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/debugging/check_numerics)(**tensor** , message, name=`None`)
- [`tf.dtypes.complex`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/dtypes/complex)(**real** , **imag** , name=`None`)
- [`tf.dtypes.saturate_cast`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/dtypes/saturate_cast)(**value** , dtype, name=`None`)
- [`tf.dynamic_partition`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/dynamic_partition)(**data** , **partitions** , num_partitions, name=`None`)
- [`tf.expand_dims`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/expand_dims)(**input** , axis=`None`, name=`None`, dim=`None`)
- [`tf.gather_nd`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/gather_nd)(**params** , **indices** , name=`None`, batch_dims=`0`)
- [`tf.gather`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/gather)(**params** , **indices** , validate_indices=`None`, name=`None`, axis=`None`, batch_dims=`0`)
- [`tf.identity`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/identity)(**input** , name=`None`)
- [`tf.io.decode_base64`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/decode_base64)(**input** , name=`None`)
- [`tf.io.decode_compressed`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/decode_compressed)(**bytes** , compression_type=`''`, name=`None`)
- [`tf.io.encode_base64`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/encode_base64)(**input** , pad=`False`, name=`None`)
- [`tf.math.abs`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/abs)(**x** , name=`None`)
- [`tf.math.acos`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/acos)(**x** , name=`None`)
- [`tf.math.acosh`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/acosh)(**x** , name=`None`)
- [`tf.math.add_n`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/add_n)(**inputs** , name=`None`)
- [`tf.math.add`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/add)(**x** , **y** , name=`None`)
- [`tf.math.angle`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/angle)(**input** , name=`None`)
- [`tf.math.asin`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/asin)(**x** , name=`None`)
- [`tf.math.asinh`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/asinh)(**x** , name=`None`)
- [`tf.math.atan2`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/atan2)(**y** , **x** , name=`None`)
- [`tf.math.atan`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/atan)(**x** , name=`None`)
- [`tf.math.atanh`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/atanh)(**x** , name=`None`)
- [`tf.math.ceil`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/ceil)(**x** , name=`None`)
- [`tf.math.conj`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/conj)(**x** , name=`None`)
- [`tf.math.cos`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/cos)(**x** , name=`None`)
- [`tf.math.cosh`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/cosh)(**x** , name=`None`)
- [`tf.math.digamma`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/digamma)(**x** , name=`None`)
- [`tf.math.divide_no_nan`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/divide_no_nan)(**x** , **y** , name=`None`)
- [`tf.math.divide`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/divide)(**x** , **y** , name=`None`)
- [`tf.math.equal`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/equal)(**x** , **y** , name=`None`)
- [`tf.math.erf`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/erf)(**x** , name=`None`)
- [`tf.math.erfc`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/erfc)(**x** , name=`None`)
- [`tf.math.exp`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/exp)(**x** , name=`None`)
- [`tf.math.expm1`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/expm1)(**x** , name=`None`)
- [`tf.math.floor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/floor)(**x** , name=`None`)
- [`tf.math.floordiv`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/floordiv)(**x** , **y** , name=`None`)
- [`tf.math.floormod`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/floormod)(**x** , **y** , name=`None`)
- [`tf.math.greater_equal`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/greater_equal)(**x** , **y** , name=`None`)
- [`tf.math.greater`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/greater)(**x** , **y** , name=`None`)
- [`tf.math.imag`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/imag)(**input** , name=`None`)
- [`tf.math.is_finite`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/is_finite)(**x** , name=`None`)
- [`tf.math.is_inf`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/is_inf)(**x** , name=`None`)
- [`tf.math.is_nan`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/is_nan)(**x** , name=`None`)
- [`tf.math.less_equal`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/less_equal)(**x** , **y** , name=`None`)
- [`tf.math.less`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/less)(**x** , **y** , name=`None`)
- [`tf.math.lgamma`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/lgamma)(**x** , name=`None`)
- [`tf.math.log1p`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/log1p)(**x** , name=`None`)
- [`tf.math.log_sigmoid`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/log_sigmoid)(**x** , name=`None`)
- [`tf.math.log`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/log)(**x** , name=`None`)
- [`tf.math.logical_and`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/logical_and)(**x** , **y** , name=`None`)
- [`tf.math.logical_not`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/logical_not)(**x** , name=`None`)
- [`tf.math.logical_or`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/logical_or)(**x** , **y** , name=`None`)
- [`tf.math.logical_xor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/logical_xor)(**x** , **y** , name=`'LogicalXor'`)
- [`tf.math.maximum`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/maximum)(**x** , **y** , name=`None`)
- [`tf.math.minimum`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/minimum)(**x** , **y** , name=`None`)
- [`tf.math.multiply`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/multiply)(**x** , **y** , name=`None`)
- [`tf.math.negative`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/negative)(**x** , name=`None`)
- [`tf.math.not_equal`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/not_equal)(**x** , **y** , name=`None`)
- [`tf.math.pow`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/pow)(**x** , **y** , name=`None`)
- [`tf.math.real`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/real)(**input** , name=`None`)
- [`tf.math.reciprocal`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reciprocal)(**x** , name=`None`)
- [`tf.math.reduce_any`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_any)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.reduce_max`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_max)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.reduce_mean`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_mean)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.reduce_min`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_min)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.reduce_prod`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_prod)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.reduce_sum`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_sum)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.math.rint`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/rint)(**x** , name=`None`)
- [`tf.math.round`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/round)(**x** , name=`None`)
- [`tf.math.rsqrt`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/rsqrt)(**x** , name=`None`)
- [`tf.math.sign`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/sign)(**x** , name=`None`)
- [`tf.math.sin`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/sin)(**x** , name=`None`)
- [`tf.math.sinh`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/sinh)(**x** , name=`None`)
- [`tf.math.sqrt`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/sqrt)(**x** , name=`None`)
- [`tf.math.square`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/square)(**x** , name=`None`)
- [`tf.math.squared_difference`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/squared_difference)(**x** , **y** , name=`None`)
- [`tf.math.subtract`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/subtract)(**x** , **y** , name=`None`)
- [`tf.math.tan`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/tan)(**x** , name=`None`)
- [`tf.math.truediv`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/truediv)(**x** , **y** , name=`None`)
- [`tf.math.unsorted_segment_max`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_max)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.math.unsorted_segment_mean`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_mean)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.math.unsorted_segment_min`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_min)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.math.unsorted_segment_prod`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_prod)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.math.unsorted_segment_sqrt_n`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_sqrt_n)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.math.unsorted_segment_sum`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/unsorted_segment_sum)(**data** , **segment_ids** , num_segments, name=`None`)
- [`tf.one_hot`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/one_hot)(**indices** , depth, on_value=`None`, off_value=`None`, axis=`None`, dtype=`None`, name=`None`)
- [`tf.ones_like`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ones_like)(**tensor** , dtype=`None`, name=`None`, optimize=`True`)
- [`tf.rank`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/rank)(**input** , name=`None`)
- [`tf.realdiv`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/realdiv)(**x** , **y** , name=`None`)
- [`tf.reduce_all`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/reduce_all)(**input_tensor** , axis=`None`, keepdims=`False`, name=`None`)
- [`tf.size`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/size)(**input** , name=`None`, out_type=[`tf.int32`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf#int32))
- [`tf.squeeze`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/squeeze)(**input** , axis=`None`, name=`None`, squeeze_dims=`None`)
- [`tf.stack`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/stack)(**values** , axis=`0`, name=`'stack'`)
- [`tf.strings.as_string`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/as_string)(**input** , precision=`-1`, scientific=`False`, shortest=`False`, width=`-1`, fill=`''`, name=`None`)
- [`tf.strings.join`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/join)(**inputs** , separator=`''`, name=`None`)
- [`tf.strings.length`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/length)(**input** , name=`None`, unit=`'BYTE'`)
- [`tf.strings.reduce_join`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/reduce_join)(**inputs** , axis=`None`, keepdims=`False`, separator=`''`, name=`None`)
- [`tf.strings.regex_full_match`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/regex_full_match)(**input** , pattern, name=`None`)
- [`tf.strings.regex_replace`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/regex_replace)(**input** , pattern, rewrite, replace_global=`True`, name=`None`)
- [`tf.strings.strip`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/strip)(**input** , name=`None`)
- [`tf.strings.substr`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/substr)(**input** , pos, len, name=`None`, unit=`'BYTE'`)
- [`tf.strings.to_hash_bucket_fast`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/to_hash_bucket_fast)(**input** , num_buckets, name=`None`)
- [`tf.strings.to_hash_bucket_strong`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/to_hash_bucket_strong)(**input** , num_buckets, key, name=`None`)
- [`tf.strings.to_hash_bucket`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/to_hash_bucket)(**input** , num_buckets, name=`None`)
- [`tf.strings.to_hash_bucket`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/to_hash_bucket)(**input** , num_buckets, name=`None`)
- [`tf.strings.to_number`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/to_number)(**input** , out_type=[`tf.float32`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf#float32), name=`None`)
- [`tf.strings.unicode_script`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/strings/unicode_script)(**input** , name=`None`)
- [`tf.tile`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/tile)(**input** , multiples, name=`None`)
- [`tf.truncatediv`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/truncatediv)(**x** , **y** , name=`None`)
- [`tf.truncatemod`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/truncatemod)(**x** , **y** , name=`None`)
- [`tf.where`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/where)(**condition** , **x** =`None`, **y** =`None`, name=`None`)
- [`tf.zeros_like`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/zeros_like)(**tensor** , dtype=`None`, name=`None`, optimize=`True`)n

## Classes

[`class RaggedTensorValue`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/RaggedTensorValue): Represents the value of a `RaggedTensor`.

## Functions

[`boolean_mask(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/boolean_mask): Applies a boolean mask to `data` without flattening the mask dimensions.

[`constant(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/constant): Constructs a constant RaggedTensor from a nested Python list.

[`constant_value(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/constant_value): Constructs a RaggedTensorValue from a nested Python list.

[`map_flat_values(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/map_flat_values): Applies `op` to the values of one or more RaggedTensors.

[`placeholder(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/placeholder): Creates a placeholder for a [`tf.RaggedTensor`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/RaggedTensor) that will always be fed.

[`range(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/range): Returns a `RaggedTensor` containing the specified sequences of numbers.

[`row_splits_to_segment_ids(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/row_splits_to_segment_ids): Generates the segmentation corresponding to a RaggedTensor `row_splits`.

[`segment_ids_to_row_splits(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/segment_ids_to_row_splits): Generates the RaggedTensor `row_splits` corresponding to a segmentation.

[`stack(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/stack): Stacks a list of rank-`R` tensors into one rank-`(R+1)` `RaggedTensor`.

[`stack_dynamic_partitions(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/ragged/stack_dynamic_partitions): Stacks dynamic partitions of a Tensor or RaggedTensor.