deezer/spleeter · error · ValueError
Unkwnown loss type: {loss_type}
Error message
Unkwnown loss type: {loss_type} What it means
_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.
Source
Thrown at spleeter/model/__init__.py:213
Tensorflow (loss, metrics) tuple.
"""
output_dict = self.model_outputs
loss_type = self._params.get("loss_type", self.L1_MASK)
if loss_type == self.L1_MASK:
losses = {
name: tf.reduce_mean(tf.abs(output - labels[name]))
for name, output in output_dict.items()
}
elif loss_type == self.WEIGHTED_L1_MASK:
losses = {
name: tf.reduce_mean(
tf.reduce_mean(labels[name], axis=[1, 2, 3], keep_dims=True)
* tf.abs(output - labels[name])
)
for name, output in output_dict.items()
}
else:
raise ValueError(f"Unkwnown loss type: {loss_type}")
loss = tf.reduce_sum(list(losses.values()))
# Add metrics for monitoring each instrument.
metrics = {k: tf.compat.v1.metrics.mean(v) for k, v in losses.items()}
metrics["absolute_difference"] = tf.compat.v1.metrics.mean(loss)
return loss, metrics
def _build_optimizer(self) -> tf.Tensor:
"""
Builds an optimizer instance from internal parameter values.
Default to AdamOptimizer if not specified.
Returns:
tf.Tensor:
Optimizer instance from internal configuration.
"""
name = self._params.get("optimizer")
if name == self.ADADELTA:
return tf.compat.v1.train.AdadeltaOptimizer()View on GitHub (pinned to c8854001ac)
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
Example fix
// before (config)
{"params": {"loss_type": "MSE"}}
// after
{"params": {"loss_type": "L1"}} Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_LOSSES = {'L1', 'L1_wmag'} # matches _build_loss branches
loss_type = params.get('loss_type')
if loss_type is not None and loss_type not in SUPPORTED_LOSSES:
raise ValueError(f"Unsupported loss_type {loss_type!r}; supported: {SUPPORTED_LOSSES}") Type guard
def is_supported_loss(cfg: dict) -> bool:
return cfg.get('model', {}).get('params', {}).get('loss_type', 'L1') in {'L1', 'L1_wmag'} Try / catch
try:
builder.build_train_model(labels)
except ValueError as e:
if 'Unkwnown loss type' in str(e):
raise ConfigError(f"Invalid loss_type in model params: {e}") from e
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: Copying a config from another separation library; assuming case-insensitive matching; upgrading/downgrading spleeter so a previously supported loss type no longer exists.
Related errors
- No model function {model_type} found
- Invalid mask_extension parameter {extension}
- n_chunks_per_song must be positif
- Unknown mode {mode}
- {adapter_class_name} is not a valid AudioAdapter class
AI-assisted analysis of deezer/spleeter@c8854001ac (2026-08-28).
Data as JSON: /api/errors/504edf8929610d70.
Report an issue: GitHub.