{"record":{"id":"504edf8929610d70","repo":"deezer/spleeter","slug":"unkwnown-loss-type-loss-type","errorCode":null,"errorMessage":"Unkwnown loss type: {loss_type}","messagePattern":"Unkwnown loss type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"spleeter/model/__init__.py","lineNumber":213,"sourceCode":"                Tensorflow (loss, metrics) tuple.\n        \"\"\"\n        output_dict = self.model_outputs\n        loss_type = self._params.get(\"loss_type\", self.L1_MASK)\n        if loss_type == self.L1_MASK:\n            losses = {\n                name: tf.reduce_mean(tf.abs(output - labels[name]))\n                for name, output in output_dict.items()\n            }\n        elif loss_type == self.WEIGHTED_L1_MASK:\n            losses = {\n                name: tf.reduce_mean(\n                    tf.reduce_mean(labels[name], axis=[1, 2, 3], keep_dims=True)\n                    * tf.abs(output - labels[name])\n                )\n                for name, output in output_dict.items()\n            }\n        else:\n            raise ValueError(f\"Unkwnown loss type: {loss_type}\")\n        loss = tf.reduce_sum(list(losses.values()))\n        # Add metrics for monitoring each instrument.\n        metrics = {k: tf.compat.v1.metrics.mean(v) for k, v in losses.items()}\n        metrics[\"absolute_difference\"] = tf.compat.v1.metrics.mean(loss)\n        return loss, metrics\n\n    def _build_optimizer(self) -> tf.Tensor:\n        \"\"\"\n        Builds an optimizer instance from internal parameter values.\n        Default to AdamOptimizer if not specified.\n\n        Returns:\n            tf.Tensor:\n                Optimizer instance from internal configuration.\n        \"\"\"\n        name = self._params.get(\"optimizer\")\n        if name == self.ADADELTA:\n            return tf.compat.v1.train.AdadeltaOptimizer()","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/deezer/spleeter/blob/c8854001ac8acad34a9bc2bd15f28475541828b1/spleeter/model/__init__.py#L195-L231","documentation":"_build_loss switches on loss_type (from model params, e.g. 'L1' or 'L1_wmag') and raises ValueError for any unrecognized value after the if/elif chain. The typo 'Unkwnown' identifies this exact branch. Only the loss types implemented in the branch chain are supported.","triggerScenarios":"Setting model.params.loss_type (or the equivalent config field) to something other than the supported values, e.g. 'l2', 'mse', 'L1 ', 'l1' (case mismatch), or a custom loss not implemented in this spleeter version.","commonSituations":"Copying a config from another separation library; assuming case-insensitive matching; upgrading/downgrading spleeter so a previously supported loss type no longer exists.","solutions":["Set loss_type to a supported value, e.g. 'L1' or 'L1_wmag', matching the exact spelling/case in the source","Print/inspect the code in _build_loss to see the accepted branch values","Remove the loss_type override so the default path is used","Implement a custom branch in _build_loss if you truly need another loss"],"exampleFix":"// before (config)\n{\"params\": {\"loss_type\": \"MSE\"}}\n// after\n{\"params\": {\"loss_type\": \"L1\"}}","handlingStrategy":"validation","validationCode":"SUPPORTED_LOSSES = {'L1', 'L1_wmag'}  # matches _build_loss branches\nloss_type = params.get('loss_type')\nif loss_type is not None and loss_type not in SUPPORTED_LOSSES:\n    raise ValueError(f\"Unsupported loss_type {loss_type!r}; supported: {SUPPORTED_LOSSES}\")","typeGuard":"def is_supported_loss(cfg: dict) -> bool:\n    return cfg.get('model', {}).get('params', {}).get('loss_type', 'L1') in {'L1', 'L1_wmag'}","tryCatchPattern":"try:\n    builder.build_train_model(labels)\nexcept ValueError as e:\n    if 'Unkwnown loss type' in str(e):\n        raise ConfigError(f\"Invalid loss_type in model params: {e}\") from e\n    raise","preventionTips":["Copy loss_type values verbatim (case-sensitive) from spleeter source/examples","Validate the whole model params schema before training starts","Do not assume losses from other frameworks (MSE/L2) exist here","Add an assertion test for your training configs in CI"],"tags":["python","valueerror","configuration","loss-function","spleeter"],"backgroundTag":"unknown-loss-type","analyzedSha":"c8854001ac8acad34a9bc2bd15f28475541828b1","analyzedAt":"2026-08-28T21:38:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}