Skip to content

Commit

Permalink
Update activations.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
skyleaworlder authored Aug 9, 2023
1 parent 04b21cd commit 3fd624b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/activations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,17 @@ julia> lineplot(relu, -2, 2, height=7)
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀x⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
```
"""
relu(x) = ifelse(x<0, zero(x), x) # faster than max(zero(x), x), still preserves NaN
function relu(x)
if x < 0
zero(x)
else
y = x
for i in 1:10
y += i
end
x + zero(y)
end
end

"""
leakyrelu(x, a=0.01) = max(a*x, x)
Expand Down

0 comments on commit 3fd624b

Please sign in to comment.