【发布时间】:2021-06-10 16:11:12
【问题描述】:
我已经将不同的迁移训练模型(VGG16、InceptionV3、EfficientNetB0)从 python 中的 tensorflow 转换为 tensorflowjs。 并且实现到tensorflowjs后,加载模型失败。
其中一个错误是:
Uncaught 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 jN (generic_utils.js:242)
at GI (serialization.js:31)
at e.fromConfig (models.js:1026)
at jN (generic_utils.js:277)
at GI (serialization.js:31)
at models.js:295
at u (runtime.js:45)
at Generator._invoke (runtime.js:274)
at Generator.forEach.t.<computed> [as next] (runtime.js:97)
at Wm (runtime.js:728)
还有
jquery-3.3.1.slim.min.js:2 Uncaught Error: Unknown layer: RandomFlip. 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 jN (generic_utils.js:242)
at GI (serialization.js:31)
at e.fromConfig (models.js:1026)
at jN (generic_utils.js:277)
at GI (serialization.js:31)
at e.fromConfig (models.js:1026)
at jN (generic_utils.js:277)
at GI (serialization.js:31)
at models.js:295
at u (runtime.js:45)
还有,
Failed to load resource: the server responded with a status of 404 ()
有什么问题? 如果我使用从可教机器生成的 .json 文件,则可以加载模型。 (然而,由于未知原因,预测变得完全错误,问题似乎不仅仅是标签问题。) 但是如果我使用 .h5 或 SavedModel 通过 tensorflow 转换器生成的 model.json 文件,无论我使用哪种预训练模型,或者生成的文件格式(.h5 或 SavedModel),都无法将模型加载到 javascript 中。
请帮忙!!
【问题讨论】: