Skip to content

Commit

Permalink
remove input_signature in from_keras_tf1()
Browse files Browse the repository at this point in the history
Signed-off-by: hwangdeyu <dejack953@outlook.com>
  • Loading branch information
hwangdeyu committed Feb 23, 2022
1 parent 18d830a commit 6b98a55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ The reason for this is that there is a dynamic input of a tensorflow op but the

An example of this is the [ONNX Slice operator before opset-10](https://github.com/onnx/onnx/blob/master/docs/Changelog.md#Slice-1) - the start and end of the slice are static attributes that need to be known at graph creation. In tensorflow the [strided slice op](https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/strided-slice) allows dynamic inputs. tf2onnx will try to find the real value of begin and end of the slice and can find them in most cases. But if those are real dynamic values calculate at runtime it will result in the message ```get tensor value: ... must be Const```.

You can pass the options ```--fold_const(deprecated after tf2onnx-1.9.3)``` in the tf2onnx command line that allows tf2onnx to apply more aggressive constant folding which will increase chances to find a constant.
You can pass the options ```--fold_const```(removed after tf2onnx-1.9.3) in the tf2onnx command line that allows tf2onnx to apply more aggressive constant folding which will increase chances to find a constant.

If this doesn't work the model is most likely not to be able to convert to ONNX. We used to see this a lot of issue with the ONNX Slice op and in opset-10 was updated for exactly this reason.
10 changes: 5 additions & 5 deletions tf2onnx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ def _is_legacy_keras_model(model):
return False


def _from_keras_tf1(model, input_signature=None, opset=None, custom_ops=None, custom_op_handlers=None,
custom_rewriter=None, inputs_as_nchw=None, extra_opset=None, shape_override=None,
target=None, large_model=False, output_path=None):
def _from_keras_tf1(model, opset=None, custom_ops=None, custom_op_handlers=None, custom_rewriter=None,
inputs_as_nchw=None, extra_opset=None, shape_override=None, target=None,
large_model=False, output_path=None):
"""from_keras for tf 1.15"""
input_names = [t.name for t in model.inputs]
output_names = [t.name for t in model.outputs]
Expand Down Expand Up @@ -422,8 +422,8 @@ def from_keras(model, input_signature=None, opset=None, custom_ops=None, custom_
An ONNX model_proto and an external_tensor_storage dict.
"""
if LooseVersion(tf.__version__) < "2.0":
return _from_keras_tf1(model, input_signature, opset, custom_ops, custom_op_handlers, custom_rewriter,
inputs_as_nchw, extra_opset, shape_override, target, large_model, output_path)
return _from_keras_tf1(model, opset, custom_ops, custom_op_handlers, custom_rewriter, inputs_as_nchw,
extra_opset, shape_override, target, large_model, output_path)

old_out_names = _rename_duplicate_keras_model_names(model)
from tensorflow.python.keras.saving import saving_utils as _saving_utils # pylint: disable=import-outside-toplevel
Expand Down

0 comments on commit 6b98a55

Please sign in to comment.