用法
numpy()
返回
-
一個 numpy 的
array
。
返回一個帶有此 RaggedTensor
值的 numpy array
。
要求此 RaggedTensor
是在即刻執行模式下構造的。
參差不齊的維度使用 numpy arrays
和 dtype=object
和 rank=1
進行編碼,其中每個元素都是一行。
例子
在以下示例中,RaggedTensor.numpy()
返回的值包含三個 numpy array
對象:每行一個(帶有 rank=1
和 dtype=int64
),一個用於組合它們(帶有 rank=1
和 dtype=object
) :
tf.ragged.constant([[1, 2, 3], [4, 5]], dtype=tf.int64).numpy()
array([array([1, 2, 3]), array([4, 5])], dtype=object)
統一維度使用多維 numpy array
s 編碼。在以下示例中,RaggedTensor.numpy()
返回的值包含單個 numpy array
對象,帶有 rank=2
和 dtype=int64
:
tf.ragged.constant([[1, 2, 3], [4, 5, 6]], dtype=tf.int64).numpy()
array([[1, 2, 3], [4, 5, 6]])
相關用法
- Python tf.RaggedTensor.nested_value_rowids用法及代碼示例
- Python tf.RaggedTensor.nrows用法及代碼示例
- 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.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.__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.RaggedTensor.numpy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。