Reputation: 1378
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?
Upvotes: 2
Views: 978
Reputation: 1
The reason is because your model is over the the default size of 4mb. Hence, it is broken into multiple chunks of at most 4mb so set weight_shard_size_bytes
argument of the tfjs.converters.save_keras_model(model,name_of_folder)
to a size larger than the size of your model, so you get just one group1-shard1of1.bin
file.
tfjs.converters.save_keras_model(model,name_of_folder,weigth_shard_size_bytes=1024*1024*size > than model_size)
Upvotes: 0
Reputation: 6799
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'
Upvotes: 3