{"record":{"id":"014f4f4e0d6ac8f6","repo":"keras-team/keras","slug":"call-function-argument-is-not-supported-with-seq","errorCode":null,"errorMessage":"`call_function` argument is not supported with Sequential models.  In a Sequential model, layers aren't called at model-construction time (they're merely listed). Use `call_function` with Functional models only. Received model of type '{model.__class__.__name__}', with call_function={clone_function}","messagePattern":"`call_function` argument is not supported with Sequential models\\.  In a Sequential model, layers aren't called at model-construction time \\(they're merely listed\\)\\. Use `call_function` with Functional models only\\. Received model of type '(.+?)', with call_function=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/models/cloning.py","lineNumber":150,"sourceCode":"    In the case of a subclassed model, you cannot using a custom\n    `clone_function`.\n    \"\"\"\n    cache = kwargs.pop(\"cache\", None)\n    if kwargs:\n        raise ValueError(\n            f\"Unexpected keyword argument(s): {tuple(kwargs.keys())}\"\n        )\n\n    if isinstance(model, Sequential):\n        # Wrap clone_function to handle recursiveness and layer sharing.\n        clone_function = _wrap_clone_function(\n            clone_function,\n            call_function=call_function,\n            recursive=recursive,\n            cache=cache,\n        )\n        if call_function is not None:\n            raise ValueError(\n                \"`call_function` argument is not supported with Sequential \"\n                \"models.  In a Sequential model, layers aren't called \"\n                \"at model-construction time (they're merely listed). \"\n                \"Use `call_function` with Functional models only. \"\n                \"Received model of \"\n                f\"type '{model.__class__.__name__}', with \"\n                f\"call_function={clone_function}\"\n            )\n        return _clone_sequential_model(\n            model,\n            clone_function=clone_function,\n            input_tensors=input_tensors,\n        )\n    if isinstance(model, Functional):\n        # Wrap clone_function to handle recursiveness and layer sharing.\n        clone_function = _wrap_clone_function(\n            clone_function,\n            call_function=call_function,","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/cloning.py#L132-L168","documentation":"call_function lets you replay a Functional model's call graph at clone time. Sequential models have no recorded call graph - layers are only listed, never called - so clone_model(model, call_function=fn) on a Sequential raises this ValueError. Use clone_function for Sequential instead.","triggerScenarios":"keras.models.clone_model(sequential_model, call_function=my_fn).","commonSituations":"Generic cloning utilities that always pass call_function regardless of model type; migrating a workflow from Functional to Sequential models.","solutions":["Pass clone_function(layer) -> layer instead; it customizes per-layer cloning for Sequential.","If you need call-graph customization, rebuild the model as Functional (built from keras.Input plus layer calls) first.","Simply drop call_function for Sequential models."],"exampleFix":"# before\nclone = keras.models.clone_model(seq_model, call_function=my_call_fn)\n\n# after\nclone = keras.models.clone_model(\n    seq_model, clone_function=lambda l: l.__class__.from_config(l.get_config()))","handlingStrategy":"type-guard","validationCode":"kwargs = {'call_function': fn} if is_functional(model) else {}\nclone = keras.models.clone_model(model, **kwargs)","typeGuard":"def is_functional(model) -> bool:\n    return getattr(model, '_functional_construction', False) or getattr(model, '_is_graph_network', False)","tryCatchPattern":null,"preventionTips":["Branch cloning logic on model type (Sequential vs Functional vs subclassed)."],"tags":["keras","models","clone-model","sequential","functional"],"backgroundTag":"unsupported-argument-for-type","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}