This project exists to serve as an example on training a neural network in nothing but javascript within your browser.
Utilizing javascript in the browser has the following benefits:
- Simple dependency management with npm
- Powerful html & css data visualisations
- GPU accelerated training through WebGL compute shaders without any extra sdk or driver installation
- The trained model is ready to deploy any other browser client
The main drawback of this set up is that performance of model training and inference will be slower than running code natively on a computer with something like Node.js or Python. That being said, spending days configuring your Python environment and fiddling with CUDA drivers is also slow 😶🌫️.
This work utilizes the sleep efficiency dataset from kaggle.
While the dataset is quite limited in size and has many methodological issues, it is a good candidate to help us answer the question:
What lifestyle changes should I make to achieve the highest sleep efficiency?
We will first utilize danfo.js to ingest and prepare, and visualize our downloaded data csv.
Tensorflow.js will be used for the training and inference process.
The only software you need is Node.js 18.
To install library dependencies run the following command at the root of the project:
npm install
To work around a bug in the existing version of danfo.js run the following command first:
npm run setup
To execute the project webpage, run the following command:
npm run start