Chapter 9: no attribute 'relu6'

In Chapter 9, when doing " Load the best model from last time":

import keras
from keras.models import Sequential
from keras.layers import *
from keras.models import Model, load_model
from keras import optimizers, callbacks
import keras.backend as K
import keras_applications

checkpoint = "checkpoints/multisnacks-0.7532-0.8304.hdf5"
classifier_model = load_model(checkpoint, custom_objects={
                "relu6": keras_applications.mobilenet.relu6 })

I get the following error, and would be grateful for any pointers on how to resolve.


AttributeError Traceback (most recent call last)
in ()
9 checkpoint = “checkpoints/multisnacks-0.7532-0.8304.hdf5”
10 classifier_model = load_model(checkpoint, custom_objects={
—> 11 “relu6”: keras_applications.mobilenet.relu6 })

AttributeError: module ‘keras_applications.mobilenet’ has no attribute ‘relu6’

Thanks!

This happens when you’re not using the same version of Keras as in the book. Please downgrade to version 2.2.0 using:

pip install -U keras==2.2.0

Let us know if that works!

1 Like

Thanks, worked great!