按元素計算 x 的 log sigmoid。
用法
tf.math.log_sigmoid(
x, name=None
)參數
-
x類型為float32或float64的張量。 -
name操作的名稱(可選)。
返回
-
與
x類型相同的張量。
具體來說,y = log(1 / (1 + exp(-x)))。為了數值穩定性,我們使用 y = -tf.nn.softplus(-x) 。
使用示例:
如果一個正數很大,那麽它的 log_sigmoid 將接近 0,因為公式將是 y = log( <large_num> / (1 + <large_num>) ),它近似於為 0 的 log (1)。
x = tf.constant([0.0, 1.0, 50.0, 100.0])
tf.math.log_sigmoid(x)
<tf.Tensor:shape=(4,), dtype=float32, numpy=
array([-6.9314718e-01, -3.1326169e-01, -1.9287499e-22, -0.0000000e+00],
dtype=float32)>
如果負數很大,則其log_sigmoid 將接近數字本身,因為公式將是y = log( 1 / (1 + <large_num>) ),即log (1) - log ( (1 + <large_num>) ),它近似於作為數字本身的- <large_num>。
x = tf.constant([-100.0, -50.0, -1.0, 0.0])
tf.math.log_sigmoid(x)
<tf.Tensor:shape=(4,), dtype=float32, numpy=
array([-100. , -50. , -1.3132616, -0.6931472],
dtype=float32)>
相關用法
- Python tf.math.log1p用法及代碼示例
- Python tf.math.logical_or用法及代碼示例
- Python tf.math.log用法及代碼示例
- Python tf.math.logical_not用法及代碼示例
- Python tf.math.logical_and用法及代碼示例
- Python tf.math.logical_xor用法及代碼示例
- Python tf.math.less_equal用法及代碼示例
- Python tf.math.lgamma用法及代碼示例
- Python tf.math.l2_normalize用法及代碼示例
- Python tf.math.less用法及代碼示例
- Python tf.math.special.fresnel_cos用法及代碼示例
- Python tf.math.polyval用法及代碼示例
- Python tf.math.is_finite用法及代碼示例
- Python tf.math.special.bessel_k0e用法及代碼示例
- Python tf.math.acosh用法及代碼示例
- Python tf.math.invert_permutation用法及代碼示例
- Python tf.math.segment_prod用法及代碼示例
- Python tf.math.bincount用法及代碼示例
- Python tf.math.bessel_i0e用法及代碼示例
- Python tf.math.unsorted_segment_min用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.math.log_sigmoid。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
