deepfakes/faceswap · error · ValueError
'{method}' is not a valid clipping method. Select from {list
Error message
'{method}' is not a valid clipping method. Select from {list(methods)} What it means
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.
Source
Thrown at lib/training/optimizer.py:125
Parameters
----------
method
The clipping method to use
autoclip_history
The history length for auto clipping
Returns
-------
The function used to clip the gradients
"""
methods: dict[str, T.Callable[[list[nn.Parameter], float], None | torch.Tensor]] = {
"autoclip": AutoClipper(int(self._value * 10), history_size=autoclip_history),
"global_norm": nn.utils.clip_grad_norm_,
"norm": self._clip_norm,
"value": nn.utils.clip_grad_value_}
if method not in methods:
raise ValueError(f"'{method}' is not a valid clipping method. Select "
f"from {list(methods)}")
retval = methods[method]
logger.debug("[GradClip] Got clipper '%s': %s", method, retval)
return retval
def __call__(self, parameters: list[nn.Parameter]) -> None:
"""Clip the given parameters by the chosen method
Parameters
----------
parameters
The parameters to clip
"""
self._clipper(parameters, self._value)
class Optimizer:
"""Object for managing the selected Torch optimizerView on GitHub (pinned to f530cb7508)
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.
Example fix
# before clipgrad = auto-clip # after clipgrad = autoclip
Defensive patterns
Strategy: validation
Validate before calling
valid_clip_methods = {"autoclip", "global_norm", "norm", "value"}
assert cfg_value in valid_clip_methods, f"clip method must be one of {valid_clip_methods}" Type guard
def is_valid_clip_method(method: str) -> bool:
return method in {"autoclip", "global_norm", "norm", "value"} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Hand-editing config files; config written by an older version of the codebase; names with wrong case or hyphens instead of underscores.
Related errors
- '{name}' is not a valid optimizer. Select from {list(_OPTIMI
- 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/8b1766894b2249dc.
Report an issue: GitHub.