boundlab.poly.relu_linearizer#
- boundlab.poly.relu_linearizer(ub, lb)[source]#
CROWN relaxation of ReLU.
For each neuron with input bounds \([\ell, u]\):
Dead (\(u \le 0\)):
f(x) = 0.Active (\(\ell \ge 0\)):
f(x) = x.Crossing (\(\ell < 0 < u\)): tight upper envelope through \((\ell, 0)\) and \((u, u)\); lower bound given by the tangent of ReLU at the interval midpoint \(c = (\ell + u)/2\).
Examples
>>> import torch >>> from boundlab.poly.relu import relu_linearizer >>> ub = torch.tensor([2.0, -1.0, 1.0]) >>> lb = torch.tensor([-1.0, -2.0, 0.5]) >>> b = relu_linearizer(ub, lb) >>> b.upper_lam.shape torch.Size([3])