Trusted-AI/adversarial-robustness-toolbox

KerasClassifier not compatible with latest versions of Keras and TensorFlow

Opened this issue · 3 comments

Describe the bug
Model architectures comprising of Keras Sequential layers are throwing various error while attempting to be used with the KerasClassifier wrapper, for latest versions of Keras.

The errors seem to relate to TensorFlow Eager Execution, as well as TensorFlow V2 Behaviour. Even after trying all sorts of configuration, the errors seemingly cannot be resolved.

The ONLY way to use KerasClassifier successfully, is to use older versions of Keras ( e.g, 2.15.0 ) and TensorFlow ( e.g. 2.15.0 ).

To Reproduce
Steps to reproduce the behavior:

  1. Train any model with Keras versions 3.. ( tried with 3.3.3 )
  2. Save/Load or directly use with KerasClassifier wrapper.
  3. As per the error descriptions, try changing TensorFlow configurations as as disabling eager-execution / v2 behaviour.

Expected behavior
A model trained/saved with the latest version of Keras, should be able to be used with KerasCassifier wrapper.

System information (please complete the following information):

  • OS - Windows
  • Python version 3.11
  • ART 1.18.1
  • TensorFlow 2.16.1 / Keras 3.3.3

one of the common error i get is ( module 'tensorflow.keras.backend' has no attribute 'placeholder')
when i trying to use the kerasclassifier wrapper as in the statment:
classifier = KerasClassifier(model=model,clip_values=(min_pixel_value, max_pixel_value),use_logits=False)
can anyone help me to resolve this error please

Confirm from my side, tf and keras==2.15 shall be used.

@zeinab2409
I have the same issue as you did you find a solution?