{"record":{"id":"f87fa197408dc849","repo":"deepfakes/faceswap","slug":"the-tflambdaop-name-is-not-supported","errorCode":null,"errorMessage":"The TFLambdaOp '{name}' is not supported","messagePattern":"The TFLambdaOp '(.+?)' is not supported","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"plugins/train/model/_base/update.py","lineNumber":153,"sourceCode":"\n    def _convert_lambda_config(self, layer: dict[str, T.Any]):\n        \"\"\"Keras 2 TFLambdaOps are not compatible with Keras 3. Scalar operations can be\n        relatively easily substituted with a :class:`~lib.model.layers.ScalarOp` layer\n\n        Parameters\n        ----------\n        layer\n            An existing Keras 2 TFLambdaOp layer\n\n        Raises\n        ------\n        FaceswapError\n            If the TFLambdaOp is not currently supported\n        \"\"\"\n        name = layer[\"config\"][\"name\"]\n        operation = name.rsplit(\".\", maxsplit=1)[-1]\n        if operation not in (\"multiply\", \"truediv\", \"add\", \"subtract\"):\n            raise FaceswapError(f\"The TFLambdaOp '{name}' is not supported\")\n        value = layer[\"inbound_nodes\"][0][-1][\"y\"]\n\n        if isinstance(layer[\"config\"][\"dtype\"], str):\n            dtype = layer[\"config\"][\"dtype\"]\n        else:\n            dtype = layer[\"config\"][\"dtype\"][\"config\"][\"name\"]\n        new_layer = ScalarOp(operation, value, name=name, dtype=dtype)\n\n        logger.debug(\"Converting legacy TFLambdaOp: %s\", layer)\n\n        layer[\"class_name\"] = \"ScalarOp\"\n        layer[\"config\"] = new_layer.get_config()\n        for n in layer[\"inbound_nodes\"]:\n            n[-1] = {}\n        layer[\"inbound_nodes\"] = [layer[\"inbound_nodes\"]]\n        logger.debug(\"Converted legacy TFLambdaOp to %s\", layer)\n\n    def _process_deprecations(self, layer: dict[str, T.Any]) -> None:  # noqa[C901]","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/plugins/train/model/_base/update.py#L135-L171","documentation":"FaceswapError raised while converting a legacy Keras 2 model config to Keras 3: a TFLambdaOp layer is encountered whose operation (the last '.'-separated segment of its name) is not one of multiply, truediv, add, subtract. Those four are the only lambda ops the converter can map to Keras 3 ScalarOp layers. Anything else (e.g. custom tf functions) has no automatic equivalent.","triggerScenarios":"Porting a Faceswap 2 model that contains an exotic TFLambdaOp layer, e.g. from a fork or plugin that added custom lambda operations to the graph. operation = name.rsplit('.', 1)[-1] fails the whitelist check.","commonSituations":"Porting models produced by modified Faceswap forks, very old versions, or models whose config was hand-edited to insert custom lambdas.","solutions":["Check the layer name reported in the error to identify the unsupported operation","Re-save/rebuild the model in Faceswap 2 using only the supported arithmetic lambda ops, then port","If the op is one you added yourself, implement an equivalent ScalarOp mapping upstream in update.py before porting"],"exampleFix":"# before: legacy config layer named\n# 'model/tf.math.reduce_mean_3' -> raises (reduce_mean unsupported)\n\n# after: rebuild in FS2 using supported op, e.g.\n# 'model/tf.math.multiply_1' -> converts to ScalarOp","handlingStrategy":"try-catch","validationCode":"import json\ncfg = json.loads(config_str)\nfor layer in cfg[\"config\"][\"layers\"]:\n    if layer[\"class_name\"] == \"TFLambdaOp\":\n        op = layer[\"config\"][\"name\"].rsplit(\".\", 1)[-1]\n        if op not in (\"multiply\", \"truediv\", \"add\", \"subtract\"):\n            raise SystemExit(f\"Unsupported lambda op {op!r}; rebuild model with supported ops\")","typeGuard":null,"tryCatchPattern":"from lib.exceptions import FaceswapError\ntry:\n    updater.port_model()\nexcept FaceswapError as err:\n    if \"TFLambdaOp\" in str(err):\n        log_unportable_model(old_file)  # record and skip, do not crash the batch\n    else:\n        raise","preventionTips":["Only port models produced by unmodified Faceswap releases","Avoid custom lambda layers when creating models intended to be portable"],"tags":["faceswap","keras","migration","lambda-layer"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}