I’m trying to make a game website and add some reinforcement learning into the games. So my backend for making the website is Django, and I’m currently using PyTorch for the neural network. I’ve made the game on the web browser where the logic of the game is inside a javascript file. I’m wondering how would I go about importing the untrained PyTorch neural network to the browser to be trained?
Because if I wanna train the model in the backend, then I would have to rewrite the whole game logic in python just to train it then import it. Since I’ve already written the game in javascript file and imported it to the browser, I would like import neural network to browser and then train it. Would this be easier if I switched to Tensorflow and use Tensorflow.js?
As of current ONNX models (which could be made from pytorch models) can not be trained in the browser. However, at a certain period (around version 1.17-1.19) there existed a way. This article outlines the full steps ( On-Device Training: Training a model in browser - Microsoft Open Source Blog or here GitHub - juharris/train-pytorch-in-js: Convert a PyTorch model and train it in JavaScript in your browser using ONNX Runtime Web ). Although, I will say this feature was very buggy (with wasm) and is now gone as of now. You can maybe convert onnx to tensorflow.js (but its not the best practice). Anyway, Inference in the browser is easy but training is not. Even if you use tensorflow it is going to be slow but here is an example of PPO ( GitHub - zemlyansky/ppo-tfjs: PPO in Tensorflow.js ).