【问题标题】:Import models to TensorflowJs将模型导入 TensorFlowJs
【发布时间】:2020-08-20 17:36:10
【问题描述】:

const tf = require('@tensorflow/tfjs');
const model = tf.sequential();

const saveResult = model.save('file:/naive_bayes.pkl');

我想导入一个我用 Python 训练的模型 tp TensorflowJs。但是我收到了这个错误:

(node:12312) UnhandledPromiseRejectionWarning: Error: Cannot find any save handlers for URL 'file:/naive_bayes.pkl'

我不明白,我正在关注它的文档。 https://www.tensorflow.org/js/guide/save_load?hl=vi

我将所有文件(模型、js)放在同一个文件夹中。

【问题讨论】:

  • 请阅读ml标签的描述。

标签: javascript import model tensorflow.js


【解决方案1】:

这样使用

const modelDir = 'model' // model floder in same dir

const modelPath = `file://${modelDir}`;

model.save(modelPath);

或者简单地说,

const modelDir = 'model' 

model.save(`file://${modelDir}`);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-13
    • 1970-01-01
    • 2020-04-13
    • 2018-10-08
    • 2020-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多