MobileNetV3 icon indicating copy to clipboard operation
MobileNetV3 copied to clipboard

Hi,

Open LucyGarlapati opened this issue 5 years ago • 5 comments

LucyGarlapati avatar Jan 06 '20 06:01 LucyGarlapati

I tried Image classification using MobilenetV3 both small & large. How to do inference on test image. I am getting error saying "ValueError: Unknown activation function:_hard_swish"

LucyGarlapati avatar Jan 06 '20 06:01 LucyGarlapati

you have to redefine the custom objects like hard_wish in your inference script and pass them to the load_model function

rokopi-byte avatar Sep 16 '20 15:09 rokopi-byte

hi, did you solve this problem? i am still getting an error "TypeError: _hard_swish() missing 1 required positional argument: 'x'" when i pass the custom objects to the load_model function. Thanks.

YuliyaLi avatar Nov 08 '20 03:11 YuliyaLi

Yes, this is what I did..

def relu6(x):
    """Relu 6
    """
    return K.relu(x, max_value=6.0)

def hard_swish(x):
    """Hard swish
    """
    return x * K.relu(x + 3.0, max_value=6.0) / 6.0

dependencies = {'_hard_swish': hard_swish,'_relu6': relu6}
model = load_model(model_path, custom_objects=dependencies)

rokopi-byte avatar Nov 08 '20 08:11 rokopi-byte

Thanks a million!!!

YuliyaLi avatar Nov 08 '20 13:11 YuliyaLi