{"record":{"id":"067d5b7546f49820","repo":"deepfakes/faceswap","slug":"name-is-not-a-valid-optimizer-select-from-li","errorCode":null,"errorMessage":"'{name}' is not a valid optimizer. Select from {list(_OPTIMIZERS)}","messagePattern":"'(.+?)' is not a valid optimizer\\. Select from (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/training/optimizer.py","lineNumber":224,"sourceCode":"        return retval\n\n    def _get_optimizer(self, model: K_Model, config: type[OptConfig]) -> torch.optim.Optimizer:\n        \"\"\"Obtain the configured optimizer the given configuration file options\n\n        Parameters\n        ----------\n        model\n            The keras model that is to be trained\n        config\n            The optimizer user configuration options\n\n        Returns\n        -------\n        The requested configured optimizer\n        \"\"\"\n        name = config.optimizer()\n        if name not in _OPTIMIZERS:\n            raise ValueError(f\"'{name}' is not a valid optimizer. Select from {list(_OPTIMIZERS)}\")\n        optimizer = _OPTIMIZERS[name]\n\n        retval = optimizer(self._get_parameter_groups(model, config.weight_decay()),\n                           lr=config.learning_rate(),\n                           **self._get_optimizer_kwargs(config))\n        logger.debug(\"[Optimizer] Got optimizer '%s': %s\", name, retval)\n        return retval\n\n    def _get_parameter_groups(self, model: K_Model, weight_decay: float\n                              ) -> tuple[dict[T.Literal[\"params\", \"weight_decay\"],\n                                              list[nn.Parameter] | float],\n                                         dict[T.Literal[\"params\", \"weight_decay\"],\n                                              list[nn.Parameter] | float]]:\n        \"\"\"Obtain the parameter groups from within the keras model\n\n        Parameters\n        ----------\n        model","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/training/optimizer.py#L206-L242","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\n[optimizer.optimizer] = adamax\n\n# after\n[optimizer.optimizer] = adam","handlingStrategy":"validation","validationCode":"from lib.training.optimizer import _OPTIMIZERS  # module-level registry\nassert config_optimizer_name in _OPTIMIZERS, f\"pick from {list(_OPTIMIZERS)}\"","typeGuard":"def is_valid_optimizer(name: str, registry: dict) -> bool:\n    return name in registry","tryCatchPattern":null,"preventionTips":["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."],"tags":["faceswap","training","optimizer","configuration","validation"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}