onnx / tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Apache License 2.0
2.31k stars 433 forks source link

error when converting the model to .onnx by command "python -m tf2onnx.convert": ValueError: Cannot find the variable that is an input to the ReadVariableOp. #1210

Closed shingming closed 3 years ago

shingming commented 3 years ago

Description of the problem

Hi, I follow the CLI reference to converting the model to .onnx, but I get some errors.

cmd line: python -m tf2onnx.convert --saved-model "C:\Users\timla\Documents\Music Project\Python\con_model_type\savedModel" --checkpoint "C:\Users\timla\Documents\Music Project\Python\con_model_type\ckpy\LSTM.ckpt.meta" --input "C:\Users\timla\Documents\Music Project\Python\con_model_type\LSTM_o.pb" --output "C:\Users\timla\Desktop\output.onnx" --outputs "dense_3/Softmax:0" --inputs "time_distributed_1_input:0" --verbose --fold_const

The first error is tensorflow.python.framework.errors_impl.InvalidArgumentError: Beta input to batch norm has bad shape: [32] and after I ref. this post, I got that the error maybe coming from TF optimization. Therefore, I remove some line(from line 212 to 213) in this script -> link

After I do that and enter the same common line, I get a new error: ValueError: Cannot find the variable that is an input to the ReadVariableOp.

log

WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\verbose_logging.py:76: The name tf.logging.set_verbosity is deprecated. Please use tf.com
pat.v1.logging.set_verbosity instead.

2020-12-03 01:58:32,256 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\verbose_logging.py:76: The name tf.logging.set_verbosity is
deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

2020-12-03 01:58:32.269027: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:173: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile ins
tead.

2020-12-03 01:58:32,274 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:173: The name tf.gfile.GFile is deprecated. Ple
ase use tf.io.gfile.GFile instead.

WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:149: convert_variables_to_constants (from tensorflow.python.framework.graph_
util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.convert_variables_to_constants`
2020-12-03 01:58:32,808 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:149: convert_variables_to_constants (from tenso
rflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.convert_variables_to_constants`
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\framework\graph_util_impl.py:270: extract_sub_graph (from tensorflow.python.fra
mework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
2020-12-03 01:58:32,810 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\framework\graph_util_impl.py:270: extract_sub_grap
h (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
INFO:tensorflow:Froze 0 variables.
2020-12-03 01:58:32,948 - INFO - tensorflow: Froze 0 variables.
INFO:tensorflow:Converted 0 variables to const ops.
2020-12-03 01:58:33,077 - INFO - tensorflow: Converted 0 variables to const ops.
2020-12-03 01:58:33.340275: I tensorflow/tools/graph_transforms/transform_graph.cc:317] Applying fold_constants
2020-12-03 01:58:33.881126: I tensorflow/tools/graph_transforms/transform_graph.cc:317] Applying remove_attribute
2020-12-03 01:58:33.957878: I tensorflow/tools/graph_transforms/transform_graph.cc:317] Applying fold_batch_norms
2020-12-03 01:58:34.098202: I tensorflow/tools/graph_transforms/transform_graph.cc:317] Applying fold_old_batch_norms
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from tensorflow.python.training.chec
kpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
2020-12-03 01:58:36,809 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from te
nsorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
INFO:tensorflow:Restoring parameters from C:\Users\timla\Documents\Music Project\Python\con_model_type\ckpy\LSTM.ckpt
2020-12-03 01:58:36,812 - INFO - tensorflow: Restoring parameters from C:\Users\timla\Documents\Music Project\Python\con_model_type\ckpy\LSTM.ckpt
INFO:tensorflow:Froze 688 variables.
2020-12-03 01:58:38,528 - INFO - tensorflow: Froze 688 variables.
INFO:tensorflow:Converted 688 variables to const ops.
2020-12-03 01:58:39,159 - INFO - tensorflow: Converted 688 variables to const ops.
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:224: The name tf.saved_model.tag_constants.SERVING is deprecated. Please use
 tf.saved_model.SERVING instead.

2020-12-03 01:58:39,343 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:224: The name tf.saved_model.tag_constants.SERV
ING is deprecated. Please use tf.saved_model.SERVING instead.

2020-12-03 01:58:39,344 - WARNING - tf2onnx.tf_loader: '--tag' not specified for saved_model. Using --tag serve
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:234: load (from tensorflow.python.saved_model.loader_impl) is deprecated and
 will be removed in a future version.
Instructions for updating:
This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for imp
orting SavedModels in Tensorflow 2.0.
2020-12-03 01:58:39,344 - WARNING - tensorflow: From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:234: load (from tensorflow.python.saved_model.l
oader_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for imp
orting SavedModels in Tensorflow 2.0.
INFO:tensorflow:Restoring parameters from C:\Users\timla\Documents\Music Project\Python\con_model_type\savedModel\variables\variables
2020-12-03 01:58:40,099 - INFO - tensorflow: Restoring parameters from C:\Users\timla\Documents\Music Project\Python\con_model_type\savedModel\variables\variables
Traceback (most recent call last):
  File "C:\Users\timla\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\timla\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\convert.py", line 188, in <module>
    main()
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\convert.py", line 137, in main
    args.signature_def, args.concrete_function, args.large_model)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py", line 340, in from_saved_model
    _from_saved_model_v1(sess, model_path, input_names, output_names, tag, signatures)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py", line 258, in _from_saved_model_v1
    frozen_graph = freeze_session(sess, input_names=input_names, output_names=output_names)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py", line 149, in freeze_session
    graph_def = convert_variables_to_constants(sess, graph_def, output_node_names)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tensorflow\python\framework\graph_util_impl.py", line 302, in convert_variables_to_constants
    raise ValueError("Cannot find the variable that is an input "
ValueError: Cannot find the variable that is an input to the ReadVariableOp.

I ref. this post because the model type is very similar for my model, with LSTM - CNN - Dense layer(you can see the detail of the model structure in the Screenshots part), so I add --fold_const in the command line, unfortunately, the same condition after that.

System information

Screenshots The following image is the model structure which is training on Keras framework, then converting the model type from .h5 to .ckpt, .pb and savedModel type in order to convert the model to .onnx

3

Input layer 1

output layer 2

TomWildenhain-Microsoft commented 3 years ago

Hi @shingming , thanks for the thorough explanation and log contents. Are you able to share a copy of the saved_model you are converting?

shingming commented 3 years ago

@TomWildenhain-Microsoft Of course, the download link is here: https://drive.google.com/file/d/1WtzXFJrBHU_I6x7digIPO1mMRUox2Teo/view?usp=sharing

TomWildenhain-Microsoft commented 3 years ago

Try this: python -m tf2onnx.convert --saved-model "C:\Users\timla\Documents\Music Project\Python\con_model_type\savedModel" For saved models, you don't need to specify a checkpoint or inputs/outputs.

shingming commented 3 years ago

@TomWildenhain-Microsoft got the same condition by your suggestion :( ValueError: Cannot find the variable that is an input to the ReadVariableOp.

TomWildenhain-Microsoft commented 3 years ago

Interesting. What version of TensorFlow are you using? Can you try updating to the latest version?

shingming commented 3 years ago

@TomWildenhain-Microsoft For the past, my Tensorflow version is 1.14.0 and then I follow your suggestion that updating to 2.3.1, it works for me! Thx!

Btw, Because of my model on training step is using tf version 1.x and I know that it is a big change between version 1.x and 2.x, so avoiding to incompatibility and error condition, I use tf version 1.x to converting, but it is clear to see that my previous assumption is wrong.

command: python -m tf2onnx.convert --saved-model "C:\Users\timla\Documents\Music Project\Python\con_model_type\savedMode l" --output "C:\Users\timla\Documents\Music Project\Python\con_model_type\output.onnx"

log:

2020-12-05 14:57:32.921008: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-12-05 14:57:32.921173: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2020-12-05 14:57:34,534 - WARNING - '--tag' not specified for saved_model. Using --tag serve
2020-12-05 14:57:35.404815: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2020-12-05 14:57:35.426561: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 with Max-Q Design computeCapability: 7.5
coreClock: 1.185GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 245.91GiB/s
2020-12-05 14:57:35.427539: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-12-05 14:57:35.428328: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-12-05 14:57:35.429124: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found
2020-12-05 14:57:35.429902: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found
2020-12-05 14:57:35.430635: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found
2020-12-05 14:57:35.431418: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-12-05 14:57:35.441445: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2020-12-05 14:57:35.441747: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are instal
led 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...
2020-12-05 14:57:35.442441: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the followin
g CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-12-05 14:57:35.450019: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x22b64e7c4b0 initialized for platform Host (this does not guarantee that XLA will be used). D
evices:
2020-12-05 14:57:35.450138: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-12-05 14:57:35.450448: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:35.450542: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
2020-12-05 14:57:36,880 - INFO - Signatures found in model: [serving_default].
2020-12-05 14:57:36,880 - WARNING - '--signature_def' not specified, using first signature: serving_default
WARNING:tensorflow:Issue encountered when serializing variables.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
to_proto not supported in EAGER mode.
2020-12-05 14:57:36,899 - WARNING - Issue encountered when serializing variables.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
to_proto not supported in EAGER mode.
WARNING:tensorflow:Issue encountered when serializing trainable_variables.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
to_proto not supported in EAGER mode.
2020-12-05 14:57:36,900 - WARNING - Issue encountered when serializing trainable_variables.
Type is unsupported, or the types of the items don't match field type in CollectionDef. Note this is a warning and probably safe to ignore.
to_proto not supported in EAGER mode.
2020-12-05 14:57:36.903100: I tensorflow/core/grappler/devices.cc:69] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 1
2020-12-05 14:57:36.903647: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2020-12-05 14:57:36.904682: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 with Max-Q Design computeCapability: 7.5
coreClock: 1.185GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 245.91GiB/s
2020-12-05 14:57:36.905658: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-12-05 14:57:36.906608: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-12-05 14:57:36.907514: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found
2020-12-05 14:57:36.908474: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found
2020-12-05 14:57:36.909304: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found
2020-12-05 14:57:36.910158: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-12-05 14:57:36.910226: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2020-12-05 14:57:36.910313: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are instal
led 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...
2020-12-05 14:57:36.998970: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:36.999072: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      0
2020-12-05 14:57:36.999484: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0:   N
2020-12-05 14:57:37.000392: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x22b5e785d90 initialized for platform CUDA (this does not guarantee that XLA will be used). D
evices:
2020-12-05 14:57:37.000495: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce RTX 2060 with Max-Q Design, Compute Capability 7.5
2020-12-05 14:57:37.029041: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize
2020-12-05 14:57:37.029130: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   function_optimizer: function_optimizer did nothing. time = 0.001ms.
2020-12-05 14:57:37.029525: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   function_optimizer: function_optimizer did nothing. time = 0ms.
2020-12-05 14:57:38.911238: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:38.911395: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
WARNING:tensorflow:From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:416: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is
 deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
2020-12-05 14:57:39,187 - WARNING - From C:\Users\timla\Documents\python_vm\ml_old_tf\lib\site-packages\tf2onnx\tf_loader.py:416: extract_sub_graph (from tensorflow.python.framework.gr
aph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
2020-12-05 14:57:39.289940: I tensorflow/core/grappler/devices.cc:69] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 1
2020-12-05 14:57:39.290191: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2020-12-05 14:57:39.291535: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 with Max-Q Design computeCapability: 7.5
coreClock: 1.185GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 245.91GiB/s
2020-12-05 14:57:39.292314: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-12-05 14:57:39.293119: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-12-05 14:57:39.294123: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found
2020-12-05 14:57:39.294842: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found
2020-12-05 14:57:39.296200: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found
2020-12-05 14:57:39.296804: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-12-05 14:57:39.296854: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2020-12-05 14:57:39.296898: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are instal
led 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...
2020-12-05 14:57:39.296986: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:39.297029: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      0
2020-12-05 14:57:39.297063: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0:   N
2020-12-05 14:57:40.302738: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize
2020-12-05 14:57:40.302846: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   constant_folding: Graph size after: 581 nodes (-253), 657 edges (-255), time = 660.906ms.
2020-12-05 14:57:40.303330: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   function_optimizer: function_optimizer did nothing. time = 6.203ms.
2020-12-05 14:57:40.303427: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   constant_folding: Graph size after: 581 nodes (0), 657 edges (0), time = 183.393ms.
2020-12-05 14:57:40.303549: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818]   function_optimizer: function_optimizer did nothing. time = 6.114ms.
2020-12-05 14:57:40.794599: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:40.794746: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
2020-12-05 14:57:40,794 - INFO - Using tensorflow=2.3.1, onnx=1.5.0, tf2onnx=1.7.2/995bd6
2020-12-05 14:57:40,794 - INFO - Using opset <onnx, 8>
2020-12-05 14:57:45.046417: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-05 14:57:45.046581: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
2020-12-05 14:57:45,062 - INFO - Computed 2 values for constant folding
2020-12-05 14:57:50,000 - INFO - folding node using tf type=StridedSlice, name=lstm_1/strided_slice_1
2020-12-05 14:57:50,000 - INFO - folding node using tf type=Range, name=lstm_1/TensorArrayUnstack/range
2020-12-05 14:57:50,510 - INFO - Optimizing ONNX model
2020-12-05 14:57:53,176 - INFO - After optimization: BatchNormalization -6 (40->34), Cast -11 (16->5), Concat -1 (2->1), Const -60 (286->226), Identity -13 (14->1), Less -1 (4->3), Til
e -1 (2->1), Transpose -234 (237->3), Unsqueeze -7 (9->2)
2020-12-05 14:57:53,310 - INFO -
2020-12-05 14:57:53,311 - INFO - Successfully converted TensorFlow model C:\Users\timla\Documents\Music Project\Python\con_model_type\savedModel to ONNX
2020-12-05 14:57:53,474 - INFO - ONNX model is saved at C:\Users\timla\Documents\Music Project\Python\con_model_type\output.onnx
TomWildenhain-Microsoft commented 3 years ago

Glad to hear it! TF 2 has backwards compatibility for reading TF 1 models and has all the TF 1 methods in the tf.compat.v1 namespace. tf2onnx uses some helper functions from tf that can be buggy in TF 1.