# Keras to TFJS - Unknown layer: TFOpLambda

**URL:** <https://discuss.ai.google.dev/t/keras-to-tfjs-unknown-layer-tfoplambda/15888>\
**Category:** General Discussion\
**Tags:** keras, tfjs, models, help\_request\
**Created:** [March 31, 2022, 9:39pm UTC](https://discuss.ai.google.dev/t/keras-to-tfjs-unknown-layer-tfoplambda/15888 "2022-03-31T21:39:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_McArthur](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@Lee\_McArthur](https://discuss.ai.google.dev/u/Lee_McArthur)\
**Post date:** [March 31, 2022, 9:39pm UTC](https://discuss.ai.google.dev/t/keras-to-tfjs-unknown-layer-tfoplambda/15888/1 "2022-03-31T21:39:51Z")

</div>

Hi

I’m new to ML and I’m trying to get keypoint detection working in the browser. I found this Keras tutorial:

> **[Keras documentation: Keypoint Detection with Transfer Learning](https://keras.io/examples/vision/keypoint_detection/)**
>
> Keras documentation

I got it working in Python, and then added a line to export it to .h5:  
`model.save('keypoint.h5')`

I then converted it to tfjs:  
`tensorflowjs_converter --input_format=keras /keypoint.h5 /tfjs_model`

However when I try and run it in the browser like so:  
`const model = await tf.loadLayersModel(‘path/to/model.json’);`

I get the following error:  
`Error: Unknown layer: TFOpLambda`

Looking inside model.json I can see the following Lambda layers:

```auto
{"class_name": "TFOpLambda", "config": {"name": "tf.math.truediv_1", "trainable": true, "dtype": "float32", "function": "math.truediv"}, "name": "tf.math.truediv_1", "inbound_nodes": [["input_4", 0, 0, {"y": 127.5, "name": null}]]}, 
{"class_name": "TFOpLambda", "config": {"name": "tf.math.subtract_1", "trainable": true, "dtype": "float32", "function": "math.subtract"}, "name": "tf.math.subtract_1", "inbound_nodes": [["tf.math.truediv_1", 0, 0, {"y": 1.0, "name": null}]]}

```

I’ve read that I need to create a custom layer, but this is where I’m completely stumped. How do I go about this? This is well beyond my current understanding but I’m keen to learn - any help appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![Jason](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jason/32/6193_2.png) [@Jason](https://discuss.ai.google.dev/u/Jason)\
**Post date:** [April 1, 2022, 8:00pm UTC](https://discuss.ai.google.dev/t/keras-to-tfjs-unknown-layer-tfoplambda/15888/3 "2022-04-01T20:00:19Z")

</div>

Maybe @lina128 or @pyu can shed some light here.
