{"record":{"id":"8b5d97609541fa8e","repo":"keras-team/keras","slug":"could-not-interpret-activation-function-identifier","errorCode":null,"errorMessage":"Could not interpret activation function identifier: {identifier}","messagePattern":"Could not interpret activation function identifier: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/activations/__init__.py","lineNumber":128,"sourceCode":"        module_objects=ALL_OBJECTS_DICT,\n        custom_objects=custom_objects,\n    )\n\n\n@keras_export(\"keras.activations.get\")\ndef get(identifier):\n    \"\"\"Retrieve a Keras activation function via an identifier.\"\"\"\n    if identifier is None:\n        return linear\n    if isinstance(identifier, dict):\n        obj = serialization_lib.deserialize_keras_object(identifier)\n    elif isinstance(identifier, str):\n        obj = ALL_OBJECTS_DICT.get(identifier, None)\n    else:\n        obj = identifier\n    if callable(obj):\n        return obj\n    raise ValueError(\n        f\"Could not interpret activation function identifier: {identifier}\"\n    )\n","sourceCodeStart":110,"sourceCodeEnd":131,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/activations/__init__.py#L110-L131","documentation":"Raised by extract_patches when size is a tuple/list but its length is neither 2 nor 3. Keras supports 2D patch grids (height, width) and 3D grids (depth, height, width) only; any other tuple length is ambiguous so it fails fast with a ValueError.","triggerScenarios":"extract_patches(images, size=(3, 3, 3, 3)) (4 elements, e.g. meant for batch or channels); size=(3,) single-element tuple from a config that collapsed; mixing a 3D tuple with 2D images instead of using 2 elements.","commonSituations":"Config files where patch size lists grow stale after switching between 2D and 3D models; copying a kernel_size=(3,3,3,3) 4D conv shape into patch extraction; tuples built programmatically with the wrong dimension count.","solutions":["Use length 2 for image inputs (patch_h, patch_w) and length 3 for volume inputs (patch_d, patch_h, patch_w)","Check len(size) before the call and assert it matches your data rank (2 for 2D, 3 for 3D)","If the tuple came from a conv kernel spec, strip the channel/batch dims before passing it"],"exampleFix":"before: extract_patches(vol, size=[2, 2, 2, 2]) -> ValueError; after: extract_patches(vol, size=[2, 2, 2])","handlingStrategy":"validation","validationCode":"assert isinstance(size, (int, tuple, list))\nif not isinstance(size, int):\n    assert len(size) in (2, 3), f\"size must have length 2 or 3, got {len(size)}\"","typeGuard":"def size_matches_rank(size, ndim) -> bool:\n    return isinstance(size, int) or (isinstance(size, (tuple, list)) and len(size) == ndim - 2)","tryCatchPattern":null,"preventionTips":["Derive size length from data rank: images -> 2, volumes -> 3","Lint config patch-size lists to exactly 2 or 3 entries","Add a unit test asserting len(size) for each model config"],"tags":["keras","argument-validation","valueerror","image-ops"],"backgroundTag":"invalid-argument-shape","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}