class MXNet::Gluon::Data::Vision::MNIST(T)

Overview

MNIST handwritten digits dataset.

Each sample is an image with shape [28, 28] (an MXNet::NDArray) paired with its label (an Int32).

Without any transformation (return type is Tuple(MXNet::NDArray, Int32)):

mnist = MXNet::Gluon::Data::Vision::MNIST.new

With a transformer (here, return type is Tuple(MXNet::NDArray, Float32)):

def transform(data, label)
  {data / 255, label.to_f32}
end

mnist = MXNet::Gluon::Data::Vision::MNIST.new(transform: ->transform(MXNet::NDArray, Int32))

See: http://yann.lecun.com/exdb/mnist

Defined in:

mxnet/gluon/data/vision/mnist.cr

Constructors

Instance methods inherited from class MXNet::Gluon::Data::DownloadedDataset(MXNet::NDArray, Int32, T)

root root, size size, unsafe_fetch(idx) unsafe_fetch

Constructor methods inherited from class MXNet::Gluon::Data::DownloadedDataset(MXNet::NDArray, Int32, T)

new(root, transform : Proc(T, U, V)? = nil) new

Instance methods inherited from class MXNet::Gluon::Data::Dataset(T)

size size, transform(lazy = true, &proc : T -> U) forall U transform, unsafe_fetch(idx) unsafe_fetch

Constructor Detail

def self.new(transform : Proc(MXNet::NDArray, Int32, T)?, root = File.join("~/", ".mxnet", "datasets", "mnist"), train = true) #

Creates a new instance.

Transforms each sample with the supplied transformer.

Parameters

  • transform (Proc, required) Transformation to apply to each sample.
  • root (String, optional) Directory in which to cache downloaded files. Automatically created if it does not already exist.
  • train (Bool, optional) Whether to load the training or testing data.

[View source]
def self.new(root = File.join("~/", ".mxnet", "datasets", "mnist"), train = true) #

Creates a new instance.

Parameters

  • root (String, optional) Directory in which to cache downloaded files. Automatically created if it does not already exist.
  • train (Bool, optional) Whether to load the training or testing data.

[View source]