tracel-ai/burn · error
Invalid split specified {split}
Error message
Invalid split specified {split} What it means
Input-validation guard in MNIST dataset download: the `split` argument must be exactly "train" or "test"; the match arms download the corresponding file set and the fallback panics with the offending value. It fires when a caller passes any other split name (typo, casing, or an unsupported split) to `MnistDataset::download`.
Source
Thrown at crates/burn-dataset/src/vision/mnist.rs:141
.expect("Could not get cache directory")
.join("burn-dataset");
let split_dir = cache_dir.join("mnist").join(split);
if !split_dir.exists() {
create_dir_all(&split_dir).expect("Failed to create base directory");
}
// Download split files
match split {
"train" => {
MnistDataset::download_file(TRAIN_IMAGES, &split_dir);
MnistDataset::download_file(TRAIN_LABELS, &split_dir);
}
"test" => {
MnistDataset::download_file(TEST_IMAGES, &split_dir);
MnistDataset::download_file(TEST_LABELS, &split_dir);
}
_ => panic!("Invalid split specified {split}"),
};
split_dir
}
/// Download a file from the MNIST dataset URL to the destination directory.
/// File download progress is reported with the help of a [progress bar](indicatif).
fn download_file<P: AsRef<Path>>(name: &str, dest_dir: &P) -> PathBuf {
// Output file name
let file_name = dest_dir.as_ref().join(name);
if !file_name.exists() {
// Download gzip file
let bytes = download_file_as_bytes(&format!("{URL}{name}.gz"), name);
// Create file to write the downloaded content to
let mut output_file = File::create(&file_name).unwrap();
View on GitHub (pinned to d16f7ba2ed)
Solutions
- Pass `"train"` or `"test"` as the split, matching case exactly.
- Normalize/validate the split string before calling the dataset constructor.
- If a new split is required, add a match arm with the corresponding file URLs.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/burn-dataset/src/vision/mnist.rs:141 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/ec2bab6504ebb7f5.
Report an issue: GitHub.