0
votes

I converted a pretrained keras model to use it with Tensorflow.js following the steps in this guide

Now, when I try to import it to javascript using

const model = tf.loadModel("{% static "keras/model.json" %}");

The following error shows up:

Uncaught (in promise) Error: Unknown layer: GaussianNoise. 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 t (errors.ts:48)
    at deserializeKerasObject (generic_utils.ts:239)
    at deserialize (serialization.ts:31)
    at t.fromConfig (models.ts:940)
    at deserializeKerasObject (generic_utils.ts:274)
    at deserialize (serialization.ts:31)
    at models.ts:302
    at common.ts:14
    at Object.next (common.ts:14)
    at i (common.ts:14)

I'm using 0.15.3 version of Tensorflow.js, imported this way:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>

I trained my neural network with Tensorflow 1.12.0 and Keras 2.2.4

1
This is now tracked at github.com/tensorflow/tfjs/issues/1326. Thanks for filing it! - David Soergel

1 Answers

0
votes

You are using the layer tf.layer.gaussianNoise that is not supported yet by tfjs.

Consider changing this layer by another one supported