Skip to content

Commit cb30e19

Browse files
committed
Define activation functions taking arrays as input
1 parent 4ebb419 commit cb30e19

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/activations.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,9 @@ function softshrink(x, λ = 0.5)
731731
ifelse(hi > 0, ifelse(lo < 0, zero(hi), lo), hi)
732732
end
733733

734-
# Provide an informative error message if activation functions are called with an array
734+
# Define broadcasts for activation functions on arrays
735735
for f in ACTIVATIONS
736-
@eval $(f)(x::AbstractArray, args...) =
737-
error("Use broadcasting (`", $(string(f)), ".(x)`) to apply activation functions to arrays.")
736+
@eval $(f)(x::AbstractArray, args...) = $(f).(x, args...)
738737
end
739738

740739
## Faster, less accurate, versions of some.

0 commit comments

Comments
 (0)