All scalar values in pylist must have the same nesting depth K, and the
returned RaggedTensorValue will have rank K. If pylist contains no
scalar values, then K is one greater than the maximum depth of empty lists
in pylist. All scalar values in pylist must be compatible with dtype.
Args
pylist
A nested list, tuple or np.ndarray. Any nested element that
is not a list or tuple must be a scalar value compatible with dtype.
dtype
numpy.dtype. The type of elements for the returned RaggedTensor.
If not specified, then a default is chosen based on the scalar values in
pylist.
ragged_rank
An integer specifying the ragged rank of the returned
RaggedTensorValue. Must be nonnegative and less than K. Defaults to
max(0, K - 1) if inner_shape is not specified. Defaults to `max(0, K
1 - len(inner_shape))ifinner_shapeis specified.
</td>
</tr><tr>
<td>inner_shape</td>
<td>
A tuple of integers specifying the shape for individual inner
values in the returnedRaggedTensorValue. Defaults to()ifragged_rankis not specified. Ifragged_rankis specified, then a
default is chosen based on the contents ofpylist.
</td>
</tr><tr>
<td>row_splits_dtype</td>
<td>
data type for the constructedRaggedTensorValue's
row_splits. One ofnumpy.int32ornumpy.int64`.
Returns
A tf.RaggedTensorValue or numpy.array with rank K and the specified
ragged_rank, containing the values from pylist.
Raises
ValueError
If the scalar values in pylist have inconsistent nesting
depth; or if ragged_rank or inner_shape are incompatible with pylist.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.ragged.constant_value\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/ragged/ragged_factory_ops.py#L90-L147) |\n\nConstructs a RaggedTensorValue from a nested Python list.\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.ragged.constant_value`](/api_docs/python/tf/compat/v1/ragged/constant_value)\n\n\u003cbr /\u003e\n\n tf.ragged.constant_value(\n pylist, dtype=None, ragged_rank=None, inner_shape=None, row_splits_dtype='int64'\n )\n\n| **Warning:** This function returns a `RaggedTensorValue`, not a `RaggedTensor`. If you wish to construct a constant `RaggedTensor`, use [`ragged.constant(...)`](/versions/r1.15/api_docs/python/tf/ragged/constant) instead.\n\n#### Example:\n\n ragged.constant_value([[1, 2], [3], [4, 5, 6]])\n RaggedTensorValue(values=[1, 2, 3, 4, 5, 6], splits=[0, 2, 3, 6])\n\nAll scalar values in `pylist` must have the same nesting depth `K`, and the\nreturned `RaggedTensorValue` will have rank `K`. If `pylist` contains no\nscalar values, then `K` is one greater than the maximum depth of empty lists\nin `pylist`. All scalar values in `pylist` must be compatible with `dtype`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `pylist` | A nested `list`, `tuple` or `np.ndarray`. Any nested element that is not a `list` or `tuple` must be a scalar value compatible with `dtype`. |\n| `dtype` | `numpy.dtype`. The type of elements for the returned `RaggedTensor`. If not specified, then a default is chosen based on the scalar values in `pylist`. |\n| `ragged_rank` | An integer specifying the ragged rank of the returned `RaggedTensorValue`. Must be nonnegative and less than `K`. Defaults to `max(0, K - 1)` if `inner_shape` is not specified. Defaults to \\`max(0, K \u003cbr /\u003e - 1 - len(inner_shape))`if`inner_shape`is specified. \u003c/td\u003e \u003c/tr\u003e\u003ctr\u003e \u003ctd\u003e`inner_shape`\u003c/td\u003e \u003ctd\u003e A tuple of integers specifying the shape for individual inner values in the returned`RaggedTensorValue`. Defaults to`()`if`ragged_rank`is not specified. If`ragged_rank`is specified, then a default is chosen based on the contents of`pylist`. \u003c/td\u003e \u003c/tr\u003e\u003ctr\u003e \u003ctd\u003e`row_splits_dtype`\u003c/td\u003e \u003ctd\u003e data type for the constructed`RaggedTensorValue`'s row_splits. One of`numpy.int32`or`numpy.int64\\`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `tf.RaggedTensorValue` or `numpy.array` with rank `K` and the specified `ragged_rank`, containing the values from `pylist`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | If the scalar values in `pylist` have inconsistent nesting depth; or if ragged_rank or inner_shape are incompatible with `pylist`. |\n\n\u003cbr /\u003e"]]