I was writing a blog post about the different activation functions and how they can impact your training. I wanted to make an interactive post so was looking at running a simple model on the browser. That’s when I found Tensorflow JS.
Kudos to the people behind this. This was a great way to bring the awesomeness of Tensorflow to the browser. When using the library you can either:
- Load a pre-trained model
- Train on the browser
Let’s try and do both. We’ll work with the make_moons dataset from sklearn.
Parameters we’ll be using:
- Activation Function: tanh
- Learning Rate: 1
The data we’ll be training on:
That took 2.63s
Save the model to a form which can be used by TensorflowJS
Finally Lets see how our model predicts
Code used to train the model:
Time taken to finish training: Loading
If you wait long enough, you’ll see the model finish training and prediction similar to our earlier method. The only difference is that this time it took a lot more time. On my PC it takes around 22s which is almost 1000% of the previous method.
Its amazing that we can even do something on the lines of training models on browsers. But at the same time, we can see how years of optimization on the Python front of Tensorflow clearly gives it an edge over its JS counterpart.