Cannot import name relu6
See original GitHub issueUsing TensorFlow backend.
Traceback (most recent call last):
File "train.py", line 9, in <module>
from mobilenet_v2 import MobileNetv2
File "/home/wq/MobileNetV2/mobilenet_v2.py", line 13, in <module>
from keras.applications.mobilenet import relu6, DepthwiseConv2D
ImportError: cannot import name relu6
There seems to be some name changes since you write the script.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
ImportError: cannot import name 'relu6' - Stack Overflow
See this answer from GitHub. You need to use a CustomObjectScope to import relu6 .
Read more >How to use mobilenet layer/module in the new version of Keras
from keras.applications.mobilenet import _conv_block. Then I have the problem that : ImportError: cannot import name '_conv_block'
Read more >tf.keras.applications.mobilenet_v2.MobileNetV2 - TensorFlow
Float, larger than zero, controls the width of the network. This is known as the width multiplier in the MobileNetV2 paper, but the...
Read more >Source code for torchvision.models.mobilenetv2 - PyTorch
import warnings from typing import Callable, Any, Optional, List import torch from torch import Tensor from torch import nn from .
Read more >Running Keras models on iOS with CoreML - PyImageSearch
Apple's CoreML development team really couldn't have made it any easier ... import necessary packages from keras.models import load_model ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have tried with CustomObjectScope({‘relu6’: keras.layers.ReLU(6.),‘DepthwiseConv2D’: keras.layers.DepthwiseConv2D}): model = load_model(‘****.hdf5’)
but I got the following error: ValueError: axes don’t match array
my TF is 1.11 my keras is 2.2.4, python 2.7. Im trying to convert the model on the same machine and environment i have trained on. any suggestions?
Had the same issue, this worked for me:
from keras import models from keras_applications import mobilenet_v2
model = models.load_model(path_model_checkpoint, custom_objects={‘relu6’: mobilenet_v2.relu6}) model.summary()
Had the idea for the fix from here: https://github.com/keras-team/keras/commit/468f080c98f06780c950e5a78c9eeeaf9fff002e