Skip to content

Commit d70001a

Browse files
committed
Remove TensorFlow2v1
Signed-off-by: Beat Buesser <[email protected]>
1 parent 040b4eb commit d70001a

File tree

66 files changed

+200
-4985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+200
-4985
lines changed

.github/workflows/ci-tensorflow-v2.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- name: TensorFlow 2.18.1v1 (Keras 3.10.0 Python 3.10)
32-
framework: tensorflow2v1
33-
python: '3.10'
34-
tensorflow: 2.18.1
35-
tf_version: v2
36-
keras: 3.10.0
37-
tf_addons: 0.23.0
3831
- name: TensorFlow 2.18.1 (Keras 3.10.0 Python 3.10)
3932
framework: tensorflow
4033
python: '3.10'

art/attacks/evasion/auto_conjugate_gradient.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ def __init__(
115115
"cross_entropy", or "difference_logits_ratio"
116116
:param verbose: Show progress bars.
117117
"""
118-
from art.estimators.classification import TensorFlowClassifier, TensorFlowV2Classifier, PyTorchClassifier
119-
120-
if isinstance(estimator, TensorFlowClassifier):
121-
raise ValueError("This attack does not support TensorFlow v1.")
118+
from art.estimators.classification import TensorFlowV2Classifier, PyTorchClassifier
122119

123120
if loss_type not in self._predefined_losses:
124121
raise ValueError(

art/attacks/evasion/rescaling_auto_conjugate_gradient.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ def __init__(
113113
"cross_entropy", or "difference_logits_ratio"
114114
:param verbose: Show progress bars.
115115
"""
116-
from art.estimators.classification import TensorFlowClassifier, TensorFlowV2Classifier, PyTorchClassifier
117-
118-
if isinstance(estimator, TensorFlowClassifier):
119-
raise ValueError("This attack does not support TensorFlow v1.")
116+
from art.estimators.classification import TensorFlowV2Classifier, PyTorchClassifier
120117

121118
if loss_type not in self._predefined_losses:
122119
raise ValueError(

art/data_generators.py

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -257,87 +257,6 @@ def get_batch(self) -> tuple:
257257
return tuple(batch)
258258

259259

260-
class TensorFlowDataGenerator(DataGenerator): # pragma: no cover
261-
"""
262-
Wrapper class on top of the TensorFlow native iterators :class:`tf.data.Iterator`.
263-
"""
264-
265-
def __init__(
266-
self,
267-
sess: "tf.Session",
268-
iterator: "tf.data.Iterator",
269-
iterator_type: str,
270-
iterator_arg: dict | tuple | "tf.Operation",
271-
size: int,
272-
batch_size: int,
273-
) -> None:
274-
"""
275-
Create a data generator wrapper for TensorFlow. Supported iterators: initializable, reinitializable, feedable.
276-
277-
:param sess: TensorFlow session.
278-
:param iterator: Data iterator from TensorFlow.
279-
:param iterator_type: Type of the iterator. Supported types: `initializable`, `reinitializable`, `feedable`.
280-
:param iterator_arg: Argument to initialize the iterator. It is either a feed_dict used for the initializable
281-
and feedable mode, or an init_op used for the reinitializable mode.
282-
:param size: Total size of the dataset.
283-
:param batch_size: Size of the minibatches.
284-
:raises `TypeError`, `ValueError`: If input parameters are not valid.
285-
"""
286-
287-
import tensorflow.compat.v1 as tf
288-
289-
super().__init__(size=size, batch_size=batch_size)
290-
self.sess = sess
291-
self._iterator = iterator
292-
self.iterator_type = iterator_type
293-
self.iterator_arg = iterator_arg
294-
295-
if not isinstance(iterator, tf.data.Iterator):
296-
raise TypeError("Only support object tf.data.Iterator")
297-
298-
if iterator_type == "initializable":
299-
if not isinstance(iterator_arg, dict):
300-
raise TypeError(f"Need to pass a dictionary for iterator type {iterator_type}")
301-
elif iterator_type == "reinitializable":
302-
if not isinstance(iterator_arg, tf.Operation):
303-
raise TypeError(f"Need to pass a TensorFlow operation for iterator type {iterator_type}")
304-
elif iterator_type == "feedable":
305-
if not isinstance(iterator_arg, tuple):
306-
raise TypeError(f"Need to pass a tuple for iterator type {iterator_type}")
307-
else:
308-
raise TypeError(f"Iterator type {iterator_type} not supported")
309-
310-
def get_batch(self) -> tuple:
311-
"""
312-
Provide the next batch for training in the form of a tuple `(x, y)`. The generator should loop over the data
313-
indefinitely.
314-
315-
:return: A tuple containing a batch of data `(x, y)`.
316-
:raises `ValueError`: If the iterator has reached the end.
317-
"""
318-
import tensorflow as tf
319-
320-
# Get next batch
321-
next_batch = self.iterator.get_next()
322-
323-
# Process to get the batch
324-
try:
325-
if self.iterator_type in ("initializable", "reinitializable"):
326-
return self.sess.run(next_batch)
327-
return self.sess.run(next_batch, feed_dict=self.iterator_arg[1])
328-
except (tf.errors.FailedPreconditionError, tf.errors.OutOfRangeError):
329-
if self.iterator_type == "initializable":
330-
self.sess.run(self.iterator.initializer, feed_dict=self.iterator_arg)
331-
return self.sess.run(next_batch)
332-
333-
if self.iterator_type == "reinitializable":
334-
self.sess.run(self.iterator_arg)
335-
return self.sess.run(next_batch)
336-
337-
self.sess.run(self.iterator_arg[0].initializer)
338-
return self.sess.run(next_batch, feed_dict=self.iterator_arg[1])
339-
340-
341260
class TensorFlowV2DataGenerator(DataGenerator):
342261
"""
343262
Wrapper class on top of the TensorFlow v2 native iterators :class:`tf.data.Iterator`.

art/defences/preprocessor/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from art.defences.preprocessor.cutout.cutout_tensorflow import CutoutTensorFlowV2
1111
from art.defences.preprocessor.feature_squeezing import FeatureSqueezing
1212
from art.defences.preprocessor.gaussian_augmentation import GaussianAugmentation
13-
from art.defences.preprocessor.inverse_gan import DefenseGAN, InverseGAN
1413
from art.defences.preprocessor.jpeg_compression import JpegCompression
1514
from art.defences.preprocessor.label_smoothing import LabelSmoothing
1615
from art.defences.preprocessor.mixup.mixup import Mixup

art/defences/preprocessor/inverse_gan.py

Lines changed: 0 additions & 189 deletions
This file was deleted.

art/estimators/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
from art.estimators.keras import KerasEstimator
1313
from art.estimators.pytorch import PyTorchEstimator
1414
from art.estimators.scikitlearn import ScikitlearnEstimator
15-
from art.estimators.tensorflow import TensorFlowEstimator, TensorFlowV2Estimator
15+
from art.estimators.tensorflow import TensorFlowV2Estimator
1616

1717
from art.estimators import certification
1818
from art.estimators import classification
19-
from art.estimators import encoding
2019
from art.estimators import generation
2120
from art.estimators import object_detection
2221
from art.estimators import poison_mitigation

art/estimators/classification/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,5 @@
2020
from art.estimators.classification.hugging_face import HuggingFaceClassifierPyTorch
2121
from art.estimators.classification.query_efficient_bb import QueryEfficientGradientEstimationClassifier
2222
from art.estimators.classification.scikitlearn import SklearnClassifier
23-
from art.estimators.classification.tensorflow import (
24-
TFClassifier,
25-
TensorFlowClassifier,
26-
TensorFlowV2Classifier,
27-
)
23+
from art.estimators.classification.tensorflow import TensorFlowV2Classifier
2824
from art.estimators.classification.xgboost import XGBoostClassifier

0 commit comments

Comments
 (0)