如何将 tensorflow.js 模型和权重转换为标准 tensorflow? [英] How to convert tensorflow.js model and weights to standard tensorflow?

查看:45
本文介绍了如何将 tensorflow.js 模型和权重转换为标准 tensorflow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将模型及其各自训练的权重从 tensorflow.js 转换为标准的 tensorflow,但无法弄清楚如何去做,tensorflow.js 的文档对此没有任何说明

我有一个 manifest.json 和许多其他文件,对应于每一层的权重和偏差,我想得到一个 .bytes 文件,用于标准版本的 tensorflow

我检查了其他可能稍微相关的问题的答案如何从 tensorflow.js 下载模型和权重(我问了那个问题)这只是部分回答,没有给出关于这个问题的任何提示的答案

解决方案

Tensorflow.js 转换器可以将 tfjs 模型转换为 Keras HDF5 格式,参数如下:

tensorflowjs_converter --input_format=tfjs_layers_model --output_format=keras path/to/tfjs_files path/to/save_keras_hdf5

您可以查看此处以安装转换.将模型转换为 Keras HDF5 后,您可以将其转换为 TensorFlow SavedModel 格式.因此,这个线程可能会有所帮助.>

注意:这适用于tfjs 层模型"格式的模型,但不适用于 tfjs 图形模型 格式.

I want to convert a model and its respective trained weights from tensorflow.js to standard tensorflow, but cant quite figure out how to do it, the documentation of tensorflow.js dont say anything about this

I have a manifest.json and a lot of other files corresponding to the weights and bias of every layer, I want to get a .bytes file, to be used in the standard version of tensorflow

I checked the answers to other question that might be mildly related How to download models and weights from tensorflow.js (I asked that question) which was only partially answered, answer that doesnt give any hints regarding this one

解决方案

Tensorflow.js converter can convert the tfjs model into Keras HDF5 format with following params:

tensorflowjs_converter --input_format=tfjs_layers_model --output_format=keras path/to/tfjs_files path/to/save_keras_hdf5

You can take a look here for installing the converting. Once the model is converted to Keras HDF5 you can convert it the TensorFlow SavedModel format. So, this thread might be helpful.

Note: This works for a model in the 'tfjs layers model' format, but not the tfjs graph model format.

这篇关于如何将 tensorflow.js 模型和权重转换为标准 tensorflow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆