我按照this guide
中的步骤将预训练的keras模型转换为可与Tensorflow.js一起使用现在,当我尝试将其导入到javascript中
const model = tf.loadModel("{% static "keras/model.json" %}");
出现以下错误:
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)
我正在使用Tensorflow.js的0.15.3版本,以这种方式导入:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.15.3/dist/tf.min.js"></script>
我使用Tensorflow 1.12.0和Keras 2.2.4训练了我的神经网络
答案 0 :(得分:0)
您正在使用tfjs尚不支持的tf.layer.gaussianNoise
层。
考虑通过另一种受支持的方式更改该层