geekcomputers/Python · error · ValueError
Unknown dataset: {name}
Error message
Unknown dataset: {name} What it means
Raised by get_dataset in neuralforge.data.datasets when the requested dataset name does not match any of the supported aliases in this factory branch (cifar10, mnist, fashion_mnist/fashionmnist, stl10, etc.). The name is matched exactly against the elif chain, so any unrecognized or misspelled string falls through to ValueError.
Source
Thrown at ML/src/python/neuralforge/data/datasets.py:132
def __getitem__(self, idx):
return self.dataset[idx]
def get_dataset(name='cifar10', root='./data', train=True, download=True):
name = name.lower()
if name == 'cifar10':
return CIFAR10Dataset(root=root, train=train, download=download)
elif name == 'cifar100':
return CIFAR100Dataset(root=root, train=train, download=download)
elif name == 'mnist':
return MNISTDataset(root=root, train=train, download=download)
elif name == 'fashion_mnist' or name == 'fashionmnist':
return FashionMNISTDataset(root=root, train=train, download=download)
elif name == 'stl10':
split = 'train' if train else 'test'
return STL10Dataset(root=root, split=split, download=download)
else:
raise ValueError(f"Unknown dataset: {name}")
class ImageNetDataset:
def __init__(self, root='./data/imagenet', split='train', transform=None, download=False):
if transform is None:
if split == 'train':
transform = transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ColorJitter(0.4, 0.4, 0.4),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
else:
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])View on GitHub (pinned to 40f4cd2652)
Solutions
- Print/lowercase the name and compare against the supported list in this factory
- Use exact aliases: 'fashion_mnist' or 'fashionmnist', 'stl10'
- If you want caltech256/oxford_pets, call the other get_dataset/factory that handles them
- Add your dataset name to the elif chain or wrap it with name.lower() before calling
Example fix
# before
ds = get_dataset('FASHION-MNIST') # ValueError
# after
ds = get_dataset('fashion_mnist'.lower()) # normalize; use supported alias Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {'cifar10','mnist','fashion_mnist','fashionmnist','stl10'}
name = name.lower()
assert name in SUPPORTED, f'{name} not in {SUPPORTED}'
ds = get_dataset(name, ...) Type guard
def is_known_dataset(name: str) -> bool:
return name.lower() in {'cifar10','mnist','fashion_mnist','fashionmnist','stl10'} Try / catch
try:
ds = get_dataset(name, root=root, train=train)
except ValueError as e:
if 'Unknown dataset' in str(e):
raise SystemExit(f'Fix dataset name: {name}. Supported: ...') from e
raise Prevention
- Normalize names to lowercase with underscores early
- Keep a single source-of-truth constant of supported names and validate config against it
- Fail fast on config load, not deep in training
When it happens
Trigger: Calling get_dataset('fashion-mnist') (hyphen instead of underscore), 'CIFAR10' if the name is not lowercased before dispatch, or a dataset like 'imagenet' handled by a different factory/branch.
Common situations: Typos or wrong separators in config files; dataset name sourced from a CLI arg without normalization; expecting a dataset that exists in the library but is served by another factory function (e.g. the get_dataset variant at line 302 covering caltech256/oxford_pets).
Related errors
AI-assisted analysis of geekcomputers/Python@40f4cd2652 (2026-08-27).
Data as JSON: /api/errors/5e2ab265a5d56d52.
Report an issue: GitHub.