mirror of
https://github.com/google-deepmind/deepmind-research.git
synced 2026-08-20 21:50:37 +08:00
Enable Travis tests for unsupervised_adversarial_training
* Pin the version of Tensorflow at >= 1.15. This allows us to remove a workaround that causes breakages for newer versions (we get errors if `AddV2` already has a registered gradient). * Pin the version of Tensorflow at < 2 since cleverhans <= 3.1.0 doesn't properly support TF2 * Pin the version of cleverhans between 3.0.1 and 3.1.0. Versions newer than 3.1.0 will no longer support TF1. * Comment out the dependency on `tensorflow-gpu` as it's not a strict requirement, and it does nothing for us on Travis. PiperOrigin-RevId: 368241595
This commit is contained in:
committed by
Diego de Las Casas
parent
b37b4ec209
commit
edcd3f3eac
@@ -26,6 +26,7 @@ env:
|
||||
- PROJECT="transporter"
|
||||
- PROJECT="tvt"
|
||||
# - PROJECT="unrestricted_advx" # TODO(b/184862249): Fix and enable
|
||||
- PROJECT="unsupervised_adversarial_training"
|
||||
before_script:
|
||||
- sudo apt-get update -qq
|
||||
- pip install --upgrade pip
|
||||
|
||||
@@ -30,7 +30,6 @@ import cleverhans
|
||||
from cleverhans import attacks
|
||||
import numpy as np
|
||||
import tensorflow.compat.v1 as tf
|
||||
from tensorflow.python.ops import math_grad
|
||||
import tensorflow_hub as hub
|
||||
|
||||
UAT_HUB_URL = ('https://tfhub.dev/deepmind/unsupervised-adversarial-training/'
|
||||
@@ -80,10 +79,6 @@ def eval_cifar():
|
||||
_, data_test = tf.keras.datasets.cifar10.load_data()
|
||||
data = _build_dataset(data_test, batch_size=batch_size, shuffle=False)
|
||||
|
||||
# Necessary for backwards-compatibility
|
||||
# Earlier versions of TF don't have a registered gradient for the AddV2 op
|
||||
tf.RegisterGradient('AddV2')(math_grad._AddGrad) # pylint: disable=protected-access
|
||||
|
||||
# Generate adversarial images.
|
||||
if attack_fn_name == 'fgsm':
|
||||
attack = attacks.MadryEtAl(cleverhans_model)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
absl-py>=0.7.0
|
||||
cleverhans>=3.0.1
|
||||
cleverhans>=3.0.1,<=3.1.0
|
||||
numpy>=1.16.4
|
||||
pillow>=4.3.0
|
||||
tensorflow>=1.14
|
||||
tensorflow-gpu >= 1.11.0 # GPU version of TensorFlow.
|
||||
tensorflow>=1.15,<2
|
||||
# tensorflow-gpu >= 1.15.0,<2 # GPU version of TensorFlow.
|
||||
tensorflow-hub>=0.5.0
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
# user@host:/path/to/deepmind_research$ unsupervised_adversarial_training/run.sh
|
||||
|
||||
# Sets up virtual environment, install dependencies, and runs evaluation script
|
||||
python3 -m venv uat_venv
|
||||
source uat_venv/bin/activate
|
||||
python3 -m venv /tmp/uat_venv
|
||||
source /tmp/uat_venv/bin/activate
|
||||
pip install -U pip
|
||||
pip install -r unsupervised_adversarial_training/requirements.txt
|
||||
|
||||
python -m unsupervised_adversarial_training.quick_eval_cifar \
|
||||
--attack_fn_name=fgsm
|
||||
--attack_fn_name=fgsm \
|
||||
--num_batches=1
|
||||
|
||||
Reference in New Issue
Block a user