how may samples in this: """Datasets.""" import os import torch from torchvision import…
- User
how may samples in this: """Datasets.""" import os
import torch from torchvision import datasets from torchvision import transforms
BASEPATH = os.path.abspath( os.path.join(os.path.dirname(file), '..', '..', 'data'))
class EMNIST(datasets.EMNIST): """EMNIST Letters dataset (labels shifted 0–25)."""
codemean_channels = (0.131,) std_channels = (0.308,) transforms = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,)) ]) def __init__(self, train=True): """EMNIST Letters dataset normalized with labels shifted to 0–25.""" super().__init__( BASEPATH, split="letters", transform=self.transforms, train=train, download=True) def __getitem__(self, index): """Return image and shifted label (0–25 instead of 1–26).""" img, target = super().__getitem__(index) target = target - 1 # shift labels return img, target def inverse_normalization(self, normalized): """Inverse the normalization applied to the original data.""" normalized = 0.5 * (normalized + 1) return normalized - Assistant
You’re using a custom wrapper around torchvision.datasets.EMNIST for the EMNIST Letters split. The number of samples depends on whether train=True or train=False. From the official EMNIST documentation:
EMNIST Letters (train set): 88,800 samples
EMNIST Letters (test set): 14,800 samples
So in your class: pythonCopyEdittrain_dataset = EMNIST(train=True) # 88,800 samples test_dataset = EMNIST(train=False) # 14,800 samples
✅ Total samples (train + test): 103,600. If you want, I can also show you a quick way to verify this in code. Do you want me to?
- User
which is being loaed
- Assistant
In your class, it depends on the argument you pass when creating an instance: pythonCopyEditdataset = EMNIST(train=True) # loads the training set → 88,800 samples dataset = EMNIST(train=False) # loads the test set → 14,800 samples
So if you just call EMNIST() without arguments, the default is train=True, meaning the training set (88,800 samples) is loaded. If you want, I can also explain how to check it dynamically after loading.
- User
by default
- Assistant
By default, your class sets train=True in the init method: pythonCopyEditdef init(self, train=True):
✅ This means that if you just do dataset = EMNIST() without specifying train, it will load the training set, which has 88,800 samples. The test set (14,800 samples) is only loaded if you explicitly call EMNIST(train=False).