JavaScript use case in Machine Learning Industry
TensorFlow.js: The Javascript library for Machine Learning in the browser
TensorFlow.js is a JavaScript library created by Google as an open-source framework for training and using machine learning models in the browser. In short, the framework helps JavaScript developers build and deploy ML models within client-side applications.
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.
Still, the question remains: why do we need a Javascript machine learning library?
Pros and cons of using JavaScript for machine learning
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.
That said, the JavaScript library is only v1.0, and it still has significant limitations. So what are the current pros and cons of using TensorFlow.js in machine learning?
Pros of TensorFlow.js
Popularity
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.
Performance
The language itself has high computational performance. It’s hardware-accelerated, as it uses WebGL (a JavaScript graphics API). Plus, if an end-user has a GPU in their system, developers can leverage that to enhance performance further.
Security
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.
Range
TensorFlow.js has already proven its value in several use cases on multiple devices: be it in JavaScript applications that run in the browser; on servers inside a Node.js environment; on the desktop; even in mobile browsers on Android and iOS devices.
Cons of TensorFlow.js
Data Limitations
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.
Hardware Acceleration
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.
Single-threaded
In the JavaScript library, single threads download synchronously, which might throttle performance. Developers can overcome this by yielding the main thread, say, to improve the responsiveness of a page during training.
And in Node.js environments, developers can ensure tasks queued in the event loop are handled in a timely manner
What’s possible with Machine Learning and JavaScript?
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.
- Automatic Picture Manipulation: auto-adjust images based on a predefined rule-set using a browser-based application — even generate art using convolutional neural networks, as Google has done.
- Offline Game Opponents: play against an AI-operated adversary, even when a video game is offline — as you can do against Chrome’s built-in Trex opponent.
- 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.
Thank You For reading !!