从嵌套的 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
