{"record":{"id":"272807a19586c358","repo":"keras-team/keras","slug":"invalid-input-type-for-serialization-received-f","errorCode":null,"errorMessage":"Invalid input type for serialization. Received: {fn} of type {type(fn)}.","messagePattern":"Invalid input type for serialization\\. Received: (.+?) of type (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/core/lambda_layer.py","lineNumber":164,"sourceCode":"            self.arguments\n        )\n        base_config = super().get_config()\n        return {**base_config, **config}\n\n    def _serialize_function_to_config(self, fn):\n        if isinstance(fn, types.LambdaType) and fn.__name__ == \"<lambda>\":\n            code, defaults, closure = python_utils.func_dump(fn)\n            return {\n                \"class_name\": \"__lambda__\",\n                \"config\": {\n                    \"code\": code,\n                    \"defaults\": defaults,\n                    \"closure\": closure,\n                },\n            }\n        elif callable(fn):\n            return serialization_lib.serialize_keras_object(fn)\n        raise ValueError(\n            \"Invalid input type for serialization. \"\n            f\"Received: {fn} of type {type(fn)}.\"\n        )\n\n    @staticmethod\n    def _raise_for_lambda_deserialization(safe_mode):\n        if safe_mode:\n            raise ValueError(\n                \"Requested the deserialization of a `Lambda` layer whose \"\n                \"`function` is a Python lambda. This carries a potential risk \"\n                \"of arbitrary code execution and thus it is disallowed by \"\n                \"default. If you trust the source of the artifact, you can \"\n                \"override this error by passing `safe_mode=False` to the \"\n                \"loading function, or calling \"\n                \"`keras.config.enable_unsafe_deserialization().\"\n            )\n\n    @classmethod","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/core/lambda_layer.py#L146-L182","documentation":"Error \"Invalid input type for serialization. Received: {fn} of type {type(fn)}.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/core/lambda_layer.py:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}