Error: Unknown layer: Functional. This may be due to one of the following reasons
See original GitHub issueI am new to the TensorFlow and JS. I was trying to convert the MobileNet V2 model from keras to tensorflow.js When I try to load model into JS, I get the following error:
`errors.ts:48 Uncaught (in promise) Error: Unknown layer: Functional. This may be due to one of the following reasons:
- The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
- The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass(). at new e (errors.ts:48) at Rp (generic_utils.ts:242) at cd (serialization.ts:31) at e.fromConfig (models.ts:942) at Rp (generic_utils.ts:277) at cd (serialization.ts:31) at models.ts:300 at common.ts:14 at Object.next (common.ts:14) at a (common.ts:14)`
I construct my model with a MobileNet V2 pre-trained model and add two layers on top of it. And I convert the model using tensorflowjs_converter with a saved h5 file of the model. Here is my model summary. The mobilenetv2_1.00_160 with a type of functional and I believed is the cause of the error.
Model: “sequential”
Layer (type)// Output Shape// Param #
#########################################################
mobilenetv2_1.00_160 (Functi (None, 5, 5, 1280)// 2257984
#########################################################
global_average_pooling2d (Gl (None, 1280) 0
#########################################################
dense (Dense) (None, 3755) 4810155
#########################################################
Total params: 7,068,139
Trainable params: 7,034,027
Non-trainable params: 34,112
#########################################################
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (1 by maintainers)
Top GitHub Comments
I had an issue like this albeit im using MobileNet not v2. I don’t have the specific link, but a stack overflow thread somewhere said to go into the public/model.json folder and ctrl+f “Functional” and replace the word with “Model”. worked for me!
Replace the “Functional” with “Model” indeed solve this error. However, it also gives me the new error as following:
Uncaught (in promise) Error: computeMask has not been implemented for Merge yet