Juggernaut: Neural Networks in a web browser
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.
The demo page enables users to define a few options before starting the training session. These options are:
- 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.
Below is the process of compiling Rust to Web Assembly:
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 is a Dota2 hero and I like this hero. Juggernaut is powerful, when he has enough farm.