從嵌套的 Python 列表構造一個 RaggedTensorValue。
用法
tf.compat.v1.ragged.constant_value(
pylist, dtype=None, ragged_rank=None, inner_shape=None,
row_splits_dtype='int64'
)參數
-
pylist嵌套的list,tuple或np.ndarray。任何不是list或tuple的嵌套元素必須是與dtype兼容的標量值。 -
dtypenumpy.dtype。返回的RaggedTensor的元素類型。如果未指定,則根據pylist中的標量值選擇默認值。 -
ragged_rank一個整數,指定返回的RaggedTensorValue的不規則排名。必須為非負數且小於K。如果未指定inner_shape,則默認為max(0, K - 1)。如果指定了inner_shape,則默認為max(0, K 1 - len(inner_shape))。 -
inner_shape一個整數元組,指定返回的RaggedTensorValue中各個內部值的形狀。如果未指定ragged_rank,則默認為()。如果指定了ragged_rank,則根據pylist的內容選擇默認值。 -
row_splits_dtype構造的RaggedTensorValue的 row_splits 的數據類型。numpy.int32或numpy.int64之一
返回
-
具有等級
K和指定的tf.RaggedTensorValue或numpy.array和指定的ragged_rank,包含來自pylist的值。
拋出
-
ValueError如果pylist中的標量值嵌套深度不一致;或者如果 ragged_rank 或 inner_shape 與pylist不兼容。
警告:此函數返回 RaggedTensorValue ,而不是 RaggedTensor 。如果您希望構造一個常量 RaggedTensor ,請改用 ragged.constant(...)。
例子:
tf.compat.v1.ragged.constant_value([[1, 2], [3], [4, 5, 6]])
tf.RaggedTensorValue(values=array([1, 2, 3, 4, 5, 6]),
row_splits=array([0, 2, 3, 6]))
pylist 中的所有標量值必須具有相同的嵌套深度 K ,並且返回的 RaggedTensorValue 將具有排名 K 。如果 pylist 不包含標量值,則 K 比 pylist 中空列表的最大深度大一。 pylist 中的所有標量值必須與 dtype 兼容。
相關用法
- Python tf.compat.v1.random.stateless_multinomial用法及代碼示例
- Python tf.compat.v1.random_uniform_initializer.from_config用法及代碼示例
- Python tf.compat.v1.random_normal_initializer用法及代碼示例
- Python tf.compat.v1.random_normal_initializer.from_config用法及代碼示例
- Python tf.compat.v1.random_poisson用法及代碼示例
- Python tf.compat.v1.random_uniform_initializer用法及代碼示例
- Python tf.compat.v1.reduce_sum用法及代碼示例
- Python tf.compat.v1.reduce_any用法及代碼示例
- Python tf.compat.v1.reduce_max用法及代碼示例
- Python tf.compat.v1.reduce_min用法及代碼示例
- Python tf.compat.v1.reduce_all用法及代碼示例
- Python tf.compat.v1.reverse_sequence用法及代碼示例
- Python tf.compat.v1.reduce_join用法及代碼示例
- Python tf.compat.v1.reduce_prod用法及代碼示例
- Python tf.compat.v1.reduce_logsumexp用法及代碼示例
- Python tf.compat.v1.reduce_mean用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.ragged.constant_value。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
