Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' #2

Closed
AlbertHG opened this issue Mar 22, 2018 · 1 comment

Comments

@AlbertHG
Copy link
Owner

在运行报错!!!

yolo_model = load_model("model_data/yolo.h5")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-24-7a6f0063995c> in <module>()
----> 1 yolo_model = load_model("model_data/yolo.h5")

C:\ProgramData\Anaconda3\lib\site-packages\keras\models.py in load_model(filepath, custom_objects, compile)
    241 
    242         # set weights
--> 243         topology.load_weights_from_hdf5_group(f['model_weights'], model.layers)
    244 
    245         # Early return if compilation is not required.

C:\ProgramData\Anaconda3\lib\site-packages\keras\models.py in model_from_config(config, custom_objects)
    315 
    316 
--> 317 def model_from_yaml(yaml_string, custom_objects=None):
    318     """Parses a yaml model configuration file and returns a model instance.
    319 

C:\ProgramData\Anaconda3\lib\site-packages\keras\layers\__init__.py in deserialize(config, custom_objects)
     53                                     module_objects=globs,
     54                                     custom_objects=custom_objects,
---> 55                                     printable_module_name='layer')

C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    142                 return cls.from_config(config['config'])
    143         else:
--> 144             # Then `cls` may be a function returning a class.
    145             # in this case by convention `config` holds
    146             # the kwargs of the function.

C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in from_config(cls, config, custom_objects)
   2518 
   2519     def save(self, filepath, overwrite=True, include_optimizer=True):
-> 2520         """Save the model to a single HDF5 file.
   2521 
   2522         The savefile includes:

C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in process_node(layer, node_data)
   2475             layer = deserialize_layer(layer_data,
   2476                                       custom_objects=custom_objects)
-> 2477             created_layers[layer_name] = layer
   2478 
   2479             # Gather layer inputs.

C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py in __call__(self, inputs, **kwargs)
    615             if len(output_ls_copy) == 1:
    616                 output = output_ls_copy[0]
--> 617             else:
    618                 output = output_ls_copy
    619 

C:\ProgramData\Anaconda3\lib\site-packages\keras\layers\advanced_activations.py in call(self, inputs)
     44         config = {'alpha': float(self.alpha)}
     45         base_config = super(LeakyReLU, self).get_config()
---> 46         return dict(list(base_config.items()) + list(config.items()))
     47 
     48 

C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in relu(x, alpha, max_value)
   2916 
   2917     output_shape = output.get_shape()
-> 2918     targets = cast(flatten(target), 'int64')
   2919     logits = tf.reshape(output, [-1, int(output_shape[-1])])
   2920     res = tf.nn.sparse_softmax_cross_entropy_with_logits(

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
@AlbertHG
Copy link
Owner Author

AlbertHG commented Mar 22, 2018

上述错误是在Keras版本2.1.5的时候出错的,通过将Keras降级到2.1.2该错误消失。
使用下列命令降级

conda install  -n your_envi -c conda-forge keras=2.1.2

将your_envi更改为你的conda环境名

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant