Skip to content

Commit ed57b37

Browse files
Guy Nicholsontensorflower-gardener
authored andcommitted
Add information to error message.
PiperOrigin-RevId: 455171224
1 parent d9c3be7 commit ed57b37

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tensorflow_model_optimization/python/core/quantization/keras/quantize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ def _quantize(layer): # pylint: disable=missing-docstring
441441
# modifications don't affect the original model, or its weights.
442442
try:
443443
model_copy = _clone_model_with_weights(model)
444-
except ValueError:
444+
except ValueError as er:
445445
raise ValueError(
446446
'Unable to clone model. This generally happens if you used custom '
447447
'Keras layers or objects in your model. Please specify them via '
448448
'`quantize_scope` for your calls to `quantize_model` and '
449-
'`quantize_apply`.')
449+
'`quantize_apply`. [%s].' % er)
450450

451451
# 2. Remove QuantizeAnnotate wrappers from the layers in the model. This
452452
# extracts the original model structure (easier to transform), and

tensorflow_model_optimization/python/core/quantization/keras/quantize_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def testQuantizeCustomLayerWithoutQuantizeScope_RaisesError(self):
362362
'`quantize_scope` for your calls to `quantize_model` and '
363363
'`quantize_apply`.')
364364

365-
self.assertEqual(str(err.exception), expected_error)
365+
self.assertIn(expected_error, str(err.exception))
366366

367367
def testQuantize_RaisesErrorIfNoQuantizeConfig(self):
368368
annotated_model = keras.Sequential([

0 commit comments

Comments
 (0)