tensorflow/models · error · AttributeError
`BUILDER` is a property and `_BUILDER` is the reserved…
Error message
`BUILDER` is a property and `_BUILDER` is the reserved class attribute. We should only assign `_BUILDER` at the class level.
What it means
Reserved-attribute guard in Config.__setattr__: user code tried to assign 'BUILDER' or '_BUILDER' on an instance. BUILDER is a read-only property resolving to the class-level _BUILDER, so it must be set via the bind decorator at class definition time, never per-instance.
Solutions
- Use the bind decorator on the Config class to register its builder
- Remove any direct instance assignments to BUILDER/_BUILDER
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/modeling/hyperparams/base_config.py:272 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/c6744ce1f5f51b7a.
Report an issue: GitHub.
Appendix: source
Thrown at official/modeling/hyperparams/base_config.py:272
elif not is_null(k) and isinstance(v, self.SEQUENCE_TYPES) and all(
[not isinstance(e, self.IMMUTABLE_TYPES) for e in v]):
if len(self.__dict__[k]) == len(v):
for i in range(len(v)):
self.__dict__[k][i].override(v[i])
elif not all([isinstance(e, self.IMMUTABLE_TYPES) for e in v]):
logging.warning(
"The list/tuple don't match the value dictionaries provided. Thus, "
'the list/tuple is determined by the type annotation and '
'values provided. This is error-prone.')
self.__dict__[k] = self._import_config(v, subconfig_type)
else:
self.__dict__[k] = self._import_config(v, subconfig_type)
else:
self.__dict__[k] = self._import_config(v, subconfig_type)
def __setattr__(self, k, v):
if k == 'BUILDER' or k == '_BUILDER':
raise AttributeError('`BUILDER` is a property and `_BUILDER` is the '
'reserved class attribute. We should only assign '
'`_BUILDER` at the class level.')
if k not in self.RESERVED_ATTR:
if getattr(self, '_locked', False):
raise ValueError('The Config has been locked. ' 'No change is allowed.')
self._set(k, v)
def _override(self, override_dict, is_strict=True):
"""Overrides same method in ParamsDict.
Also called by ParamsDict methods.
Args:
override_dict: dictionary to write to .
is_strict: If True, not allows to add new keys.
Raises:View on GitHub (pinned to e006f5f0d5)