Syna
Syna is a lightweight machine learning framework inspired by DeZero. Built from scratch using only NumPy, it follows a define-by-run (dynamic computation graph) approach and includes a basic reinforcement learning framework.
Unlike most frameworks that implement reinforcement learning as a separate library, Syna provides everything in a single library.
Designed for beginners and researchers, Syna helps you learn the fundamentals of machine learning and the inner workings of frameworks like PyTorch. Performance is not the focus, and GPU support is intentionally omitted to keep the code simple and easy to understand.
Installation
Get the Syna Source
git clone https://github.com/sql-hkr/syna.git
cd syna
uv venv
source .venv/bin/activate
uv sync
Or, from PyPI:
uv add syna
[!IMPORTANT] To visualize the computation graph, you need to install Graphviz.
brew install graphviz # macOS sudo apt install graphviz # Linux
Getting started
Computation Graph
Visualize the computation graph for the fifth derivative of tanh(x) with respect to x.
import syna
import syna.functions as F
from syna import utils
x = syna.tensor(1.0)
y = F.tanh(x)
x.name = "x"
y.name = "y"
y.backward(create_graph=True)
iters = 4
for i in range(iters):
gx = x.grad
x.cleargrad()
gx.backward(create_graph=True)
gx = x.grad
gx.name = "gx" + str(iters + 1)
utils.viz.plot_dot_graph(gx, verbose=False, to_file="tanh.svg")
The output graph is shown below.
RL (Deep Q-Network; DQN)
Solve CartPole-v1 using the DQN algorithm.
from syna.algo.dqn import DQNAgent
from syna.utils.rl import Trainer
trainer = Trainer(
env_name="CartPole-v1",
num_episodes=300,
agent=DQNAgent(
lr=3e-4,
),
)
trainer.train()
API Reference
License
Syna is licensed under the MIT License. See LICENSE for details.
Release files for syna 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| syna-0.3.0.tar.gz | 23.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| syna-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.3 kB
Release files / syna-0.3.0.tar.gz
| Download URL | syna-0.3.0.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21aeaa8e651182e257e0ae2a8044e1fe1847c44c9040a2630e4b7484702a3f3d
|
|
BLAKE2b-256 checksum How to use checksums |
ae3a979d9b0fd44e3d0031d4362d13f3f396d44cee6cf14a3dde8174911b2020
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2025.
Transparency logRelease files / syna-0.3.0-py3-none-any.whl
| Download URL | syna-0.3.0-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3535a43753e7f4c9fff874f428bf887c49a67128b42322a0deb7d2dd342669ad
|
|
BLAKE2b-256 checksum How to use checksums |
4ee9a4e76d3473f38de93d303b12221ebd36018a70590ccd44f7a92b2b7d3f73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2025.
Transparency log