We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5de0867 commit 3b85e46Copy full SHA for 3b85e46
src/softmax.jl
@@ -17,9 +17,9 @@ independent.
17
0.244728
18
0.665241
19
"""
20
-softmax(xs) = softmax!(similar(xs), xs)
+softmax(xs; dims=2) = softmax!(similar(xs), xs, dims)
21
22
-function softmax!(out::AbstractVecOrMat{T}, xs::AbstractVecOrMat{T}) where {T}
+function softmax!(out::AbstractVecOrMat{T}, xs::AbstractVecOrMat{T}, dims) where {T}
23
# First, store column-wise maximum in the last element of `out`
24
maxdims = ntuple(d -> (d in dims) ? (1:1) : (:), ndims(xs))
25
out[maxdims...] = maximum!(out[maxdims...], xs)
0 commit comments