There’s a misconception in the world of machine learning (ML). Developers have been led to believe that, to build and train an ML model, they are restricted to using a select few programming languages. Python and Java often top the list.
Python for its simplicity: The language has an abundance of out-the-box libraries to shorten development time. PyBrain, for example, is a modular ML library that helps developers build algorithms, then test and compare solutions in predefined environments.
Java for its maturity: Java has been around for decades, so it’s the de facto language of choice for larger organizations such as banks and financial institutions when building and using algorithms.
But times are changing — as are the dynamics of ML engineering. And it’s become common practice for developers to write machine learning functions using common web-scripting languages.
These days, it’s possible to build and train an algorithm using any general-purpose programming language you want.
Developers have swarmed to using TensorFlow.js as they can use it to both:
Create new machine-learning models from scratch
As well as run — or retrain — existing, pre-trained models
The language is also a companion to its namesake TensorFlow (the ML library used with Python), meaning any machine learning model built using TensorFlow can be converted to run in the browser using TensorFlow.js.
The answer is…
The fact that TensorFlow.js runs within the browser opens up a range of exciting possibilities for businesses and developers alike.
As browsers are an interactive space: one that offers access to various sensors — including webcams and microphones — which can provide visuals and sounds as an input into any machine learning model.
Pros of TensorFlow.js
The first positive signal: developers who use it love TensorFlow.js. And adulation typically points to utility, so it’s safe to say the library offers a valuable addition to the world of machine learning.
Moreover, given its a companion to the popular Python library, there’s a low entry threshold — making it simpler for developers to start using it.
Web-scripting languages can open potential vulnerabilities. However, TensorFlow.js has built a reputation for the security of its execution environment, ensuring devices remain protected against threats when running an application.
Cons of TensorFlow.js
Despite all the positives, TensorFlow.js does not have default access to the file system in the browser host environment. This limits available data resources and can put restrictions on file sizes.
The framework also has limited support for hardware acceleration. That said, as the open-source language evolves beyond v1.0, this situation is rapidly improving.
And in Node.js environments, developers can ensure tasks queued in the event loop are handled in a timely manner.
So now you know the pros and cons, but what’s actually possible with TensorFlow.js?
Presciently, many developers are moving from handling ML on back-end servers to front-end applications.
And thanks to TensorFlow.js, teams can now create and run ML models in static HTML documents without ever setting up a server or even database — enabling the following services, hosted entirely client-side.
Content Recommendation Engine: build and train an ML algorithm in the browser, identifying what users like to look at and surfacing more relevant content — just as Twitter have done to rank tweets.
Activity Monitoring: install a client-side application that learns usage patterns on a local network or device — to monitor and flag unusual activity.
Object Detection: use a client-side application to detect documents or objects in pictures — such as Airbnb uses to alert users to the presence of sensitive information when they upload a passport or driving license photo.
How to use Tensorflow.js to showcase your creativity
Yes — TensorFlow.js is in its early stages.
Still, an increasing number of companies are experimenting with machine learning applications that run on the end-users’ device. And as devices get more powerful, the opportunity to experiment will only grow.
At DLabs.AI, we’ve used browser-based applications (with permission, of course) to carry out early-stage data analysis from the client’s device, gleaning powerful insights that inform on future development decisions.
We’ve also used the latest APIs — like Node’s File System API — to access files stored locally on the user’s device, as well as to run multiple threads to help clients overcome performance issues.
We’re excited by what we’ve been able to do, not to mention intrigued by what’s to come — safe to say, it’s a technology we’ll be exploring well into the future.
Interested in exploring browser-based ML? Feel free to get in touch to see how DLabs.AI can help you use TensorFlow.js to boost your machine learning initiatives.