【问题标题】:How to load custom tensorflowJS model in react-native?如何在 react-native 中加载自定义 tensorflowJS 模型?
【发布时间】:2020-06-28 00:32:58
【问题描述】:

我已经使用 tensorflowjs_converter 将我的 Keras 模型转换为 TensorflowJS。它生成了一个“model.json”文件和 9 个“*.bin”文件。我正在尝试使用以下函数加载此模型。

const model = await tf.loadLayersModel(bundleResourceIO(modelJson, modelWeights));

modelWeights 只选择一个权重。但我有9个。如何正确加载此模型?

【问题讨论】:

    标签: react-native tensorflow.js


    【解决方案1】:

    好的,我刚刚找到了解决方案。基本上 tensorflow_converter 将权重分解为一些较小的大小。但是如果增加权重文件的大小限制,生成的文件数量会减少。假设您的模型权重文件需要 30MB。因此,将限制增加到 >=30MB,它将只生成一个权重文件。您可以按照以下命令执行此操作:

    tensorflowjs_converter --input_format keras --weight_shard_size_bytes 60000000 'your_model.h5' 'output_dir'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多