Error when Converting a TensorFlow.js Layers model (JSON + binary weight file(s)) to a Keras HDF5 model file.
See original GitHub issueTo get help from the community, we encourage using Stack Overflow and the tensorflow.js
tag.
TensorFlow.js version
1.0.0
Browser version
Chrome 72.0.3626.121 (Official Build) (64-bit)
Describe the problem or feature request
I imported tfjs by a script in HTML:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>
I trained a MNIST model and save it as a JSON file and a bin file.
But Error is raised when using tensorflowjs_converter to convert the model into Keras h5 model.
I get:
I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-03-21 11:28:50.356788: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2592000000 Hz
2019-03-21 11:28:50.356952: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5545eb0 executing computations on platform Host. Devices:
2019-03-21 11:28:50.356967: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
Traceback (most recent call last):
File "/home/bigdog/.local/bin/tensorflowjs_converter", line 11, in <module>
sys.exit(main())
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflowjs/converters/converter.py", line 368, in main
FLAGS.output_path)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflowjs/converters/converter.py", line 169, in dispatch_tensorflowjs_to_keras_h5_conversion
model = keras_tfjs_loader.load_keras_model(config_json_path)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 218, in load_keras_model
use_unique_name_scope=use_unique_name_scope)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 65, in _deserialize_keras_model
model = keras.models.model_from_json(json.dumps(model_topology_json))
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/saving/model_config.py", line 96, in model_from_json
return deserialize(config, custom_objects=custom_objects)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/layers/serialization.py", line 88, in deserialize
printable_module_name='layer')
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 192, in deserialize_keras_object
list(custom_objects.items())))
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/sequential.py", line 351, in from_config
custom_objects=custom_objects)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/layers/serialization.py", line 88, in deserialize
printable_module_name='layer')
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 194, in deserialize_keras_object
return cls.from_config(cls_config)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/base_layer.py", line 437, in from_config
return cls(**config)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/layers/convolutional.py", line 477, in __init__
kernel_initializer=initializers.get(kernel_initializer),
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/initializers.py", line 194, in get
return deserialize(identifier)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/initializers.py", line 186, in deserialize
printable_module_name='initializer')
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 194, in deserialize_keras_object
return cls.from_config(cls_config)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/ops/init_ops_v2.py", line 89, in from_config
return cls(**config)
File "/home/bigdog/.local/lib/python3.5/site-packages/tensorflow/python/ops/init_ops_v2.py", line 390, in __init__
raise ValueError("Invalid `mode` argument:", mode)
ValueError: ('Invalid `mode` argument:', None)
Code to reproduce the bug / link to feature request
tensorflowjs_converter --input_format tfjs_layers_model --output_format keras mnist-cnn.json result/
tfjs_layers_model file attached for reference
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Model conversion | TensorFlow.js
This will convert the model at /tmp/model.h5 and output a model.json file along with binary weight files to your tmp/tfjs_model/ directory.
Read more >Importing a Keras model into TensorFlow.js
The target TensorFlow.js Layers format is a directory containing a model.json file and a set of sharded weight files in binary format.
Read more >Save and load models | TensorFlow Core
The above code stores the weights to a collection of checkpoint-formatted files that contain only the trained weights in a binary format.
Read more >Save and load models | TensorFlow.js
A binary file carrying the weight values named [my-model].weights.bin . You can change the name [my-model] to get files with a different name....
Read more >Importing a TensorFlow GraphDef based Models into ...
Convert an existing TensorFlow model to the TensorFlow.js web format ... group1-shard\*of\* (collection of binary weight files).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the additional information!
There are a number of things going on here.
distribution: normal
properly. For that I’ve filed b/129177721 to notify the keras team. cc @yhliang @fchollet @karmel@1egit The current work around is as follows: install and use tensorflowjs version 0.8.5: `pip install tensorflowjs==0.8.5". This should install the latest stable release of tensorflow (1.13.1), which doesn’t have this issue.
Let me know if you have more questions.
Hi all,
I’m facing the similar issue:
Traceback (most recent call last): File “/home/burak/.local/bin/tensorflowjs_converter”, line 11, in <module> sys.exit(main()) File “/home/burak/.local/lib/python2.7/site-packages/tensorflowjs/converters/converter.py”, line 352, in main strip_debug_ops=FLAGS.strip_debug_ops) File “/home/burak/.local/lib/python2.7/site-packages/tensorflowjs/converters/tf_saved_model_conversion_pb.py”, line 329, in convert_tf_frozen_model graph = load_graph(frozen_model_path, output_node_names) File “/home/burak/.local/lib/python2.7/site-packages/tensorflowjs/converters/tf_saved_model_conversion_pb.py”, line 63, in load_graph graph_def.ParseFromString(f.read()) File “/home/burak/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py”, line 125, in read self._preread_check() File “/home/burak/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py”, line 85, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File “/home/burak/.local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py”, line 528, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: output/saved_model.pb; No such file or directory
I couldn’t solve it. Can anyone help?
PS: First time asking question here, sorry if I forgetting something.