tf.RaggedTensor 的類型規範。
繼承自:TypeSpec
用法
tf.RaggedTensorSpec(
shape=None, dtype=tf.dtypes.float32, ragged_rank=None,
row_splits_dtype=tf.dtypes.int64, flat_values_spec=None
)參數
-
shapeRaggedTensor 的形狀,或None以允許任何形狀。如果指定了形狀,則所有參差不齊的尺寸都必須具有大小None。 -
dtypeRaggedTensor 中的tf.DType個值。 -
ragged_rankPython 整數,RaggedTensor 的flat_values 被分區的次數。默認為shape.ndims - 1。 -
row_splits_dtypedtype用於 RaggedTensor 的row_splits張量。tf.int32或tf.int64之一。 -
flat_values_specRaggedTensor 的 flat_value 的 TypeSpec。當flat_values 是 CompositeTensor 而不是 Tensor 時,應提供它。如果同時提供dtype和flat_values_spec和 ,則dtype必須與flat_values_spec.dtype相同。 (實驗性)
屬性
-
dtypetf.dtypes.DType此類型為 RaggedTensor 指定。rt = tf.ragged.constant([["a"], ["b", "c"]], dtype=tf.string) tf.type_spec_from_value(rt).dtype tf.string -
flat_values_specRaggedTensor 的flat_values 的TypeSpec。 -
ragged_rankRaggedTensor 的flat_values 被分區的次數。默認為
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 1rt1 = tf.RaggedTensor.from_uniform_row_length(values, 2) tf.type_spec_from_value(rt1).ragged_rank 2 -
row_splits_dtypetf.dtypes.DTypeRaggedTensor 的row_splits.rt = tf.ragged.constant([[1, 2, 3], [4]], row_splits_dtype=tf.int64) tf.type_spec_from_value(rt).row_splits_dtype tf.int64 -
shapeRaggedTensor 的靜態已知形狀。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]) -
value_type與此 TypeSpec 兼容的值的 Python 類型。特別是,所有與此 TypeSpec 兼容的值都必須是此類型的實例。
相關用法
- Python tf.RaggedTensor.row_lengths用法及代碼示例
- Python tf.RaggedTensor.__rmul__用法及代碼示例
- Python tf.RaggedTensor.from_uniform_row_length用法及代碼示例
- Python tf.RaggedTensor.__radd__用法及代碼示例
- Python tf.RaggedTensor.__pow__用法及代碼示例
- Python tf.RaggedTensor.__rand__用法及代碼示例
- Python tf.RaggedTensor.numpy用法及代碼示例
- Python tf.RaggedTensor.get_shape用法及代碼示例
- Python tf.RaggedTensor.__xor__用法及代碼示例
- Python tf.RaggedTensor.__gt__用法及代碼示例
- Python tf.RaggedTensor.__getitem__用法及代碼示例
- Python tf.RaggedTensor.__rpow__用法及代碼示例
- Python tf.RaggedTensor.row_limits用法及代碼示例
- Python tf.RaggedTensor.nested_value_rowids用法及代碼示例
- Python tf.RaggedTensor.__rxor__用法及代碼示例
- Python tf.RaggedTensor.from_value_rowids用法及代碼示例
- Python tf.RaggedTensor.from_nested_row_lengths用法及代碼示例
- Python tf.RaggedTensor.__ror__用法及代碼示例
- Python tf.RaggedTensor.__rsub__用法及代碼示例
- Python tf.RaggedTensor.__abs__用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.RaggedTensorSpec。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
