JuliaIntervals / IntervalConstraintProgramming.jl

Calculate rigorously the feasible region for a set of real-valued inequalities with Julia
Other
63 stars 16 forks source link

Adding functions that work with @contractor #169

Open MartinDAndersson opened 3 years ago

MartinDAndersson commented 3 years ago

I am wondering if there is a way to add new functions (functions that are not composed of the regular ones already in src) that the @constraint macro can handle? For instance, I am interested in neural networks, and would like to have constraints using the ReLU function (g(x) = x ? x \geq 0 : 0), but the @function macro does not seem to handle conditionals. It would be nice if I can somehow add ReLU, providing forward and backwards code for the contraction step. Is there some way to do this?

dpsanders commented 3 years ago

Sorry I missed this.

I think you can write ReLU in terms of abs, floor etc. that are already implemented?

Conditionals are not possible with interval methods, but we should be able to simulate them with piecewise functions.

MartinDAndersson commented 3 years ago

Yes, thank you! I also realized I could just use f(x) = max(0,x) in this particular case.