{"record":{"id":"5a4edf0da921ba97","repo":"CorentinJ/Real-Time-Voice-Cloning","slug":"unknown-model-mode-value","errorCode":null,"errorMessage":"Unknown model mode value - ","messagePattern":"Unknown model mode value - ","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vocoder/models/fatchord_version.py","lineNumber":230,"sourceCode":"\n                if self.mode == 'MOL':\n                    sample = sample_from_discretized_mix_logistic(logits.unsqueeze(0).transpose(1, 2))\n                    output.append(sample.view(-1))\n                    if torch.cuda.is_available():\n                        # x = torch.FloatTensor([[sample]]).cuda()\n                        x = sample.transpose(0, 1).cuda()\n                    else:\n                        x = sample.transpose(0, 1)\n\n                elif self.mode == 'RAW' :\n                    posterior = F.softmax(logits, dim=1)\n                    distrib = torch.distributions.Categorical(posterior)\n\n                    sample = 2 * distrib.sample().float() / (self.n_classes - 1.) - 1.\n                    output.append(sample)\n                    x = sample.unsqueeze(-1)\n                else:\n                    raise RuntimeError(\"Unknown model mode value - \", self.mode)\n\n                if i % 100 == 0:\n                    gen_rate = (i + 1) / (time.time() - start) * b_size / 1000\n                    progress_callback(i, seq_len, b_size, gen_rate)\n\n        output = torch.stack(output).transpose(0, 1)\n        output = output.cpu().numpy()\n        output = output.astype(np.float64)\n        \n        if batched:\n            output = self.xfade_and_unfold(output, target, overlap)\n        else:\n            output = output[0]\n\n        if mu_law:\n            output = decode_mu_law(output, self.n_classes, False)\n        if hp.apply_preemphasis:\n            output = de_emphasis(output)","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/CorentinJ/Real-Time-Voice-Cloning/blob/890f3a03187195b9829db2079b75c2ba2ab0405c/vocoder/models/fatchord_version.py#L212-L248","documentation":"Raised in WaveRNN.generate() (vocoder/models/fatchord_version.py) during the sample loop when self.mode is neither 'MOL' (mixture of logistics) nor 'RAW' (categorical softmax). The mode is baked into the model object — set from hparams / the class-string of the loaded weights — and determines how network logits are turned into audio samples. Note the bug-shaped message: RuntimeError(\"Unknown model mode value - \", self.mode) passes the mode as a separate arg instead of formatting it, so the printed message never shows the offending value.","triggerScenarios":"Loading a vocoder checkpoint whose training mode disagrees with the mode the runtime assigns (e.g. MOL-trained weights generated with mode 'RAW'), or constructing WaveRNN manually and passing an invalid mode string. The mismatch usually surfaces only at generate() time, not at load time.","commonSituations":"Using a pretrained vocoder with hparams (vocoder_mode / class-based hp.vocoder_mode) that differ from the checkpoint's training config; editing hparams between train and inference; third-party WaveRNN weights with a nonstandard mode string; typos like 'Mol' or 'raw'.","solutions":["Align the mode with the checkpoint: if using the standard pretrained vocoder, keep the repository's default hparams (which set the correct mode) instead of overriding them.","Inspect the mode before generating: print(_model.mode) — it must be exactly 'MOL' or 'RAW' (uppercase).","If loading custom weights, set the mode argument at WaveRNN construction / load_model to match how those weights were trained.","As a quick sanity check, load with the unmodified repo hparams first; only customize after generation works."],"exampleFix":"# before: checkpoint trained in MOL, hparams forced to RAW\nhp.vocoder_mode = 'RAW'  # ... later: RuntimeError: Unknown model mode value -\n\n# after\nhp.vocoder_mode = 'MOL'  # match the checkpoint's training mode; print(model.mode) to confirm","handlingStrategy":"validation","validationCode":"def valid_wavernn_mode(mode) -> bool:\n    return mode in (\"MOL\", \"RAW\")\n\n# before generate(): assert valid_wavernn_mode(model.mode), model.mode","typeGuard":"def is_wavernn_mode(m) -> bool:\n    return m in (\"MOL\", \"RAW\")","tryCatchPattern":"try:\n    wav = model.generate(mel, batched, target, overlap, mu_law)\nexcept RuntimeError as e:\n    if \"Unknown model mode\" in str(e):\n        raise RuntimeError(f\"model.mode={model.mode!r} invalid; load with mode MOL/RAW matching the checkpoint\") from e\n    raise","preventionTips":["Keep the checkpoint and its hparams together; never load weights with different mode settings.","After load_model, assert _model.mode in ('MOL', 'RAW') before any generation call.","When adopting third-party WaveRNN weights, ask/inspect which mode they were trained in (weights shape of the output head hints at it)."],"tags":["vocoder","hparams","model-loading","inference"],"backgroundTag":null,"analyzedSha":"890f3a03187195b9829db2079b75c2ba2ab0405c","analyzedAt":"2026-08-15T02:15:13.202Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}