google-deepmind / deep-verify

Apache License 2.0
16 stars 8 forks source link

Analysis 2D maxpool #1

Open jiahaubai opened 3 years ago

jiahaubai commented 3 years ago

Thanks for providing code!! I saw the analysis(verification) about maxpool in the paper. I am curious about if this repository provide the analysis containing 2D maxpool ? If yes, how should I use it ?   verify.py seems to have only analysis on conv and relu :)

RobertStanforth commented 3 years ago

Dear jiahaubai, the verify.py code example uses the DNN model class (https://github.com/deepmind/interval-bound-propagation/blob/master/interval_bound_propagation/src/model.py#L583). It is not necessary to use the DNN class at all; it was provided purely as a convenience for setting up simple sequential convolutional networks employing some of the supported layer types. You are free to write a more complex neural network class, which may be used instead of the DNN classifier in verify.py. Note that tf.nn.maxpool (with VALID padding) is already supported by the underlying verification engine, so it's enough for your replacement classifier to simply create tf.nn.maxpool layers. One option would be to fork the DNN class itself to allow maxpool layers to be specified in a way analogous to conv layers, something like ('maxpool2d', (4, 4), 'VALID', 2).

jiahaubai commented 3 years ago

Dear RobertStanforth,

Thank you for getting back to me ! It will be very helpful for me, I will give it a try !

But another problem occurs when I execute verify.py use command python verify.py --model=tiny --epsilon=0.02

I get the error

File "verify.py", line 177, in <lambda>
    lambda x: x.set_shape([test_batch_size] + x.shape[1:]), test_data_live)
TypeError: can only concatenate list (not "TensorShape") to list

I think it may be due to version issues the system environment I used is :

python == 3.7.7
tensorflow==1.14.0
tensorflow-estimator==1.14.0
tensorflow-probability==0.7.0 
dm-sonnet==1.35

Could you provide the environment requirements, please ~ Are there any details I should notice when I run the code ?

Cheers, jiahaubai

RobertStanforth commented 3 years ago

Hi jiahaubai, I believe we were using tensorflow 1.11.0 at the time. Rather than pinning to a legacy version, I'd suggest simply fixing up the error by using .as_list() to convert a TensorShape to a Python list: [test_batch_size] + x.shape[1:].as_list()