用法
@classmethod
from_row_starts(
values, row_starts, name=None, validate=True
)
參數
-
values
形狀可能參差不齊的張量[nvals, ...]
。 -
row_starts
形狀為[nrows]
的一維整數張量。必須為非負數並按升序排序。如果nrows>0
,則row_starts[0]
必須為零。 -
name
RaggedTensor 的名稱前綴(可選)。 -
validate
如果為真,則使用斷言檢查參數是否形成有效的RaggedTensor
。注意:這些斷言會產生運行時成本,因為必須檢查每個張量值。
返回
-
一個
RaggedTensor
。result.rank = values.rank + 1
。result.ragged_rank = values.ragged_rank + 1
。
創建一個 RaggedTensor
,其中行由 row_starts
分區。
相當於:from_row_splits(values, concat([row_starts, nvals]))
.
例子:
print(tf.RaggedTensor.from_row_starts(
values=[3, 1, 4, 1, 5, 9, 2, 6],
row_starts=[0, 4, 4, 7, 8]))
<tf.RaggedTensor [[3, 1, 4, 1], [], [5, 9, 2], [6], []]>
相關用法
- Python tf.RaggedTensor.from_row_splits用法及代碼示例
- Python tf.RaggedTensor.from_row_limits用法及代碼示例
- Python tf.RaggedTensor.from_row_lengths用法及代碼示例
- Python tf.RaggedTensor.from_uniform_row_length用法及代碼示例
- Python tf.RaggedTensor.from_value_rowids用法及代碼示例
- Python tf.RaggedTensor.from_nested_row_lengths用法及代碼示例
- Python tf.RaggedTensor.from_tensor用法及代碼示例
- Python tf.RaggedTensor.from_nested_row_splits用法及代碼示例
- Python tf.RaggedTensor.from_sparse用法及代碼示例
- Python tf.RaggedTensor.from_nested_value_rowids用法及代碼示例
- Python tf.RaggedTensor.row_lengths用法及代碼示例
- Python tf.RaggedTensor.__rmul__用法及代碼示例
- 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__用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.RaggedTensor.from_row_starts。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。