AttributeError:“ Conv2D”对象没有属性“ get_config”

时间:2019-09-10 15:06:37

标签: tensorflow keras keras-layer tf.keras cleverhans

我正在尝试对mnist数据集进行fgsm攻击。我收到“对象没有属性”错误: 我曾经使用过:python 2(在Google colab中)Keras == 2.1.3 tensorflow == 1.14.0

我也使用keras == 1.2和keras == 2.1.5运行它,我也将get_config转换为_get_config,但是,我也将tf-keras转换为keras,但是所有使用上述解决方案的运行都失败了。 请告诉我如何克服这个问题。非常感谢你

x_adv_sub = fgsm.generate(images_tensor, **fgsm_par)
File "/content/defensegan/cleverhans/attacks/fast_gradient_method.py", 
  line 50, in generate
  labels, _nb_classes = self.get_or_guess_labels(x, kwargs)
File "/content/defensegan/cleverhans/attacks/attack.py", line 278, in 
  get_or_guess_labels
  preds = self.model.get_probs(x)
File "/content/defensegan/cleverhans/utils_keras.py", line 196, in 
  get_probs
  :return: Names of all the layers kept by Keras
File "/content/defensegan/cleverhans/utils_keras.py", line 130, in 
  _get_softmax_name
  def _get_abstract_layer_name(self):
AttributeError: 'Conv2D' object has no attribute 'get_config'

Unit_keras.py在这里:    https://github.com/tensorflow/cleverhans/blob/master/cleverhans/utils_keras.py

我还用过: https://github.com/tensorflow/cleverhans/blob/6b065c4507f50e2545c009f75e82678f92353163/cleverhans/utils_keras.py

但是我无法修复该错误。 有人可以解决吗?非常感谢。

0 个答案:

没有答案