Skip to content

Commit

Permalink
Merge pull request #34 from JuliaReach/schillic/boxforward
Browse files Browse the repository at this point in the history
Unify `BoxForward` for monotonic activations
  • Loading branch information
schillic authored Jul 5, 2024
2 parents 9fb6ec2 + ee97e64 commit 4ca6190
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/ForwardAlgorithms/BoxForward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,10 @@ function forward(X::LazySet, ::ReLU, ::BoxForward)
end

# apply monotonic activation function
for ACT in (:Sigmoid, :Tanh)
for ACT in (:Sigmoid, :Tanh, :LeakyReLU)
@eval function forward(X::LazySet, act::$ACT, ::BoxForward)
@assert isbounded(X) "this algorithm requires a bounded input set"
l, h = extrema(X)
return Hyperrectangle(; low=act(l), high=act(h))
end
end

# apply leaky-ReLU activation function
function forward(X::LazySet, act::LeakyReLU, ::BoxForward)
l, h = extrema(X)
if !(any(isinf, l) || any(isinf, h))
return Hyperrectangle(; low=act(l), high=act(h))
else
error("not implemented")
end
end

0 comments on commit 4ca6190

Please sign in to comment.