Verified-Intelligence / auto_LiRPA

auto_LiRPA: An Automatic Linear Relaxation based Perturbation Analysis Library for Neural Networks and General Computational Graphs
https://arxiv.org/pdf/2002.12920
Other
269 stars 67 forks source link

Bound of difference != difference of bound? #31

Closed haoming-codes closed 2 years ago

haoming-codes commented 2 years ago

In running the sample code auto_LiRPA/examples/vision/simple_training.py --bound_type IBP, I was trying to test whether {the bound of the margin between classes} is equal to {the difference between the bound between classes}.

Specifically, I did

c1 = the specification matrix from the paper
c2 = c1.clone(); c2[c2==-1] = 0
c3 = c1.clone(); c3[c3==1] = 0
lb1, ub1 = model.compute_bounds(IBP=True, C=c1, method=None)
lb2, ub2 = model.compute_bounds(IBP=True, C=c2, method=None)
lb3, ub3 = model.compute_bounds(IBP=True, C=c3, method=None)

I expect lb1 == lb2+lb3 and ub1 == ub2+ub3, but they are not equal. Is this expected?

shizhouxing commented 2 years ago

Yes that’s expected as tightness of bounds can be different.

haoming-codes commented 2 years ago

Can you please elaborate more? Why should the tightness be different?

huanzhang12 commented 2 years ago

@haoming-codes lb1 should be tighter than lb2+lb3 and ub1 should be tighter than ub2+ub3, due to the last layer elision trick. See https://arxiv.org/pdf/1810.12715.pdf

haoming-codes commented 2 years ago

@huanzhang12 @shizhouxing Thank you!