Preface

Write once, run anywhere is an old developer dream. The world would be so perfect if you could execute the same software in all environments, whatever the machine, the operating system, the screen resolution, or the available computing power! This wonderful idea led first to the emergence of virtual machines: a standard computer is emulated to run the software, adding an abstraction layer between the physical computer and the code. Since a virtual machine machine is the same between different architectures, you only need to write and compile the source code once. The Java Virtual Machine was released in 1994 and was the first really cross-platform virtual machine.

At the same time, the World Wide Web was in its childhood. Every connected user should be able to read and publish documents on the network through the same file format. The HTML language was soon adopted as a standard for web enriched textual content. But it was only descriptive, unable to meet the needs of the new uses of the network. Indeed, in the late nineties the Internet was no longer a shared repository: the users wanted to interact dynamically with the content and with each other. For this purpose the JavaScript language landed in the web browser, which then became a Turing machine. The Java Virtual Machine also arrived in the browser through the use of Java applets and was used a lot because JavaScript was slow and weak, unsuited for large applications.

Years have passed and JavaScript has become stronger and stronger. It was first standardized in 1997. Its speed increased to such an extent that it is now less than one order of magnitude slower than native languages, without using WebAssembly or ASM.js. The web browsers have implemented new APIs providing access previously reserved to compiled applications: the GPU with WebGL, the camera and P2P streaming with WebRTC, the gamepad with Gamepad API, the Audio card with WebAudio, and the VR and AR devices with WebXR. JavaScript has even invaded new battlegrounds: server side applications with Node.js, desktop applications with Electron, Mobile applications with Progressive Web Applications or even blockchain distributed applications with Lisk. Large frameworks like React.js or Angular and package managers like Node Package Manager were built to make the development of large software possible. JavaScript is unstoppable. Its competitors like VBScript, Flash, or Silverlight were all expelled from the web browser, even the Java Virtual Machine. The role has been reversed: Javascript is often embedded into Java applications through Webview components. What if the write once, run anywhere was here, almost 25 years after the release of the first Java Virtual Machine?

When web browsers were getting enriched with new JavaScript based features, the capacities of artifical neural networks were unleashed, thanks to the use of the GPUs as computing supports and the release of GPU parallel computing libraries like Cuda or OpenCL. They added new possibilities and quickly surpassed the state of the art in many areas: natural language processing, translations, facial recognition, object labelling, image segmentation, and chatbots. Large open source deep learning frameworks like Torch, Theano, or Tensorflow, and cloud GPU offers, have brought this technology out of the labs.

However, the use of deep learning is still mainly server side and not client side. It can be explained in different ways. First, for efficient deep learning you need to use the GPU, and only now are average GPUs powerful enough even on mobile devices. Secondly, neural network models are often very heavy, and only new mobile network technologies like 5G can transfer these amounts of data fast enough. Third, you need well a built open source framework to run network models in JavaScript like Tensorflow.js in order to make it accessible. The technological trend is also moving from a full cloud computing paradigm to a more pragmatic approach led by the edge computing concept: why process all computations in a network on expensive servers when users have powerful terminals that are free to use? The technology is ready, so it is just a matter of time until you see many deep learning applications in the browser.

It is very advantageous to implement deep learning applications on the client side. You can process the browser inputs that are unavailable on the server-side, or by having a real-time constraint such as the audio feed from the microphone or the video feed from the webcam. It also makes applications more scalable and more robust with connection breaks. The software enjoys all of the benefits of JavaScript: it can be tested server-side with Node.js, used as a mobile application wrapped as a Progressive Web App, or installed as a desktop application. Your users are able to test it safely without installing anything.

This book is at the crossroads of web development and deep learning. Both technologies are beginning to meet, and their honeymoon will produce new fantastic applications that you can’t even imagine yet. Are you ready to embark on the adventure? This book is for you: you will see both how to use the main JavaScript deep learning frameworks, and the web programming side with the capture of the inputs, and the WebGL implementation.

In the near future computers will get even closer to us. In the 70’s they were far away with mainframes, but then they got closer in the 80’s with desktop computers. They entered in handbags with laptops and finally they crept into our pockets with smartphones. The augmented reality autonomous masks are the next step, and the web standard for it is almost ready: WebXR. It will bring the Internet closer to us and smarter applications will be needed in order to better understand the physical world. In the browser deep learning is currently at an embryonic stage, and this is the best time to bet on it before it becomes a giant.

Good reading and good (deep) learning!

Book Example

All of the source code used in this book can be found here: https://github.com/backstopmedia/deep-learning-browser.

You can access the demo of our Rock Paper Scissors game here: https://reiinakano.github.io/tfjs-rock-paper-scissors/.

You can access the demo of our text generation model here: https://reiinakano.github.io/tfjs-lstm-text-generation/.

About the authors

  • Xavier Bourry is Cofounder and CTO @ StartupJeeliz, specializing in deep learning.
  • Kai Sasaki is a Senior Software Engineer at Arm, and is an Apache Hivemall Committer.
  • Christoph Körner handles TSP Data and AI at Microsoft, Dublin.
  • Reiichiro Nakano, Software Engineer at Infostellar, specializes in machine learning.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset