@property:AttributeError:无法设置属性

时间:2018-11-25 17:28:33

标签: python keras keras-2

我正在尝试example并收到以下错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-9f46197aa363> in <module>()
    206 
    207 if __name__ == "__main__":
--> 208     main()

<ipython-input-1-9f46197aa363> in main()
    202                 opt_d=Adam(1e-3, decay=1e-5),
    203                 nb_epoch=100, generator=generator, discriminator=discriminator,
--> 204                 latent_dim=latent_dim)
    205 
    206 

<ipython-input-1-9f46197aa363> in example_gan(adversarial_optimizer, path, opt_g, opt_d, nb_epoch, generator, discriminator, latent_dim, targets, loss)
    155     model = AdversarialModel(base_model=gan,
    156                              player_params=[generator.trainable_weights, discriminator.trainable_weights],
--> 157                              player_names=["generator", "discriminator"])
    158     model.adversarial_compile(adversarial_optimizer=adversarial_optimizer,
    159                               player_optimizers=[opt_g, opt_d],

/Users/cpei/ebay/dev/lib/python2.7/site-packages/keras_adversarial-0.0.3-py2.7.egg/keras_adversarial/adversarial_model.pyc in __init__(self, player_params, base_model, player_models, player_names)
     45             raise ValueError("Specify base_model or player_models, not both")
     46         if base_model is not None:
---> 47             self.layers = []
     48             for i in range(self.player_count):
     49                 # duplicate base model

/Users/cpei/ebay/dev/lib/python2.7/site-packages/keras/engine/network.pyc in __setattr__(self, name, value)
    314                 if value not in self._layers:
    315                     self._layers.append(value)
--> 316         super(Network, self).__setattr__(name, value)
    317 
    318     @property

AttributeError: can't set attribute

有何评论?谢谢

1 个答案:

答案 0 :(得分:0)

检查您的{file: "file.doc", myData: ['dat1','dat2']} 版本。我安装了Keras后,Keras 2.2.4遇到了同样的问题。