Skip to content Skip to sidebar Skip to footer

"unknown Layer: Lambda" In Tensorflowjs On Browser

I am new in machine learning area. i am trying to run python program on browser by converting trained model in tensorflow js. this attention_ocr is related to OCR written in python

Solution 1:

Lambda (native code) layers are not supported in TensorFlow.js. You will need to replace it with a custom layer. This is tricky. Here is an example custom layer: https://github.com/tensorflow/tfjs-examples/tree/master/custom-layer

Solution 2:

You have to create a custom layer class as @BlessedKey stated above (https://github.com/tensorflow/tfjs-examples/tree/master/custom-layer).

You also have to edit the model.json file. The model definition must be updated point to the new class you created for your custom layer instead of the Lambda class. Find the lambda layer inside your model.json and change the "class_name": "Lambda" attribute to "class_name": "YourCustomLayer". You can find an example here: https://github.com/tensorflow/tfjs/issues/283.

Also make sure to return the correct tensor shape from computeOutputShape(inputShape) or you'll get bothered by this pesky guy:

TypeError: Cannot read property 'dtype' of undefined
at executor.js:29
at t.e.add (executor.js:96)
at SA(executor.js:341)
at training.js:1063
at engine.js:425
at t.e.scopedRun (engine.js:436)
at t.e.tidy (engine.js:423)
at Nb(globals.js:182)
at s(training.js:1046)
at training.js:1045

Post a Comment for ""unknown Layer: Lambda" In Tensorflowjs On Browser"