重塑 SparseTensor 以在新的密集形状中表示值。
用法
tf.sparse.reshape(
sp_input, shape, name=None
)参数
-
sp_input输入SparseTensor。 -
shape一维(向量)int64Tensor指定表示的SparseTensor的新密集形状。 -
name返回张量的名称前缀(可选)
返回
-
SparseTensor具有相同的非空值,但具有由新密集形状计算的索引。
抛出
-
TypeError如果sp_input不是SparseTensor。 -
ValueError如果参数shape请求的SparseTensor元素数量与sp_input不同。 -
ValueError如果shape具有多个推断 (== -1) 维度。
此操作在表示的密集张量上具有与 reshape 相同的语义。 sp_input 中非空值的索引基于新的密集形状重新计算,并返回包含新索引和新形状的新 SparseTensor。 sp_input 中非空值的顺序不变。
如果 shape 的一个分量是特殊值 -1,则计算该维度的大小,以便总密集大小保持不变。 shape 的最多一个分量可以是-1。 shape 隐含的密集元素的数量必须与最初由 sp_input 表示的密集元素的数量相同。
例如,如果 sp_input 具有形状 [2, 3, 6] 和 indices /values :
[0, 0, 0]:a
[0, 0, 1]:b
[0, 1, 0]:c
[1, 0, 0]:d
[1, 2, 3]:e
和 shape 是 [9, -1] ,那么输出将是形状为 [9, 4] 和 indices /values 的 SparseTensor :
[0, 0]:a
[0, 1]:b
[1, 2]:c
[4, 2]:d
[8, 1]:e
相关用法
- Python tf.sparse.reduce_sum用法及代码示例
- Python tf.sparse.retain用法及代码示例
- Python tf.sparse.reduce_max用法及代码示例
- Python tf.sparse.reorder用法及代码示例
- Python tf.sparse.cross用法及代码示例
- Python tf.sparse.mask用法及代码示例
- Python tf.sparse.split用法及代码示例
- Python tf.sparse.to_dense用法及代码示例
- Python tf.sparse.expand_dims用法及代码示例
- Python tf.sparse.maximum用法及代码示例
- Python tf.sparse.bincount用法及代码示例
- Python tf.sparse.concat用法及代码示例
- Python tf.sparse.transpose用法及代码示例
- Python tf.sparse.softmax用法及代码示例
- Python tf.sparse.to_indicator用法及代码示例
- Python tf.sparse.from_dense用法及代码示例
- Python tf.sparse.minimum用法及代码示例
- Python tf.sparse.segment_sum用法及代码示例
- Python tf.sparse.fill_empty_rows用法及代码示例
- Python tf.sparse.slice用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.sparse.reshape。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
