{"record":{"id":"8b1766894b2249dc","repo":"deepfakes/faceswap","slug":"method-is-not-a-valid-clipping-method-select","errorCode":null,"errorMessage":"'{method}' is not a valid clipping method. Select from {list(methods)}","messagePattern":"'(.+?)' is not a valid clipping method\\. Select from (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/training/optimizer.py","lineNumber":125,"sourceCode":"\n        Parameters\n        ----------\n        method\n            The clipping method to use\n        autoclip_history\n            The history length for auto clipping\n\n        Returns\n        -------\n        The function used to clip the gradients\n        \"\"\"\n        methods: dict[str, T.Callable[[list[nn.Parameter], float], None | torch.Tensor]] = {\n            \"autoclip\": AutoClipper(int(self._value * 10), history_size=autoclip_history),\n            \"global_norm\": nn.utils.clip_grad_norm_,\n            \"norm\": self._clip_norm,\n            \"value\": nn.utils.clip_grad_value_}\n        if method not in methods:\n            raise ValueError(f\"'{method}' is not a valid clipping method. Select \"\n                             f\"from {list(methods)}\")\n        retval = methods[method]\n        logger.debug(\"[GradClip] Got clipper '%s': %s\", method, retval)\n        return retval\n\n    def __call__(self, parameters: list[nn.Parameter]) -> None:\n        \"\"\"Clip the given parameters by the chosen method\n\n        Parameters\n        ----------\n        parameters\n            The parameters to clip\n        \"\"\"\n        self._clipper(parameters, self._value)\n\n\nclass Optimizer:\n    \"\"\"Object for managing the selected Torch optimizer","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/training/optimizer.py#L107-L143","documentation":"Raised by the trainer's gradient-clipping factory in lib/training/optimizer.py when the clipping method string in the optimizer section of the training configuration does not match one of the implemented clippers: 'autoclip', 'global_norm', 'norm', or 'value'. It is a plain ValueError and surfaces before training starts, as soon as the optimizer is built.","triggerScenarios":"Editing the training config file and setting the gradient clipping option to a typo'd or unsupported value (e.g. 'auto-clip', 'gradient', 'clip'), or carrying over a value from an older Faceswap version whose method names changed.","commonSituations":"Hand-editing config files; config written by an older version of the codebase; names with wrong case or hyphens instead of underscores.","solutions":["Change the gradient clipping setting in the training config to one of: autoclip, global_norm, norm, value.","If unsure of the exact spelling, use the GUI's Train > Configure settings dialog, which only offers valid values.","Check for stale config files after upgrading Faceswap and regenerate the config."],"exampleFix":"# before\nclipgrad = auto-clip\n\n# after\nclipgrad = autoclip","handlingStrategy":"validation","validationCode":"valid_clip_methods = {\"autoclip\", \"global_norm\", \"norm\", \"value\"}\nassert cfg_value in valid_clip_methods, f\"clip method must be one of {valid_clip_methods}\"","typeGuard":"def is_valid_clip_method(method: str) -> bool:\n    return method in {\"autoclip\", \"global_norm\", \"norm\", \"value\"}","tryCatchPattern":null,"preventionTips":["Only edit training config through the GUI settings dialogs, which enumerate valid values.","After upgrading Faceswap, regenerate or diff config files against defaults to catch renamed options."],"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"}