Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert tensorflow.js model and weights to standard tensorflow?

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

like image 205
Boris Avatar asked Jan 17 '19 19:01

Boris


1 Answers

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.

like image 172
Ping Yu Avatar answered Nov 20 '22 11:11

Ping Yu