Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

tfrecord

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tfrecord

Reader and writer for the TensorFlow Record file format

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

tensorflow

FAQs

Package last updated on 09 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts