tfjs classification model in react native app - Error: Unknown layer: Normalization
I trained a custom EfficientNetB2 classification model with Tensorflow 2.9.0:
base_model = EfficientNetB2(include_top=False, pooling ='avg', weights='imagenet', input_shape=(IMG_SIZE, IMG_SIZE, 3))
x = base_model.output
x = Dense(1024, activation='relu')(x)
x = Dropout(0.01)(x)
predictions = Dense(num_classes, activation='softmax')(x)
model = Model(inputs = base_model.input, outputs = predictions)
I then converted the resulting .h5 saved model to tfjs (using tensorflowjs 3.19.0):
tfjs.converters.save_keras_model(saved_model, 'tfjs_model')
After the conversion completes I get this message:
weight normalization_3/count with shape () and dtype int64 was auto converted to the type int32
Then, when I use the tfjs model in a react native app, I get this error message:
Possible Unhandled Promise Rejection (id: 2):
Error: Unknown layer: Normalization. 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().
I am using @tensorflow/tfjs 4.4.0
This seems to be an error related to normalization but I am not sure how to address it.
Any help would be appreciated!
Is this an appropriate place to ask this question or is another forum more appropriate?
@Linchenn any ideas here?
having same issue !! i trained a model in EfficientNetB0 , same error is showing , did you find any solution ?
Nope. No response. I've moved on to a different approach.
I used tensorflow.keras.layers.Normalization() in my model and I am getting the same error. Did you guys find a workaround for this issue?
same issue
I have the same issue. Has anyone found a workaround?