tensorflowtensorflow.jstensorflowjs-converter

how to get a single weights file in tensorflow js converter


I'm using this command:

tfjs.converters.save_keras_model(model,'jsmodels')

but I get a model.json and 3 weights file

group1-shard1of3.bin
group1-shard2of3.bin
group1-shard3of3.bin

and I want to get only one .bin file, how can I do that?


Solution

  • I am not too sure if this is possible using save_keras_model but from the command line with tensorflowjs_converter I would do the following. Where you specify the --weigth_shard_size_bytes to be the size of the model you have. If your model is <= 30Mb then setting it to 30000000 bytes will result in a single file group1-shard1of1.bin.

    tensorflowjs_converter --input_format keras --weight_shard_size_bytes 30000000 'model.h5' 'output_dir'