Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit f90fa00

Browse files
authored
Show error when using keras2onnx with tf>=2.3 (#116)
* Show error when using keras2onnx with tf>=2.3 * Change warn flag to raise; update message * Using f string
1 parent 10c1121 commit f90fa00

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/sparseml/keras/utils/exporter.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def export_onnx(
6060
opset: int = DEFAULT_ONNX_OPSET,
6161
doc_string: str = "",
6262
debug_mode: bool = True,
63+
raise_on_tf_support: bool = True,
6364
**kwargs,
6465
):
6566
"""
@@ -74,6 +75,16 @@ def export_onnx(
7475
if keras2onnx_import_error is not None:
7576
raise keras2onnx_import_error
7677

78+
if raise_on_tf_support:
79+
import tensorflow
80+
v = tensorflow.__version__
81+
if v >= "2.3.0":
82+
raise ValueError(
83+
f"Tensorflow version {v} is greater than the currently supported "
84+
"version for keras2onnx. Please downgrade the Tensorflow <2.3.0 "
85+
"or set raise_on_tf_support to False to continue."
86+
)
87+
7788
model_name = self._model.name or name.split(".onnx")[0]
7889
onnx_model = keras2onnx.convert_keras(
7990
self._model,

0 commit comments

Comments
 (0)