{"record":{"id":"4a1dd9d7d4633aff","repo":"keras-team/keras","slug":"output-mode-is-invalid-it-must-be-one-of-jo","errorCode":null,"errorMessage":"Output mode is invalid, it must be one of {', '.join(all_modes)}. Received: mode={mode}","messagePattern":"Output mode is invalid, it must be one of (.+?)\\. Received: mode=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/stft_spectrogram.py","lineNumber":172,"sourceCode":"                f\"frame_length={frame_length}\"\n            )\n\n        if fft_length is not None and fft_length < frame_length:\n            raise ValueError(\n                \"`fft_length` should be not less than `frame_length`. \"\n                f\"Received fft_length={fft_length}, frame_length={frame_length}\"\n            )\n\n        if fft_length is not None and (fft_length & -fft_length) != fft_length:\n            warnings.warn(\n                \"`fft_length` is recommended to be a power of two. \"\n                f\"Received fft_length={fft_length}\"\n            )\n\n        all_modes = [\"log\", \"magnitude\", \"psd\", \"real\", \"imag\", \"angle\", \"stft\"]\n\n        if mode not in all_modes:\n            raise ValueError(\n                \"Output mode is invalid, it must be one of \"\n                f\"{', '.join(all_modes)}. Received: mode={mode}\"\n            )\n\n        if scaling is not None and scaling not in [\"density\", \"spectrum\"]:\n            raise ValueError(\n                \"Scaling is invalid, it must be `None`, 'density' \"\n                f\"or 'spectrum'. Received scaling={scaling}\"\n            )\n\n        if padding not in [\"valid\", \"same\"]:\n            raise ValueError(\n                \"Padding is invalid, it should be 'valid', 'same'. \"\n                f\"Received: padding={padding}\"\n            )\n\n        if isinstance(window, str):\n            # throws an exception for invalid window function","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/stft_spectrogram.py#L154-L190","documentation":"Constructor guard in STFTSpectrogram.__init__: the mode argument is not one of the layer's enumerated output modes ('log', 'magnitude', 'psd', 'real', 'imag', 'angle', 'stft'). The offending value is the mode string, echoed in the message.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/stft_spectrogram.py:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of: 'log', 'magnitude', 'psd', 'real', 'imag', 'angle', 'stft'","Check for typos/case in the mode string; values are matched exactly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}