This content is part of the Essential Guide: Guide to Google Cloud Platform services in the enterprise

Essential Guide

Browse Sections

TensorFlow.js brings machine learning to JavaScript

Google has delivered a version of its TensorFlow machine learning library to support JavaScript developers, and the technology has proved to be a hit with users.

Google built TensorFlow.js to bring machine learning to a broader group of developers, which has quickly embraced the technology.

Machine learning has gained popularity as a way to infuse intelligence into applications. TensorFlow is a popular platform for machine learning, although the majority of machine learning packages target Python developers. Nevertheless, with TensorFlow support for JavaScript, Google will bet the odds with machine learning and TensorFlow.js. JavaScript is the number one programming language by many measures, said Sandeep Gupta, a product manager for TensorFlow at Google.

In 2017, there were 2.3 million GitHub pull requests compared to 1 million for Python, Gupta and his team wrote in a technical paper supporting TensorFlow.js. And the open source TensorFlow.js code has been downloaded more than 300,000 times since its release last year, he said.

In essence, Google wants to make it easy for hundreds of thousands of JavaScript developers to use machine learning without the need to learn Python, Gupta said.

Running in the browser

Increasingly in AI, developers want to do more powerful things with browsers, such as speech recognition; image and object recognition; and pattern and anomaly detection. TensorFlow.js aims to put that power in the browser form factor without the need for additional cloud resources or specialized server or chipsets.

Sandeep Gupta, TensorFlow product manager Sandeep Gupta

"This means that even casual app developers looking to add machine learning capabilities to their web-based apps or even mobile apps that leverage JavaScript- or Node.js-based server apps can use TensorFlow.js to add that capability," said Ronald Schmelzer, an analyst at Cognilytica, in Ellicott City, Md.

TensorFlow.js runs machine learning models entirely in the browser, using JavaScript and high-level layers API. As TensorFlow presides as the standard library for building machine learning models these days, TensorFlow.js enables JavaScript developers to reuse TensorFlow skills, extensions and models, and will enable more standardization across the field as a whole, said Adam Smith, CEO of San Francisco-based Kite, which uses machine learning to help developers write code.

Even casual app developers looking to add machine learning capabilities to their web-based apps or even mobile apps that leverage JavaScript- or Node.js-based server apps can use TensorFlow.js.
Ronald Schmelzeranalyst, Cognilytica

This also points to another growing trend to provide many server-side capabilities through JavaScript, said Torsten Volk, an analyst at Enterprise Management Associates, in Boulder, Colo.

"TensorFlow.js is one more example of this, making TensorFlow-driven machine learning accessible to full-stack developers," he said.

Server-side installation is not required. This lowers the threshold even further, which attracts even more front-end-centric developers to explore TensorFlow-based machine learning, Volk added.

Additionally, rather than download the TensorFlow.js package, developers can embed JavaScript packages directly in their applications through a call to a JavaScript library and run it from their webpage.

TensorFlow.js has more than three million hits to its library, and there have been over three million instances where people have made a call to the TensorFlow JavaScript model, Gupta said. Moreover, downloads are up 50% over the last six months compared with the previous six-month period, Gupta said.

He said he thinks this is just the beginning. Potential use cases for TensorFlow.js include the production of finished, off-the-shelf machine learning models that developers can directly embed in their applications for some quick and easy AI.

However, Google also works with large enterprise partners such as Uber, Walmart and PayPal that have standardized on Node.js, a server-side JavaScript environment, to see how machine learning pipelines could become core in their Node.js environments, Gupta said.

"Anywhere you are using JavaScript code, you can use TensorFlow.js," he said.

Dig Deeper on Software design and development

Cloud Computing
App Architecture