BT

Tensorflow with Javascript Brings Deep Learning to the Browser

| by Alexis Perrier Follow 1 Followers on Apr 18, 2018. Estimated reading time: 2 minutes |

GDPR for Software Engineers

This eMag examines what software engineers, data engineers, and operations teams need to know about GDPR, along with the implications it has on data collection, storage and use for any organization dealing with customer data in the EU. Download Now.

At the recent TensorFlow Dev Summit 2018, Google announced the release of Tensorflow.js, a Javascript implementation of Tensorflow, its open-source deep-learning framework. Tensorflow.js allows training models directly in the browser by leveraging the WebGL JavaScript API for faster computations.

Tenforflow.js is an evolution of deeplearn.js, a Javascript library released by Google in August 2017. Deeplearn.js was born out of the success of the Tensorflow Playground, an interactive visualization of neural networks written in TypeScript.

Tensorflow.js has four layers: The WebGL API for GPU-supported numerical operations, the web browser for user interactions, and two APIs: Core and Layers. The low-level Core API corresponds to the former deeplearn.js library. It provides hardware-accelerated linear algebra operations and an eager API for automatic differentiation. The higher-level Layers API is used to build machine-learning models on top of Core. The Layers API is modeled after Keras and implements similar functionality. It also allows to import models previously trained in python with Keras or TensorFlow SavedModels and use it for inference or transfer learning in the browser.

With Tensorflow.js, machine-learning models can be utilized in the browser in three ways: by importing already pre-trained models and using them for inference only, by training models from scratch directly in the browser, or by using transfer learning to first adapt imported models to the user's context and then use these improved models for inference.

As Nikhil Thorat and Daniel Smilkov, members of the Tensorflow team, point out in their announcement video, running Tensorflow in the browser has several advantages: the infrastructure and set of requirements are simplified as the need for background API requests is removed; the available data is richer in nature thanks to newly accessible sensors, such as webcam and microphone on computers or GPS and gyroscope on mobile devices; and the data also remains on the client side which addresses privacy concerns. 

Javascript based deep-learning also lowers the barrier of entry into the field of data science for many web developers. It enables them to integrate machine learning functionality into their applications while bringing an innovative approach to the domain. Online demos show the improvements in terms of speed and quality of interactions which result from running machine learning directly in the browser: from sentiment analysis to hand gesture detection or style transfer.

Similar Javascript implementations of deep learning frameworks have existed for a while with the precursor brain.js project and the ConvNet.js library from Standford for convoluted neural networks. More recent libraries include KerasJS and TensorFire. However, these libraries either lack the ability to leverage the browser WebGL components for GPU based computations, or do not allow training the models directly in the browser. Propel for scientific computing and ml5 a for machine learning are more recent projects based on Tensorflow.js, which do not suffer from these shortcomings.

The Tensorflow team is currently working on making TensorFlow.js support Node.js, but no timeframe has been given yet. Several other significant Tensorflow developments were announced during the TensorFlow Dev Summit including TensorFlow for Swift, due for release in April 2018 and TensorFlow Hub which "provides a repository for sharing different pre-built modules developers can reuse across multiple models".

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT