堆疊張量或 RaggedTensor 的動態分區。
用法
tf.ragged.stack_dynamic_partitions(
data, partitions, num_partitions, name=None
)參數
-
data包含要堆棧的值的Tensor或RaggedTensor。 -
partitionsint32或int64Tensor或RaggedTensor指定應將data的每個切片添加到的分區。partitions.shape必須是data.shape的前綴。值必須大於或等於零,並且小於num_partitions。partitions不需要排序。 -
num_partitionsint32或int64標量指定要輸出的分區數。這決定了output中的行數。 -
name返回張量的名稱前綴(可選)。
返回
-
包含堆疊分區的
RaggedTensor。返回的張量具有與data相同的 dtype,其形狀為[num_partitions, (D)] + data.shape[partitions.rank:],其中(D)是一個參差不齊的維度,其長度是為每個partition堆疊的數據切片的數量。
返回帶有 num_partitions 行的 RaggedTensor output,其中行 output[i] 是通過堆疊所有切片 data[j1...jN] 以使得 partitions[j1...jN] = i 形成的。 data 的切片按行優先順序堆疊。
如果 num_partitions 是 int (不是 Tensor ),那麽這等效於 tf.ragged.stack(tf.dynamic_partition(data, partitions, num_partitions)) 。
例子:
data = ['a', 'b', 'c', 'd', 'e']
partitions = [ 3, 0, 2, 2, 3]
num_partitions = 5
tf.ragged.stack_dynamic_partitions(data, partitions, num_partitions)
<tf.RaggedTensor [[b'b'], [], [b'c', b'd'], [b'a', b'e'], []]>
相關用法
- Python tf.ragged.stack用法及代碼示例
- Python tf.ragged.segment_ids_to_row_splits用法及代碼示例
- Python tf.ragged.cross用法及代碼示例
- Python tf.ragged.boolean_mask用法及代碼示例
- Python tf.ragged.map_flat_values用法及代碼示例
- Python tf.ragged.range用法及代碼示例
- Python tf.ragged.row_splits_to_segment_ids用法及代碼示例
- Python tf.ragged.cross_hashed用法及代碼示例
- Python tf.ragged.constant用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代碼示例
- Python tf.raw_ops.BatchMatMul用法及代碼示例
- Python tf.raw_ops.OneHot用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代碼示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代碼示例
- Python tf.raw_ops.GatherV2用法及代碼示例
- Python tf.raw_ops.Expm1用法及代碼示例
- Python tf.range用法及代碼示例
- Python tf.raw_ops.BitwiseAnd用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.ragged.stack_dynamic_partitions。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
