The CIFAR datasets are benchmark classification datasets composed of 60,000 RGB thumbnail images of size 32x32 pixels. The CIFAR10 variant contains 10 classes while CIFAR100 provides 100 classes. Images are split into 50,000 training samples and 10,000 test samples.

Downloads and prepares the CIFAR100 dataset.

cifar10_dataset(
  root = tempdir(),
  train = TRUE,
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

cifar100_dataset(
  root = tempdir(),
  train = TRUE,
  transform = NULL,
  target_transform = NULL,
  download = FALSE
)

Arguments

root

(string): Root directory of dataset where directory cifar-10-batches-bin exists or will be saved to if download is set to TRUE.

train

Logical. If TRUE, use the training set; otherwise, use the test set. Not applicable to all datasets.

transform

Optional. A function that takes an image and returns a transformed version (e.g., normalization, cropping).

target_transform

Optional. A function that transforms the label.

download

Logical. If TRUE, downloads the dataset to root/. If the dataset is already present, download is skipped.

Value

A torch::dataset object. Each item is a list with:

  • x: a 32x32x3 integer array

  • y: the class label

Details

Downloads and prepares the CIFAR archives.

Examples

if (FALSE) { # \dontrun{
ds <- cifar10_dataset(root = tempdir(), download = TRUE)
item <- ds[1]
item$x
item$y
} # }