Python integer, the number of times the RaggedTensor's
flat_values is partitioned. Defaults to shape.ndims - 1.
row_splits_dtype
dtype for the RaggedTensor's row_splits tensor. One
of tf.int32 or tf.int64.
flat_values_spec
TypeSpec for flat_value of the RaggedTensor. It shall be
provided when the flat_values is a CompositeTensor rather then Tensor.
If both dtype and flat_values_spec and are provided, dtype must
be the same as flat_values_spec.dtype. (experimental)
Attributes
dtype
The tf.dtypes.DType specified by this type for the RaggedTensor.
Implements the tf.types.experimental.func.TraceType interface.
If not overridden by a subclass, the default behavior is to assume the
TypeSpec is covariant upon attributes that implement TraceType and
invariant upon rest of the attributes as well as the structure and type
of the TypeSpec.
Returns the most specific supertype TypeSpec of self and others.
Implements the tf.types.experimental.func.TraceType interface.
If not overridden by a subclass, the default behavior is to assume the
TypeSpec is covariant upon attributes that implement TraceType and
invariant upon rest of the attributes as well as the structure and type
of the TypeSpec.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-03-17 UTC."],[],[],null,["# tf.RaggedTensorSpec\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/ops/ragged/ragged_tensor.py#L2307-L2634) |\n\nType specification for a [`tf.RaggedTensor`](../tf/RaggedTensor).\n\nInherits From: [`TypeSpec`](../tf/TypeSpec), [`TraceType`](../tf/types/experimental/TraceType)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.RaggedTensorSpec`](https://www.tensorflow.org/api_docs/python/tf/RaggedTensorSpec)\n\n\u003cbr /\u003e\n\n tf.RaggedTensorSpec(\n shape=None,\n dtype=../tf/dtypes#float32,\n ragged_rank=None,\n row_splits_dtype=../tf/dtypes#int64,\n flat_values_spec=None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `shape` | The shape of the RaggedTensor, or `None` to allow any shape. If a shape is specified, then all ragged dimensions must have size `None`. |\n| `dtype` | [`tf.DType`](../tf/dtypes/DType) of values in the RaggedTensor. |\n| `ragged_rank` | Python integer, the number of times the RaggedTensor's flat_values is partitioned. Defaults to `shape.ndims - 1`. |\n| `row_splits_dtype` | `dtype` for the RaggedTensor's `row_splits` tensor. One of [`tf.int32`](../tf#int32) or [`tf.int64`](../tf#int64). |\n| `flat_values_spec` | TypeSpec for flat_value of the RaggedTensor. It shall be provided when the flat_values is a CompositeTensor rather then Tensor. If both `dtype` and `flat_values_spec` and are provided, `dtype` must be the same as `flat_values_spec.dtype`. (experimental) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dtype` | The [`tf.dtypes.DType`](../tf/dtypes/DType) specified by this type for the RaggedTensor. \u003cbr /\u003e rt = tf.ragged.constant([[\"a\"], [\"b\", \"c\"]], dtype=tf.string) tf.type_spec_from_value(rt).dtype tf.string \u003cbr /\u003e |\n| `flat_values_spec` | The `TypeSpec` of the flat_values of RaggedTensor. |\n| `ragged_rank` | The number of times the RaggedTensor's flat_values is partitioned. \u003cbr /\u003e Defaults to `shape.ndims - 1`. values = tf.ragged.constant([[1, 2, 3], [4], [5, 6], [7, 8, 9, 10]]) tf.type_spec_from_value(values).ragged_rank 1 rt1 = tf.RaggedTensor.from_uniform_row_length(values, 2) tf.type_spec_from_value(rt1).ragged_rank 2 \u003cbr /\u003e |\n| `row_splits_dtype` | The [`tf.dtypes.DType`](../tf/dtypes/DType) of the RaggedTensor's `row_splits`. \u003cbr /\u003e rt = tf.ragged.constant([[1, 2, 3], [4]], row_splits_dtype=tf.int64) tf.type_spec_from_value(rt).row_splits_dtype tf.int64 \u003cbr /\u003e |\n| `shape` | The statically known shape of the RaggedTensor. \u003cbr /\u003e rt = tf.ragged.constant([[0], [1, 2]]) tf.type_spec_from_value(rt).shape TensorShape([2, None]) rt = tf.ragged.constant([[[0, 1]], [[1, 2], [3, 4]]], ragged_rank=1) tf.type_spec_from_value(rt).shape TensorShape([2, None, 2]) \u003cbr /\u003e |\n| `value_type` | The Python type for values that are compatible with this TypeSpec. \u003cbr /\u003e In particular, all values that are compatible with this TypeSpec must be an instance of this type. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `from_value`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/ops/ragged/ragged_tensor.py#L2619-L2634) \n\n @classmethod\n from_value(\n value\n )\n\n### `is_compatible_with`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/ops/ragged/ragged_tensor.py#L2455-L2464) \n\n is_compatible_with(\n spec_or_value\n )\n\nReturns true if `spec_or_value` is compatible with this TypeSpec.\n\nPrefer using \"is_subtype_of\" and \"most_specific_common_supertype\" wherever\npossible.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------------|-------------------------------------------------------------|\n| `spec_or_value` | A TypeSpec or TypeSpec associated value to compare against. |\n\n\u003cbr /\u003e\n\n### `is_subtype_of`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/framework/type_spec.py#L100-L137) \n\n is_subtype_of(\n other: ../tf/types/experimental/TraceType\n ) -\u003e bool\n\nReturns True if `self` is a subtype of `other`.\n\nImplements the tf.types.experimental.func.TraceType interface.\n\nIf not overridden by a subclass, the default behavior is to assume the\nTypeSpec is covariant upon attributes that implement TraceType and\ninvariant upon rest of the attributes as well as the structure and type\nof the TypeSpec.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|---------------------|\n| `other` | A TraceType object. |\n\n\u003cbr /\u003e\n\n### `most_specific_common_supertype`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/framework/type_spec.py#L139-L185) \n\n most_specific_common_supertype(\n others: Sequence[../tf/types/experimental/TraceType]\n ) -\u003e Optional['TypeSpec']\n\nReturns the most specific supertype TypeSpec of `self` and `others`.\n\nImplements the tf.types.experimental.func.TraceType interface.\n\nIf not overridden by a subclass, the default behavior is to assume the\nTypeSpec is covariant upon attributes that implement TraceType and\ninvariant upon rest of the attributes as well as the structure and type\nof the TypeSpec.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|---------------------------|\n| `others` | A sequence of TraceTypes. |\n\n\u003cbr /\u003e\n\n### `most_specific_compatible_type`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/framework/type_spec.py#L216-L234) \n\n most_specific_compatible_type(\n other: 'TypeSpec'\n ) -\u003e 'TypeSpec'\n\nReturns the most specific TypeSpec compatible with `self` and `other`. (deprecated)\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use most_specific_common_supertype instead.\n\nDeprecated. Please use `most_specific_common_supertype` instead.\nDo not override this function.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|---------------|\n| `other` | A `TypeSpec`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|--------------------------------------------------------------------------|\n| `ValueError` | If there is no TypeSpec that is compatible with both `self` and `other`. |\n\n\u003cbr /\u003e\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/framework/type_spec.py#L438-L441) \n\n __eq__(\n other\n ) -\u003e bool\n\nReturn self==value.\n\n### `__ne__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/framework/type_spec.py#L443-L444) \n\n __ne__(\n other\n ) -\u003e bool\n\nReturn self!=value."]]