Before you go, check out these stories!

Hackernoon logoIntroducing TensorFlow.js 🎉 by@rish-16

Introducing TensorFlow.js 🎉

Author profile picture


ML Research Student at NUS •

Running ML models on the browser became so much more easier!

We have seen the awesome capacity of TensorFlow and how it makes the process of programming neural network architectures so much more simpler. An increasing number of startups are using TensorFlow in their open-source projects.

Best of TF – now on your browser

On Friday, 30 March 2018, the TensorFlow team announced the arrival of the much-awaited web version of the famous ML framework, TensorFlow.js.

Now, developers can build lightweight models and directly run them on the browser without any hassle. The code examples and documentation provided are easy to understand and fortunately, they follow the same generic programming convention of the Python framework in terms of syntax and applicability.

To get started with projects with TF.js, you can check out their site here.

Creating Neural Networks

Building Neural Networks (NNs) using javascript has become so much more easier with TF.js. The process of creating tensor arrays and creating feedforward networks is simplified with the abstractions that the web framework provides.

Let’s take a look at how one can create a simple feedforward NN using TF.js:

This is a basic HTML template with the TF.js CDN.
This is a single layer perceptron using the TF.js library.

In comparison, here is the implementation of the same neural network using the Python framework:

This is the implementation of the same network using the tflearn library. You can see how alike the two sets of code are to each other, making TF.js a suitable web counterpart to TensorFlow.

The lack of proper training datasets does have an effect on the accuracy of the above network demo (We all know that’s not the right answer). Nonetheless, the JS library has the same performance metrics as its Python counterpart, assuring you the same quality as your Python projects that use TensorFlow, Keras or tflearn.

We can see that both of the libraries have the same performance and results for the network, making TF.js a suitable component for web-based predictions.

An honest review (of sorts)

Learning about TensorFlow has been a new experience on its own! The ease of implementing Machine Learning algorithms and deploying them has revolutionised the industry.

The code is simple to write and doesn’t contain too much technical jargon, making it ideal for beginners. Another exciting development to look forward to in the web ML space is the release of Keras.js. I’d like to get my hands on that!

Generally, if you are used to tflearn, TensorFlow.js should be easy to apply into your web projects. The code is lightweight and the training is fast. There doesn’t seem to be any problems in reading the JS documentation and implementing the code for the network.

In a nutshell

TensorFlow.js has serious potential. Instead of linking javascript files to a python file running on the cloud for a prediction, the model can be run directly from the browser without invoking any extra files. TF.js can be used like any other CDN (Content Delivery Network) like Font Awesome or JQuery. Do try out this web framework for yourself and take it out for a test drive when working on online ML solutions. Until then, I’ll see you in the next one!

Original article by Rishabh Anand


Join Hacker Noon

Create your free account to unlock your custom reading experience.