當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.RaggedTensor.bounding_shape用法及代碼示例

用法

bounding_shape(
    axis=None, name=None, out_type=None
)

參數

  • axis 一個整數標量或向量,指示要為其返回邊界框的軸。如果未指定,則返回完整的邊界框。
  • name 返回張量的名稱前綴(可選)。
  • out_type dtype 用於返回的張量。默認為 self.row_splits.dtype

返回

  • 一個整數 Tensor ( dtype=self.row_splits.dtype )。如果未指定 axis,則 output 是帶有 output.shape=[self.shape.ndims] 的向量。如果axis 是標量,則output 是標量。如果 axis 是向量,則 output 是向量,其中 output[i] 是維度 axis[i] 的邊界大小。

返回此 RaggedTensor 的緊密邊界框形狀。

例子:

rt = tf.ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]])
rt.bounding_shape().numpy()
array([5, 4])

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.RaggedTensor.bounding_shape。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。