Tensorflow 未知层:掩蔽

Tensorflow 未知层:掩蔽,tensorflow,tensorflow.js,Tensorflow,Tensorflow.js,使用tensorflow.js,尝试导入我已经从.h5移到JSON的模型 这就是我得到的错误 Uncaught (in promise) Error: Unknown layer: Masking. 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 J

使用tensorflow.js,尝试导入我已经从.h5移到JSON的模型

这就是我得到的错误

    Uncaught (in promise) Error: Unknown layer: Masking. 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 e (errors.ts:48)
    at Rp (generic_utils.ts:242)
    at cd (serialization.ts:31)
    at e.fromConfig (models.ts:942)
    at Rp (generic_utils.ts:277)
    at cd (serialization.ts:31)
    at models.ts:300
    at common.ts:14
    at Object.next (common.ts:14)
    at a (common.ts:14)
这是我的密码:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js">import * as tf from '@tensorflow/tfjs';</script>
<script type='text/javascript'>
    let data = {{ data| tojson | safe}};
    console.log(data);

    if (data.ops != []) {
        //docs say tf.loadLayersModel is an async function, console says it is not...
        //I believe the docs are written for Node.js, some pages specify a difference, others do not.
        const model = tf.loadLayersModel('{{url_for("static", filename = "js/model.json/model.json")}}');
        console.log(model);
    }
</script>
import*作为tf从'@tensorflow/tfjs'导入;
让数据={data | tojson | safe};
控制台日志(数据);
如果(data.ops!=[]){
//文档说tf.loadLayersModel是一个异步函数,控制台说它不是。。。
//我相信这些文档是为Node.js编写的,有些页面指定了差异,而其他页面则没有。
const model=tf.loadLayersModel(“{url_代表(“static”,filename=“js/model.json/model.json”)}”);
console.log(模型);
}

它是一个Jinja2模板,因此{{}看起来可能很奇怪,基本上它运行一些python代码并返回相应的值。{{url_for()}}返回我存储JSON的url,看起来还可以。

任何有同样问题的人,问题是tensorflowjs的1.0.0版

将我的导入更改为此文件:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>