npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tfjs-model-view

v0.2.1

Published

Tensorflow.JS model viewer

Downloads

9

Readme

tfjs-model-view

tfjs-model-view is a library for in browser visualization of neural network intended for use with TensorFlow.js.

Features:

  • Automatically render of the neural net
  • Automatically update weights/biases/values

The library also aims to be flexible and make it easy for you to incorporate.

Demos

Sample rendering output

Samples

Usage

Simple:

new ModelView(model)

Customized:

new ModelView(model, {
    printStats: true,
    radius: 25,
    renderLinks: true,
    xOffset: 100,
    renderNode(ctx, node) {
      const { x, y, value } = node;
      ctx.font = '10px Arial';
      ctx.fillStyle = '#000';
      ctx.textAlign = 'center';
      ctx.textBaseline = 'middle';
      ctx.fillText(Math.round(value * 100) / 100, x, y);
    },
    onBeginRender: renderer => {
      const { renderContext } = renderer;
      renderContext.fillStyle = '#000';
      renderContext.textAlign = 'end';
      renderContext.font = '12px Arial';
      renderContext.fillText('Sepal Length (cm)', 110, 110);
      renderContext.fillText('Sepal Width (cm)', 110, 136);
      renderContext.fillText('Petal Length (cm)', 110, 163);
      renderContext.fillText('Petal Width (cm)', 110, 190);

      renderContext.textAlign = 'start';
      renderContext.fillText('Setosa', renderer.width - 60, 95);
      renderContext.fillText('Versicolor', renderer.width - 60, 150);
      renderContext.fillText('Virginica', renderer.width - 60, 205);
    },
    layer: {
      'dense_Dense1_input': {
        domain: [0, 8],
        color: [165, 130, 180]
      },
      'dense_Dense1/dense_Dense1': {
        color: [125, 125, 125]
      },
      'dense_Dense2/dense_Dense2': {
        color: [125, 125, 125]
      },
      'dense_Dense3/dense_Dense3': {
        nodePadding: 30
      }
    }
  });

Customizing:

new ModelView(model, {
  /** renders the list of layers **/
  printStats: true,

  /** Default domain for color intensity **/
  domain: [0, 1],

  /** Default node radius **/
  radius: 6,

  /** Default node padding **/
  nodePadding: 2,

  /** Default layer padding **/
  layerPadding: 20,

  /** Default group padding **/
  groupPadding: 1,
    
  /** Horizontal padding **/
  xPadding: 10,

  /** Vertical padding **/
  yPadding: 10,
   
  /** Render links between layers **/
  renderLinks: false,
  
  /** Stroke node outer circle **/
  nodeStroke: true,

  /** custom render node function **/
  renderNode: (ctx, node, nodeIdx) => {...},

  /** If present will be executed before node rendering **/
  onBeginRender: renderer => { ... },

  /** If present will be executed after all node rendering is finished **/
  onEndRender: renderer => { ... },

  /** Personalized layer configuration **/
  /** All defaults can be overridden for each layer individually **/
  layer: {
    'layerName': {
      /** Any property mentioned above **/

      /** Reshape layer to antoher [cols, rows, groups] layout **/
      reshape: [4, 4, 8]
    }
  }
});

Installation

You can install this using npm with

npm install tfjs-model-view

or using yarn with

yarn add tfjs-model-view

Building from source

To build the library, you need to have node.js installed. We use yarn instead of npm but you can use either.

First install dependencies with

yarn

or

npm install

You can start the dev environment using

yarn dev

or

npm run dev

Sample Usage

Issues

Found a bug or have a feature request? Please file an issue