tf.compat.v1.ragged.constant_value | TensorFlow v2.16.1 (original) (raw)
Constructs a RaggedTensorValue from a nested Python list.
tf.compat.v1.ragged.constant_value(
pylist,
dtype=None,
ragged_rank=None,
inner_shape=None,
row_splits_dtype='int64'
) -> Union[tf.compat.v1.ragged.RaggedTensorValue, np.ndarray]
Example:
tf.compat.v1.ragged.constant_value([[1, 2], [3], [4, 5, 6]])
tf.RaggedTensorValue(values=array([1, 2, 3, 4, 5, 6]),
row_splits=array([0, 2, 3, 6]))
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
.
Returns |
---|
A tf.RaggedTensorValue or numpy.array with rank K and the specifiedragged_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. |