{"record":{"id":"9a15d056924c53e5","repo":"tracel-ai/burn","slug":"top-k-must-be-non-zero","errorCode":null,"errorMessage":"top_k must be non-zero","messagePattern":"top_k must be non-zero","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/metric/fbetascore.rs","lineNumber":74,"sourceCode":"                ..Default::default()\n            },\n            beta,\n        )\n    }\n\n    /// F-beta score metric for multiclass classification.\n    ///\n    /// # Arguments\n    ///\n    /// * `beta` - Positive real factor to weight recall's importance.\n    /// * `top_k` - The number of highest predictions considered to find the correct label (typically `1`).\n    /// * `class_reduction` - [Class reduction](ClassReduction) type.\n    #[allow(dead_code)]\n    pub fn multiclass(beta: f64, top_k: usize, class_reduction: ClassReduction) -> Self {\n        Self::new(\n            ClassificationMetricConfig {\n                decision_rule: DecisionRule::TopK(\n                    NonZeroUsize::new(top_k).expect(\"top_k must be non-zero\"),\n                ),\n                class_reduction,\n            },\n            beta,\n        )\n    }\n\n    /// F-beta score metric for multi-label classification.\n    ///\n    /// # Arguments\n    ///\n    /// * `beta` - Positive real factor to weight recall's importance.\n    /// * `threshold` - The threshold to transform a probability into a binary prediction.\n    /// * `class_reduction` - [Class reduction](ClassReduction) type.\n    #[allow(dead_code)]\n    pub fn multilabel(beta: f64, threshold: f64, class_reduction: ClassReduction) -> Self {\n        Self::new(\n            ClassificationMetricConfig {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/metric/fbetascore.rs#L56-L92","documentation":"Config validation in `FBetaScore`/`ClassificationMetricConfig` construction: the `top_k` argument passed to the multiclass (or related) constructor is zero, which would make top-k classification undefined; config building panics.","triggerScenarios":"Thrown at crates/burn-train/src/metric/fbetascore.rs:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass top_k >= 1 (typically 1)","Validate user-provided top_k before constructing the metric","Use the binary/threshold variant if top-k is not needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}