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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
