{"record":{"id":"2ab7af097049d574","repo":"keras-team/keras","slug":"invalid-dtype-dtype","errorCode":null,"errorMessage":"Invalid dtype: {dtype}","messagePattern":"Invalid dtype: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/variables.py","lineNumber":587,"sourceCode":"\n@keras_export(\n    [\"keras.utils.standardize_dtype\", \"keras.backend.standardize_dtype\"]\n)\ndef standardize_dtype(dtype):\n    if dtype is None:\n        return config.floatx()\n    dtype = dtypes.PYTHON_DTYPES_MAP.get(dtype, dtype)\n    if hasattr(dtype, \"name\"):\n        dtype = dtype.name\n    elif hasattr(dtype, \"__name__\"):\n        dtype = dtype.__name__\n    elif hasattr(dtype, \"__str__\") and (\n        \"torch\" in str(dtype) or \"jax.numpy\" in str(dtype)\n    ):\n        dtype = str(dtype).split(\".\")[-1]\n\n    if dtype not in dtypes.ALLOWED_DTYPES:\n        raise ValueError(f\"Invalid dtype: {dtype}\")\n    return dtype\n\n\ndef standardize_shape(shape):\n    if not isinstance(shape, tuple):\n        if shape is None:\n            raise ValueError(\"Undefined shapes are not supported.\")\n        if not hasattr(shape, \"__iter__\"):\n            raise ValueError(f\"Cannot convert '{shape}' to a shape.\")\n        if config.backend() == \"tensorflow\":\n            if isinstance(shape, tf.TensorShape):\n                # `tf.TensorShape` may contain `Dimension` objects.\n                # We need to convert the items in it to either int or `None`\n                shape = shape.as_list()\n\n    if config.backend() == \"jax\":\n        # Replace `_DimExpr` (dimension expression) with None\n        from jax import export as jax_export","sourceCodeStart":569,"sourceCodeEnd":605,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/variables.py#L569-L605","documentation":"Error \"Invalid dtype: {dtype}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/common/variables.py:587 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"}