{"record":{"id":"d7b17852bb4f1abc","repo":"keras-team/keras","slug":"invalid-input-type-expected-float32-or-float64-d7b178","errorCode":null,"errorMessage":"Invalid input type. Expected `float32` or `float64`. Received: input type={x.dtype}","messagePattern":"Invalid input type\\. Expected `float32` or `float64`\\. Received: input type=(.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/math.py","lineNumber":201,"sourceCode":"    return (\n        np.real(complex_output).astype(x.dtype),\n        np.imag(complex_output).astype(x.dtype),\n    )\n\n\ndef irfft(x, fft_length=None):\n    complex_input = _get_complex_tensor_from_tuple(x)\n    # numpy always outputs float64, so we need to recast the dtype\n    return np.fft.irfft(\n        complex_input, n=fft_length, axis=-1, norm=\"backward\"\n    ).astype(x[0].dtype)\n\n\ndef stft(\n    x, sequence_length, sequence_stride, fft_length, window=\"hann\", center=True\n):\n    if standardize_dtype(x.dtype) not in {\"float32\", \"float64\"}:\n        raise TypeError(\n            \"Invalid input type. Expected `float32` or `float64`. \"\n            f\"Received: input type={x.dtype}\"\n        )\n    if fft_length < sequence_length:\n        raise ValueError(\n            \"`fft_length` must equal or larger than `sequence_length`. \"\n            f\"Received: sequence_length={sequence_length}, \"\n            f\"fft_length={fft_length}\"\n        )\n    if isinstance(window, str):\n        if window not in {\"hann\", \"hamming\"}:\n            raise ValueError(\n                \"If a string is passed to `window`, it must be one of \"\n                f'`\"hann\"`, `\"hamming\"`. Received: window={window}'\n            )\n    x = convert_to_tensor(x)\n    ori_dtype = x.dtype\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/math.py#L183-L219","documentation":"Error \"Invalid input type. Expected `float32` or `float64`. Received: input type={x.dtype}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/numpy/math.py:201 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"}