创建一个用标量值填充的张量。
用法
tf.raw_ops.Fill(
dims, value, name=None
)
参数
-
dims
一个Tensor
。必须是以下类型之一:int32
,int64
。一维。表示输出张量的形状。 -
value
一个Tensor
。 0-D(标量)。填充返回的张量的值。 -
name
操作的名称(可选)。
返回
-
一个
Tensor
。具有与value
相同的类型。
此操作创建一个形状为 dims
的张量并用 value
填充它。
例如:
# Output tensor has shape [2, 3].
fill([2, 3], 9) ==> [[9, 9, 9]
[9, 9, 9]]
tf.fill
在以下几个方面与 tf.constant
不同:
tf.fill
仅支持标量内容,而tf.constant
支持张量值。tf.fill
在计算图中创建一个 Op,它在运行时构造实际的 Tensor 值。这与tf.constant
形成对比,tf.constant
使用Const
节点将整个张量嵌入到图中。- 因为
tf.fill
在图形运行时评估,它支持基于其他运行时张量的动态形状,这与tf.constant
不同。
numpy 兼容性
相当于 np.full
相关用法
- Python tf.raw_ops.Fingerprint用法及代码示例
- Python tf.raw_ops.TPUReplicatedInput用法及代码示例
- Python tf.raw_ops.Bitcast用法及代码示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.BatchMatMul用法及代码示例
- Python tf.raw_ops.OneHot用法及代码示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代码示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代码示例
- Python tf.raw_ops.GatherV2用法及代码示例
- Python tf.raw_ops.Expm1用法及代码示例
- Python tf.raw_ops.BitwiseAnd用法及代码示例
- Python tf.raw_ops.UniqueWithCounts用法及代码示例
- Python tf.raw_ops.DecodeGif用法及代码示例
- Python tf.raw_ops.Size用法及代码示例
- Python tf.raw_ops.ScatterUpdate用法及代码示例
- Python tf.raw_ops.ParallelConcat用法及代码示例
- Python tf.raw_ops.ScatterNdUpdate用法及代码示例
- Python tf.raw_ops.BatchToSpaceND用法及代码示例
- Python tf.raw_ops.TensorScatterMax用法及代码示例
- Python tf.raw_ops.DepthToSpace用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.Fill。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。