Torch - Neural Network Library for MakeCode Arcade
Torch is a lightweight neural network library designed for use within MakeCode Arcade. It provides essential tensor operations, basic neurons, and layer-based training to build small-scale neural networks.
π Features
- Tensor Operations β Supports matrix multiplication, element-wise function applications, and tensor addition.
- Neuron & Linear Layers β Implements simple neuron models and fully connected layers.
- Convolutional Layer β Enables basic convolution operations for feature extraction.
- Training Support β Uses Mean Squared Error (MSE) loss and backpropagation for weight updates.
- Activation Functions β Includes ReLU, Sigmoid, Tanh, Leaky ReLU, Softmax, ELU, Swish, GELU, Hard Sigmoid, Bent Identity, and Mish for non-linear transformations.
π See Full Version History π See How to Update Models
π Installation & Usage
β Use as an Extension
This repository can be added as an extension in MakeCode Arcade.
- Open MakeCode Arcade
- Click New Project
- Open Extensions under the gearwheel menu
- Search for
https://github.com/killercraft-thecoder/makecode-torchand import
β Edit this Project
To edit this repository directly within MakeCode:
- Open MakeCode Arcade
- Click Import, then Import URL
- Paste
https://github.com/killercraft-thecoder/makecode-torchand click Import
π GitHub Repository
You can explore the full project here:
https://killercraft-thecoder.github.io/makecode-torch/
π PyTorch Model Conversion (convert.py)
Torch now includes a conversion tool that allows users to convert saved PyTorch models into MakeCode Arcade-compatible TypeScript.
Usage
- Run
convert.pyand provide the path to your saved PyTorch model (.pthfile). - The script will extract weights and convert layers into a structured TypeScript format.
- The generated file can be imported into your MakeCode Arcade project!
Example Command:
python convert.py
πΉ GitHub Syncing Tip for MakeCode Arcade
Did you know? MakeCode Arcade only pulls changes affecting managed project files, but ignores externally added files like history.md.
This means you can:
- Store documentation or version history externally without affecting the MakeCode project.
- Keep development notes or testing scripts only in GitHub.
- Maintain extra resources without cluttering the MakeCode editor.
- Also Rember makecode arcade only pulls files in the files part of pxt.json!
If you need to make non-code updates, doing them externally can keep the project cleaner while still benefiting from GitHubβs commit tracking!