代码之家  ›  专栏  ›  技术社区  ›  BAE

@属性:AttributeError:无法设置属性

  •  0
  • BAE  · 技术社区  · 6 年前

    我正在尝试这个 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
    

    有什么评论吗?谢谢

    0 回复  |  直到 6 年前
        1
  •  0
  •   Hasitha Jayawardana    5 年前

    Keras 版本我也经历过同样的问题 Keras 2.2.4 Keras==2.1.1 它开始运作良好。