Internal

Internal API documentation for RemBG.

Index

Internal Interface

RemBG.softmax — Function
softmax(X, dims)
softmax(X, dims, θ)

Compute the softmax function along the dims dimension of the array X. You can adjust the scaling factor θ.

Examples

julia> x = [1000.0 1.0; 1000.0 1.0];
julia> y = RemBG.softmax(x, 2)
2×2 Matrix{Float64}:
 1.0  0.0
 1.0  0.0
source
RemBG.log_softmax — Function
log_softmax(x)
log_softmax(x, dims)

Compute the logarithm of the softmax function.

In principle::

log_softmax(x) = log(softmax(x))

but using a more accurate implementation.

Arguments

  • x: Input array
  • dims: Axis to compute values along

Returns

  • Array or Number: An array with the same shape as x. Exponential of the result will

sum to 1 along the specified axis. If x is a scalar, a scalar is returned.

Examples

julia> x = [1000.0, 1.0];
julia> y = log_softmax(x)
2-element Vector{Float64}:
    0.0
 -999.0

julia> x = [1000.0 1.0; 1000.0 1.0];
julia> y = log_softmax(x, 2)
2×2 Matrix{Float64}:
 0.0  -999.0
 0.0  -999.0
source