tfjs: Error import Keras Mobilenet model: Unknown layer: BatchNormalizationV1
Hi everyone
I have a problem when run keras mobinet model in tensorflow js.
Browser raise exception:
errors.ts:48 Uncaught (in promise) Error: Unknown layer: BatchNormalizationV1. This may be due to one of the following reasons:
1. The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().
at new t (errors.ts:48)
at deserializeKerasObject (generic_utils.ts:239)
at deserialize (serialization.ts:31)
at u (container.ts:1335)
at t.fromConfig (container.ts:1362)
at deserializeKerasObject (generic_utils.ts:274)
at deserialize (serialization.ts:31)
at models.ts:287
at common.ts:14
at Object.next (common.ts:14)
My model train by python with keras application mobilenet
mobileModel = keras.applications.mobilenet.MobileNet(weights=None,classes=4, input_shape=(150,150,3))
mobileModel.compile(optimizer=tf.keras.optimizers.Adam(0.01),
loss='binary_crossentropy',
metrics=['accuracy'])
ref: https://keras.io/applications/#mobilenet
There is my h5 file: https://drive.google.com/file/d/10YmV7jfR0ooPxzXUbD1s1Y0X1FjRLeyz/view?usp=sharing
TensorFlow.js version: 0.15.1 Browser: chrome Version 72.0.3626.109 (Official Build) (64-bit)
Thank you very much
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 30 (1 by maintainers)
It is fixed but now we get a different error
ValueError: Improperly formatted model config.
😦 so frustrating
thanks for the quick reply.
i’m NOW stuck with that second type of error (the one that gets past the batchNormalizationV1 bug).
i’m now at the
Any suggestions on how to fix this?
How do I force the version of tensorflowjs?
referring to your suggestion earlier to use version 0.8.5
do I just do the following?
thanks again.
@SanthoshRajendiran For tflite-related problems, please file issues at https://github.com/tensorflow/tensorflow/issues
For TensorFlow.js, we are considering adding a logic in our converter to take care of the wrong class names such as BatchNormalizationV1.
Just to be clear, the final release of tensorflow 1.13 (1.13.0) that’s coming out soon should fix this issue.