Giter Club home page Giter Club logo

tfjs-shapes's Introduction

Tensorflow.js Shape Backend

This is a backend for Tensorflow.js that just computes the shapes and dtypes of tensors.

This could be used to build an editor extension that lets you get the shape of a tensor on hover, or to build asynchronous computation backends (Tensorflow.js needs to know the shape of tensors synchronously, but is fine with the actual computation being asynchronous).

Usage

import * as tf from '@tensorflow/tfjs'
import 'tfjs-shapes'

tf.setBackend('tfjs-shapes')

const ones = tf.ones([10, 10, 10, 10])
const pooled = tf.maxPool(ones, 2, 2, 'same')

console.log(pooled)
/** should print something like
 * Tensor {
  isDisposedInternal: false,
  size: 2500,
  shape: [ 10, 5, 5, 10 ],
  dtype: 'float32',
  strides: [ 250, 50, 10 ],
  dataId: {},
  id: 3,
  rankType: '4' }
  */

Or

import { shapesOnly } from 'tfjs-shapes'

const { shape, dtype } = shapesOnly(() => {
    const ones = tf.ones([10, 10, 10, 10])
    const pooled = tf.maxPool(ones, 2, 2, 'same')
    return pooled
})
// shape === [10, 5, 5, 10]
// dtype === 'float32'

TODO

  • Implement
    • BatchToSpaceND & SpaceToBatchND
  • More tests
  • Better name for shapesOnly

tfjs-shapes's People

Contributors

aman-tiwari avatar

Stargazers

maxmarcos avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.