tensorflow / neural-structured-learning

Training neural models with structured signals.
https://www.tensorflow.org/neural_structured_learning
Apache License 2.0
980 stars 189 forks source link

Adding an implementation of Denoised Smoothing #85

Closed sayakpaul closed 3 years ago

sayakpaul commented 3 years ago

This PR adds Denoised Smoothing under the research folder.

The success of Randomized Smoothing is proven and it works for many different scenarios. But it also operates under the assumption that the underlying classifier is able to perform well under Gaussian perturbations. Won't it be better if we could just take our standard pre-trained image classifiers (including the Cloud APIs) and have the benefits of Randomized Smoothing inside of them in an easy manner?

That is preciously what Denoised Smoothing does by prepending a Denoiser to an image classifier and still maintains the theoretical guarantees of robustness against L2 attacks.

Besides, the implementation includes a suite of utilities that may be helpful to generate robustness certificates. I think that gives us a unique opportunity to actually design an API inside NSL that would allow easy generation of robustness certificates. To the best of my knowledge, there does not exist any such framework as we speak.

review-notebook-app[bot] commented 3 years ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

sayakpaul commented 3 years ago

@csferng,

Please run pylint to format the code into TensorFlow style (instruction here).

I have followed most of the instructions I got from the linter barring a few exceptions:

Apart from these, I could not resolve the following:

scripts/certification_utils.py:57:4: R1705: Unnecessary "else" after "return" (no-else-return)
scripts/certification_utils.py:82:4: R1705: Unnecessary "else" after "return" (no-else-return)

scripts/certify.py:14:0: W9008: Redundant returns documentation (redundant-returns-doc)
scripts/certify.py:30:2: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
scripts/certify.py:37:2: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
scripts/certify.py:57:4: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)

models/dncnn.py:27:13: R1719: The if expression can be replaced with 'bool(test)' (simplifiable-if-expression)

Also, I was checking some of the modules under research and I felt they do not strictly follow tensorflow/tools/ci_build/pylintrc (such as type annotation, trailing newline, etc.).

sayakpaul commented 3 years ago

@csferng I am happy to change it to Apache. Please advice.

csferng commented 3 years ago

@sayakpaul, sorry that I didn't make my point clear. Since Google does not own the copyright to those code, please move the directory to research/third_party/denoised_smoothing. Either MIT or Apache 2.0 license is fine, and you can choose one you'd like.

sayakpaul commented 3 years ago

@csferng done.

sayakpaul commented 3 years ago

@csferng could you provide an update on the progress of the PR?

sayakpaul commented 3 years ago

@csferng just wanted to see if an update is available for this PR.

csferng commented 3 years ago

@sayakpaul Sorry for the delay. The PR is merged now.

sayakpaul commented 3 years ago

Thank you so much.

Is it possible to include a note on the third_party projects here?