question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Unknown layer: Functional. This may be due to one of the following reasons

See original GitHub issue

I 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:

  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 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:closed
  • Created 3 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
lospericoscommented, Aug 13, 2020

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!

7reactions
KailiangGucommented, Aug 14, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensorflow.js Error: Unknown layer: Functional - Stack Overflow
Error : Unknown layer: Functional. This may be due to one of the following reasons: 1. The layer is defined in Python, in...
Read more >
Unknown layer ERROR in importing Keras model to ...
Error : Unknown layer: SlicingOpLambda. This may be due to one of the following reasons: 1. The layer is defined in Python, in...
Read more >
How to load my custom layer fully written as tensorflow.js ?
It sounds like the problem has to do with serializing / deserializing the custom layer. In order for layers to be recognized for...
Read more >
No module named tf - Spaces - Hugging Face Forums
the reason for this error is cause of use of different versions of Keras & TensorFlow… like in for training the model the...
Read more >
Python: ValueError: Unknown layer: Functional
2020-09-19 04:49:24.824483: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found