Coder Social home page Coder Social logo

oneppcdev / deeplearnjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tensorflow/tfjs-core

0.0 1.0 0.0 8.59 MB

A hardware-accelerated deep learning library for the web.

Home Page: https://deeplearnjs.org

License: Apache License 2.0

JavaScript 0.54% Shell 0.61% Python 1.12% TypeScript 97.73%

deeplearnjs's Introduction

Getting started

deeplearn.js is an open source hardware-accelerated JavaScript library for machine intelligence. deeplearn.js brings performant machine learning building blocks to the web, allowing you to train neural networks in a browser or run pre-trained models in inference mode.

We provide two APIs, an immediate execution model (think NumPy) and a deferred execution model mirroring the TensorFlow API. deeplearn.js was originally developed by the Google Brain PAIR team to build powerful interactive machine learning tools for the browser, but it can be used for everything from education, to model understanding, to art projects.

Usage

Typescript / ES6 JavaScript

npm install deeplearn

A simple example that sums an array with a scalar (broadcasted):

import {Array1D, NDArrayMathGPU, Scalar} from 'deeplearn';

const math = new NDArrayMathGPU();
const a = Array1D.new([1, 2, 3]);
const b = Scalar.new(2);
math.scope(() => {
  const result = math.add(a, b);
  console.log(result.getValues());  // Float32Array([3, 4, 5])
});

ES3/ES5 JavaScript

You can also use deeplearn.js with plain JavaScript. Load the latest version of the library directly from the Google CDN:

<script src="https://storage.googleapis.com/learnjs-data/deeplearn-latest.js"></script>

To use a specific version, replace latest with a version number (e.g. deeplearn-0.1.0.js), which you can find in the releases page on GitHub. After importing the library, the API will be available as deeplearn in the global namespace:

var math = new deeplearn.NDArrayMathGPU();
var a = deeplearn.Array1D.new([1, 2, 3]);
var b = deeplearn.Scalar.new(2);
math.scope(function() {
  var result = math.add(a, b);
  console.log(result.getValues());  // Float32Array([3, 4, 5])
});

Development

To build deeplearn.js from source, we need to clone the project and prepare the dev environment:

$ git clone https://github.com/PAIR-code/deeplearnjs.git
$ cd deeplearnjs
$ npm run prep # Installs node modules and bower components.

We recommend using Visual Studio Code for development. Make sure to install the clang-format command line tool as well as the Clang-Format VSCode extension for auto-formatting.

To interactively develop any of the demos (e.g. demos/nn-art/):

$ ./scripts/watch-demo demos/nn-art/nn-art.ts
>> Starting up http-server, serving ./
>> Available on:
>>   http://127.0.0.1:8080
>> Hit CTRL-C to stop the server
>> 1357589 bytes written to dist/demos/nn-art/bundle.js (0.85 seconds) at 10:34:45 AM

Then visit http://localhost:8080/demos/nn-art/nn-art-demo.html. The watch-demo script monitors for changes of typescript code and does incremental compilation (~200-400ms), so users can have a fast edit-refresh cycle when developing apps.

Before submitting a pull request, make sure the code passes all the tests and is clean of lint errors:

$ npm run test
$ npm run lint

To build a standalone ES5 library that can be imported in the browser with a <script> tag:

$ ./scripts/build-standalone.sh VERSION # Builds standalone library.
>> Stored standalone library at dist/deeplearn-VERSION(.min).js

To do a dry run and test building an npm package:

$ ./scripts/build-npm.sh
>> Stored npm package at dist/deeplearn-VERSION.tgz

To install it locally, run npm install ./dist/deeplearn-VERSION.tgz.

On Windows, use bash (available through git) to use the scripts above.

Supported environments

deeplearn.js targets WebGL 1.0 devices with the OES_texture_float extension and also targets WebGL 2.0 devices. For platforms without WebGL, we provide CPU fallbacks.

However, currently our demos do not support Mobile, Firefox, and Safari. Please view them on desktop Chrome for now. We are working to support more devices. Check back soon!

Resources

Thanks

ย  for providing testing support.

This is not an official Google product.

deeplearnjs's People

Contributors

arthurjdam avatar bernard-lin avatar bhageena avatar borismus avatar caisq avatar cghawthorne avatar chihuahua avatar digitalheir avatar dsmilkov avatar ivikash avatar jsphweid avatar kaihuchen avatar lewuathe avatar mnottheone avatar nsthorat avatar raymondr avatar shancarter avatar wenkesj avatar

Watchers

 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.