Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mnist-dataset with all npm packages installed. Try it out:

var mnistDataset = require("mnist-dataset")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mnist-dataset v0.0.1

✍️ Yann LeCun's MNIST handwritten digit dataset, made available to Node.js.

mnist-dataset

✍️ Yann LeCun's MNIST handwritten digit dataset, made available to Node.js. This library contains all of the utilities you need to download and parse the raw unfiltered dataset, which is expressed as JSON arrays. It uses fs to cache to your system's tmpdir() so that you don't have to keep downloading the dataset between successive executions of your software.

code style: prettier



🚀 Getting Started

Using npm:

npm install --save mnist-dataset

Using yarn:

yarn add mnist-dataset

✍️ Usage

import { cache, trainingImagesUrl, trainingLabelsUrl } from 'mnist-dataset';

(
  async () => {
    const trainingImages = await cache(trainingImagesUrl); // [[Number]] (i.e. [[0, 0, 0, ...], [0, 0, 0, ...], ...])
    const trainingLabels = await cache(trainingLabelsUrl); // [[Number]] (i.e. [[7], [2], ...])

    const toString = e =>
      [...Array(28)]
        .map((_, i) =>
          [...Array(28)].map((_, j) => (e[i * 28 + j] > 128 ? "#" : " ")).join("")
        )
        .join("\n");

    const [number7] = trainingImages;
    console.log(toString(number7));
  }
)();

✌️ License

MIT

Buy @cawfree a coffee

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free