tensorflow/models · error · ValueError
Variables to load is empty.
Error message
Variables to load is empty.
What it means
Sanity check inside the checkpoint-restore scaffold function: after building the assignment map from the model variables and the checkpoint's var_to_shape_map, no variables remained to load. This means none of the model's variable names matched the checkpoint entries under the given prefix/skip regex.
Solutions
- Verify the checkpoint path points to a compatible pretrained checkpoint
- Check that the prefix matches the variable naming in the checkpoint (e.g. the backbone prefix)
- Relax or remove skip_variables_regex if it is excluding all variables
- Confirm the model was built before restore is attempted so variables exist
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/legacy/detection/modeling/checkpoint_utils.py:139 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/32e28355153e383b.
Report an issue: GitHub.
Appendix: source
Thrown at official/legacy/detection/modeling/checkpoint_utils.py:139
"""
def _restore_checkpoint_fn(keras_model):
"""Loads pretrained model through scaffold function."""
if not checkpoint_path:
logging.info('checkpoint_path is empty')
return
var_prefix = prefix
if prefix and not prefix.endswith('/'):
var_prefix += '/'
var_to_shape_map = _get_checkpoint_map(checkpoint_path)
assert var_to_shape_map, 'var_to_shape_map should not be empty'
vars_to_load = _build_assignment_map(
keras_model,
prefix=var_prefix,
skip_variables_regex=skip_regex,
var_to_shape_map=var_to_shape_map)
if not vars_to_load:
raise ValueError('Variables to load is empty.')
tf.compat.v1.train.init_from_checkpoint(checkpoint_path, vars_to_load)
return _restore_checkpoint_fn
View on GitHub (pinned to e006f5f0d5)