nn-calculator

0.0.1 • Public • Published

nnstats

NPM version Build Status Dependency Status Coverage percentage

Javascript package for analyzing Neural Networks.

Installation

  npm install --save nnstats

Usage

Basic usage

The following show basic usage for analyzing CNN in Tensorflow (padding takes either SAME or VALID).

'use strict';
 
 
let nnStats = require('./');
let analyzer = nnStats.analyzer;
let utils = nnStats.utils;
 
let model = [{
    'type': 'conv',
    'filter': [5, 5, 32],
    'stride': [1, 1],
    'padding': 'SAME',
    'datasize': 4
},{
    'type': 'pool',
    'filter': [2, 2],
    'stride': [2, 2],
    'padding': 'SAME',
    'datasize': 4
},{
    'type': 'conv',
    'filter': [5, 5, 64],
    'stride': [2, 2],
    'padding': 'SAME',
    'datasize': 4
},{
    'type': 'pool',
    'filter': [2, 2],
    'stride': [2, 2],
    'padding': 'SAME',
    'datasize': 4
},{
    'type': 'fc',
    'hidden': 2048
},{
    'type': 'fc',
    'hidden': 1000
}]
 
 
let input = [28, 28, 1]
let options = {
    tensorflow: true
}
 
let stats = analyzer.analyzeNetwork(model, input, options);
 
utils.report(stats);

Model layout

Currently, here are 3 supported layers type: convolution layer (conv), pooling layer (pool), and fully-connected layer ('fc'). In all cases, type field is required in layer object to identity layer type.

Fields in conv layer:

  1. filter: 3D array kernal size (height, width, outChannel).
  2. stride: 2D array stride size (height, width).
  3. padding: 2D array padding size (height, width).
  4. datasize (optional): number of byte of one value (for float32, this should be 4 because 32 / 8 = 4). This value is used to calculate how much memory needed for the network.

Fields in pool layer:

  1. filter: 2D array kernal size (height, width).
  2. stride: 2D array stride size (height, width).
  3. padding: 2D array padding size (height, width).
  4. datasize (optional): number of byte of one value (for float32, this should be 4 because 32 / 8 = 4). This value is used to calculate how much memory needed for the network.

Fields in fc layer:

  1. hidden: number of neurons in hiddent layers.

Created with

Yeoman and Generator-simple-package

License

MIT © nghiattran

/nn-calculator/

    Package Sidebar

    Install

    npm i nn-calculator

    Weekly Downloads

    1

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • nghiattran