deepfakes/faceswap · error · ValueError
'{name}' is not a valid optimizer. Select from {list(_OPTIMI
Error message
'{name}' is not a valid optimizer. Select from {list(_OPTIMIZERS)} What it means
Raised when building the training optimizer if config.optimizer() does not match any key in the _OPTIMIZERS registry in lib/training/optimizer.py. The optimizer name is read straight from the user's training configuration, so any unrecognised string aborts training at startup with this ValueError.
Source
Thrown at lib/training/optimizer.py:224
return retval
def _get_optimizer(self, model: K_Model, config: type[OptConfig]) -> torch.optim.Optimizer:
"""Obtain the configured optimizer the given configuration file options
Parameters
----------
model
The keras model that is to be trained
config
The optimizer user configuration options
Returns
-------
The requested configured optimizer
"""
name = config.optimizer()
if name not in _OPTIMIZERS:
raise ValueError(f"'{name}' is not a valid optimizer. Select from {list(_OPTIMIZERS)}")
optimizer = _OPTIMIZERS[name]
retval = optimizer(self._get_parameter_groups(model, config.weight_decay()),
lr=config.learning_rate(),
**self._get_optimizer_kwargs(config))
logger.debug("[Optimizer] Got optimizer '%s': %s", name, retval)
return retval
def _get_parameter_groups(self, model: K_Model, weight_decay: float
) -> tuple[dict[T.Literal["params", "weight_decay"],
list[nn.Parameter] | float],
dict[T.Literal["params", "weight_decay"],
list[nn.Parameter] | float]]:
"""Obtain the parameter groups from within the keras model
Parameters
----------
modelView on GitHub (pinned to f530cb7508)
Solutions
- Set the optimizer in the training config to one of the names printed in the error (the keys of _OPTIMIZERS).
- Pick the value via the GUI Train > Configure dialog so only valid names are offered.
- Delete/regenerate the stale training config after upgrading Faceswap so it is rewritten with the currently valid options.
Example fix
# before [optimizer.optimizer] = adamax # after [optimizer.optimizer] = adam
Defensive patterns
Strategy: validation
Validate before calling
from lib.training.optimizer import _OPTIMIZERS # module-level registry
assert config_optimizer_name in _OPTIMIZERS, f"pick from {list(_OPTIMIZERS)}" Type guard
def is_valid_optimizer(name: str, registry: dict) -> bool:
return name in registry Prevention
- Choose optimizer names from the GUI dropdown rather than typing them.
- Re-validate hand-edited configs against the current version's option list before launching training.
When it happens
Trigger: Training is launched with an optimizer name in the training config that is not registered (typos like 'ADAM', 'adamw' when unsupported, or names removed after a Faceswap upgrade, e.g. the Keras-to-PyTorch backend migration).
Common situations: Hand-edited config files; configs carried across versions where the optimizer list changed; copying a config from a tutorial/forum listing optimizers this build does not include.
Related errors
- '{method}' is not a valid clipping method. Select from {list
- Penalized Mask Loss has been selected but you have not chose
- You have selected the mask type '{mask_type}' but at least o
- Load weights selected, but the path '{weights_file}' does no
- 'Learn Mask' has been selected but you have not chosen a Mas
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/067d5b7546f49820.
Report an issue: GitHub.