tensorflow/models · error · ValueError
Unexpected dtype: %s
Error message
Unexpected dtype: %s
What it means
Error "Unexpected dtype: %s" thrown in tensorflow/models.
Source
Thrown at official/modeling/performance.py:53
optimizer = tf_keras.mixed_precision.LossScaleOptimizer(
optimizer, dynamic=False, initial_scale=loss_scale)
return optimizer
def set_mixed_precision_policy(dtype, loss_scale=None):
"""Sets the global `tf_keras.mixed_precision.Policy`."""
# TODO(b/191894773): Remove loss_scale argument
assert loss_scale is None, (
'The loss_scale argument must be None. The argument exists for '
'historical reasons and will be removed soon.')
if dtype == tf.float16:
tf_keras.mixed_precision.set_global_policy('mixed_float16')
elif dtype == tf.bfloat16:
tf_keras.mixed_precision.set_global_policy('mixed_bfloat16')
elif dtype == tf.float32:
tf_keras.mixed_precision.set_global_policy('float32')
else:
raise ValueError('Unexpected dtype: %s' % dtype)
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/modeling/performance.py:53 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/1d279add19099a6b.
Report an issue: GitHub.