JSPM

tfrecord

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q40727F
  • License MIT

Reader and writer for the TensorFlow Record file format

Package Exports

  • tfrecord

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tfrecord) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TensorFlow record (.tfrecord) File I/O for Node

Build Status NPM Version

Produce data for your TensorFlow pipelines directly in node.

Requirements

This module uses ES2017's async / await, so it requires node.js 7.6 or above.

While this module will presumably be used to interoperate with TensorFlow, it does not require a working TensorFlow installation.

Usage

const tfrecord = require('tfrecord');

async function writeDemo() {
  const writer = await tfrecord.createWriter('data.tfrecord');

  const example = tfrecord.Example.fromObject({
    features: {
      feature: {
        answer: {  // The feature name.
          int64List: {
            value: [42],  // The feature value.
          },
        },
      },
    },
  });

  await writer.writeExample(example);
  await writer.close();
}

async function readDemo() {
  const reader = await tfrecord.createReader('data.tfrecord');
  let example;
  while (example = await reader.readExample()) {
    console.log('%j', example.toJSON());
  }
  // The reader auto-closes after it reaches the end of the file.
}

async function demo() {
  await writeDemo();
  await readDemo();
}

demo();

Development

Run the following command to populate the pre-generated files. These files are distributed in the npm package, but not checked into the git repository.

scripts/generate.sh

The test data can be regenerated by the following command, which requires a working TensorFlow installation on Python 3.

python3 scripts/write_test_data.py

The test data is in the repository so we don't have to spend the time to install TensorFlow on Travis for every run.