mindspore.dataset.Dataset.num_classes

Dataset.num_classes()[source]

Get the number of classes in a dataset.

Returns

int, number of classes.

Examples

>>> import mindspore.dataset as ds
>>> # Read image files
>>> image_folder_dataset_dir = "/path/to/image_folder_dataset_directory"
>>> dataset = ds.ImageFolderDataset(dataset_dir=image_folder_dataset_dir)
>>> # Check how many classes exist in image folder
>>> num_classes = dataset.num_classes()