創建一個用標量值填充的張量。
用法
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。