Juggernaut: Neural Networks in a web browser

Juggernaut is an experimental Neural Network, written in Rust. It is a feed-forward neural network that uses gradient descent to fit the model and train the network. Juggernaut enables us to build web applications that can train and evaluate a neural network model in the context of the web browser. This is done without having any servers or backends and without using Javascript to train the model.

Juggernaut’s developer-friendly API makes it easy to interact with. You can pass a dataset to Juggernaut from a CSV file or simply use the programmatic API to add documents to the model, and then ask the framework to train it. Juggernaut implements most activation functions as well as a few different cost functions, including Cross Entropy.

Juggernaut has a demo page, written with React and D3.js which illustrates the network, weights, and loss during a training session.

Demo

The demo page enables users to define a few options before starting the training session. These options are:

Dataset

Learning rate

Number of epochs (iterations)

In order to make the demo page more intuitive and easier to use, there are a few predefined datasets available on the page which load and illustrate data points from a CSV file. Each dataset has 3 classes, orange, blue and green and 2 features, X and Y.

After selecting the dataset and defining the options, you can start the training session by clicking the “Train” button on the page. Clicking on this button will spawn a new thread (web worker) and pass the dataset and parameters to the created thread.

During the training session, you can see the number of epochs, loss, and weights of the network. The web worker communicates with the main thread of the browser and sends the result back to the render thread to visualize each step of training.

The number of layers is predefined in the application. We have one input layer, two hidden layers, and one output. For hidden layers, we use ReLU activation function and the output layer uses Softmax with Cross Entropy cost function.

Compiling Rust to Web Assembly

Juggernaut’s demo page uses Web Assembly and HTML5 Web Worker to spawn a new thread inside the context of a web browser, and communicates between the web worker and the browser’s render thread (main thread) to train and evaluate the model.

Juggernaut does not use any kind of Javascript codes to train and evaluate a model. However, it is still possible to run Juggernaut on modern web browsers, without having any backend servers as most modern web browsers, including IE 11 and portable web browsers on Android and iOS, support Web Assembly (source: http://caniuse.com/#search=wasm).

Importantly, the demo page uses a separate thread to train and evaluate a model and does not block the main thread or render thread of the web browser. So you can still interact with the UI elements of the page during training or you can keep the training session running for some time until receiving the accurate evaluation from the framework.

“Juggernaut”?

Juggernaut is a Dota2 hero and I like this hero. Juggernaut is powerful, when he has enough farm.