Machine Learning has long been associated with implementing complex algorithms. It has always been a field, where only the developers, who have deep knowledge of complex mathematical topics like Linear Algebra and Multivariate Calculus can enter.
With the introduction of TensorFlow, the complexity of developing machine learning applications has reduced drastically. However, using TensorFlow still requires proficiency in Python as well as high-performance machines for computation.
In this post, we’ll give you a quick overview of TensorFlow JS.
TensorFlow JS comes bundled with:
1) A Core API, which specifically deals with low-level code.
2) A Layer API, built with the Core API as its base. This level of abstraction makes our development easier.
Since TensorFlow JS does not require the user to install any libraries or drivers, development becomes much easier and the end user just needs to open the web page to run the application. It supports WebGL and GPU acceleration which makes computation faster.
Using TensorFlow JS, you can both run the machine-learned models in the browser to perform analysis and train them as well. Mobile devices can take advantage of sensor data (camera, microphone, gyroscope, accelerometer etc.) for creating a rich user experience.
Finally, all data stays on the client’s machine, which makes TensorFlow JS a good choice for developing low-latency client application, ensuring end-user privacy.
Using TensorFlow JS, you can:
- Import an existing, pre-trained model: This method helps us to take advantage of the hardware capabilities of server machines for training models and then use them for various applications on the client side.
- Re-train an imported model: This method takes advantage of the hardware capabilities of server machines for training a base model and then fine-tuning the model using inputs from the client side. This gives a more personalized user experience.
- Create models directly: This method gives the developer the ability to create applications that train model from scratch, completely from the client side.
TensorFlow JS comes with its own disadvantages when compared to TensorFlow. Using TensorFlow JS with WebGL makes it considerably slower than TensorFlow in Python with AVX. In the browser, simple models can be trained much faster, however, larger models will take much longer to train, compared to TensorFlow in Python with AVX.
Here are a few interesting projects build using TensorFlow JS:
- Webcam Controller: Play Pac-Man using images trained in your browser. (https://storage.googleapis.com/tfjs-examples/webcam-transfer-learning/dist/index.html)
- PoseNet: Real-time Human Pose Estimation in the browser. (https://storage.googleapis.com/tfjs-models/demos/posenet/camera.html)
- Emoji Scavenger Hunt: Use your phone’s camera to identify emojis in the real world. (https://emojiscavengerhunt.withgoogle.com/)