tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.51k stars 1.94k forks source link

KeyError: 'simple_rnn_25/kernel' in tensorflowjs_converter #8088

Open bipinkrish opened 12 months ago

bipinkrish commented 12 months ago

System information

Describe the current behavior

I tried to convert tfjs_layers_model to keras from here with tensorflowjs_converter i got KeyError: 'simple_rnn_25/kernel'

Describe the expected behavior

I was expecting to get keras HDF5 model

Standalone code to reproduce the issue

tensorflowjs_converter --input_format tfjs_layers_model --output_format keras face-features/model.json py-models/

Other info / logs Include any logs or source code that would be helpful to

2023-12-04 09:45:31.087841: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-12-04 09:45:31.377680: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-12-04 09:45:31.379317: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-04 09:45:33.362517: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/usr/local/bin/tensorflowjs_converter", line 8, in <module>
    sys.exit(pip_main())
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 958, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 962, in main
    convert(argv[0].split(' '))
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 948, in convert
    _dispatch_converter(input_format, output_format, args, quantization_dtype_map,
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 682, in _dispatch_converter
    dispatch_tensorflowjs_to_keras_h5_conversion(args.input_path,
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 308, in dispatch_tensorflowjs_to_keras_h5_conversion
    raise ValueError(
ValueError: For input_type=tfjs_layers_model & output_format=keras, the input path should be a model.json file, but received a directory.
krish@DESKTOP-L8N8U7O:/mnt/d/Code/translate/src/assets/models$ tensorflowjs_converter --input_format tfjs_layers_model --output_format keras face-features/model.json new/
2023-12-04 09:46:08.115969: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-12-04 09:46:08.196721: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-12-04 09:46:08.197775: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-04 09:46:09.141644: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2023-12-04 09:46:13.484437: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:981] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2023-12-04 09:46:13.485284: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1960] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
WARNING:tensorflow:From /home/krish/.local/lib/python3.8/site-packages/keras/src/layers/normalization/batch_normalization.py:883: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "/usr/local/bin/tensorflowjs_converter", line 8, in <module>
    sys.exit(pip_main())
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 958, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 962, in main
    convert(argv[0].split(' '))
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 948, in convert
    _dispatch_converter(input_format, output_format, args, quantization_dtype_map,
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 682, in _dispatch_converter
    dispatch_tensorflowjs_to_keras_h5_conversion(args.input_path,
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/converter.py", line 329, in dispatch_tensorflowjs_to_keras_h5_conversion
    model = keras_tfjs_loader.load_keras_model(config_json_path)
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 299, in load_keras_model
    return _deserialize_keras_model(config_json['modelTopology'],
  File "/usr/local/lib/python3.8/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 95, in _deserialize_keras_model
    weights_list.append(weights_dict[shorten_name])
KeyError: 'simple_rnn_25/kernel'
gaikwadrahul8 commented 12 months ago

Hi, @bipinkrish

Thank you for bringing this issue to our attention and I was trying to replicate the same behavior from my end and I'm also getting the same error messages which you've mentioned in the issue template so we'll have to dig more into this issue and will update you soon.

Thank you for your understanding and patience.

Here is error output log for reference :

2023-12-04 11:03:24.445771: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-12-04 11:03:24.445847: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-12-04 11:03:24.447202: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-12-04 11:03:25.514124: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
WARNING:tensorflow:From /usr/local/lib/python3.10/dist-packages/keras/src/layers/normalization/batch_normalization.py:883: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "/usr/local/bin/tensorflowjs_converter", line 8, in <module>
    sys.exit(pip_main())
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/converter.py", line 958, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/converter.py", line 962, in main
    convert(argv[0].split(' '))
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/converter.py", line 948, in convert
    _dispatch_converter(input_format, output_format, args, quantization_dtype_map,
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/converter.py", line 682, in _dispatch_converter
    dispatch_tensorflowjs_to_keras_h5_conversion(args.input_path,
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/converter.py", line 329, in dispatch_tensorflowjs_to_keras_h5_conversion
    model = keras_tfjs_loader.load_keras_model(config_json_path)
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 299, in load_keras_model
    return _deserialize_keras_model(config_json['modelTopology'],
  File "/usr/local/lib/python3.10/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 95, in _deserialize_keras_model
    weights_list.append(weights_dict[shorten_name])
KeyError: 'simple_rnn_25/kernel'