Machine Learning in the Browser

Machine learning is defined as a set of techniques that enables computers to learn new stuff. The programmers define a set of learning techniques or algorithms and feed them into the machines. Based on those algorithms, the machines start learning new stuff. Various languages have been used to implement machine learning algorithms. The most common ones being python, R, Java etc. In order to aid the development process various machine learning libraries have been developed by various companies. The most notable one being the tensorflow library released by Google.

The Tensorflow library

Tensorflow library is an open source machine learning library introduced by the Google brain team. This library performs machine learning by executing the algorithms called models on the given input data. A model represents a set of mathematical computations or algorithms that is performed on the given data. Tensorflow library is based on the commonly used Python language. The user can either define new models or can reuse the already existing models on the given data to derive the results. The results can range from small range tasks like games to higher level tasks such as decision making with medical, financial and other crucial data. Because of its open source and easy to learn nature, it has been tried out, followed and developed by vast amounts of developers all over the world.

Machine Learning in browser

The languages used for machine learning needs their own setup for development. The setup includes installation of compilers, supported editors and debuggers etc. Google wanted to reduce this workload even further so that developers can start even early without any further development environment setup. This introduced the introduction of Tensorflow js. Tensorflow js enables the developers start with the machine learning code in the browser itself. The developer do not have to go through complex development environment setup. The developer can also create new models or execute new models in the browser environment without any added complexity.

Tensorflow JS

Tensorflow JS is available as a node js package for installing in the client side machine. The following command can be used to install the necessary packages to the system.

npm install @tensorflow/tfjs
yarn install @tensorflow/tfjs

Either the node package manager tool or the yarn can be used for installing the packages. Tensorflow js enables quick setup with a one line command install. The output can be viewed in the browser environment. The only thing pending from the developer side is to create a sample web application and start with the coding task. The user can get additional information from the Tensorflow JS website. The site provides various code samples that enables the developer to get a quick taste of the machine learning technology. Either the developer can enjoy the demos or can look at the code for a deeper understanding. The user can create models, retrain already created models, or even reuse the created models on the current test data.

The following is a small example of a sample code using the prediction api

The documentation section contains all the necessary links for the developer in getting started with the Tensorflow platform.

Machine learning is an amazing technology, which leads to the evolvement of smart machines that benefits the humans in various ways. Google assistant, Iphone siri, Amazon alexa are the perfect examples. Now with the introduction of Tensorflow js, any developer can start with the machine learning technology without lot of development setup. What’s more interesting than starting with the development of this disruptive technology and explore and test it inside the browser environment itself. Let’s start exploring.