Skip to main content

pymlkit

A small, dependency-free neural network library with a C core and a Python wrapper. Dense feed-forward networks, mini-batch SGD, binary weight import/export, and REINFORCE reinforcement learning (C API).

Python

pip install pymlkit        # or, from a clone: pip install .
from pymlkit import Network, Activations, Losses

model = Network(2)                          # 2 inputs
model.add_dense(16, Activations.ReLU)
model.add_dense(1, Activations.Sigmoid)
model.set_loss(Losses.HalfMSE)

# data is a flat list: [x1a, x1b, x2a, x2b, ...] / [y1, y2, ...]
model.fit(train_x, train_y, lr=0.1, epochs=100, batch=16)

print(model.forward([0.1, 0.2]))            # -> [0.93]
model.export("model.mlk")                   # model.load("model.mlk") to restore
Method Description
Network(input_size) Create a network
add_dense(n, activation) Append a dense layer (output layer last)
set_loss(loss) Losses.HalfMSE or Losses.CrossEntropy
fit(x, y, lr, epochs, batch, log_step) Mini-batch SGD
forward(x) One sample in, list of outputs out
backward(y) Accumulate gradients for one sample (custom loops)
export(path) / load(path) Save / load weights; load returns False if the file is missing

Activations: ReLU, Linear, Softmax, Sigmoid. Example: python/examples/circle_classifier.py.

C

The same library, usable directly from C (MLKit.c / MLKit.h):

#include "MLKit.h"

Network* net = nn_network_create(2);
nn_add_layer_dense(net, 8, activation_reLU);
nn_add_layer_dense(net, 1, activation_sigmoid);
nn_network_set_loss(net, CrossEntropy);

nn_network_fit(net, x_train, 4, y_train, 0.1f, 2000, 4, 500);
float* out = nn_network_forward(net, sample);

nn_network_export(net, "model.mlk");
nn_network_destroy(net);
gcc -Ofast -o example example.c MLKit.c -lm   # or: cmake -S . -B build && cmake --build build

Compile with -Ofast (MSVC: /O2 /fp:fast) for much faster training. The CMake build and the PyPI wheels already do this.

Main functions: nn_network_create, nn_add_layer_dense, nn_network_set_loss, nn_network_fit, nn_network_forward, nn_network_backward, nn_apply_gradients, nn_network_test, nn_network_export, nn_network_import_file, nn_network_destroy. Signatures are in MLKit.h.

Reinforcement learning (REINFORCE): rl_agent_create, rl_draw_action, rl_remember, rl_policy_fit, rl_agent_destroy. See examples/snake/ for a full Snake agent.

Notes

  • Weights are stored as flat float32 arrays; the .mlk file is a raw float32 stream (bias, then weights, per neuron).
  • Loading a model does not check that the architecture matches.
  • No shuffling between epochs. CPU only. A learning/prototyping library, not production-hardened.

License

MIT

Metadata

Release files for pymlkit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymlkit 0.1.1
File Size Uploaded Provenance
pymlkit-0.1.1.tar.gz 11.6 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pymlkit 0.1.1
File
pymlkit-0.1.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pymlkit-0.1.1-py3-none-win32.whl Python 3 none Windows x86-32 Details
pymlkit-0.1.1-py3-none-pyemscripten_2026_0_wasm32.whl Python 3 none PyEmscripten 2026.0+ WebAssembly Details
pymlkit-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
pymlkit-0.1.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
pymlkit-0.1.1-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 114.8 kB

Release files / pymlkit-0.1.1.tar.gz

Download URL pymlkit-0.1.1.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
62c6950dd6741c45c9f211cd6f7b6589d89c48cddcc9f52a0fa5215f4b84629e
BLAKE2b-256 checksum
How to use checksums
a4e20a69cb2a6a62de9b842b0e294f68663dd101ce034e7a85f59cfd587bc1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-win_amd64.whl

Download URL pymlkit-0.1.1-py3-none-win_amd64.whl
Size 19.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
fc9f83e122605fc737a2a457f6dc8d21f121389184c98678cbae87c745278104
BLAKE2b-256 checksum
How to use checksums
c685ba99c31a08e5de9fdc466b28fbdb1011ba73d399268b19106a3b9c22f090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-win32.whl

Download URL pymlkit-0.1.1-py3-none-win32.whl
Size 16.3 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
a1c292b492ed44d59a225beb3979f5c3fcfde271d13029d12ec68a78654752d6
BLAKE2b-256 checksum
How to use checksums
fbe43c4ab8e07540539cd70b59f9c7974b88ff2780230186c7c5e70416f3b613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-pyemscripten_2026_0_wasm32.whl

Download URL pymlkit-0.1.1-py3-none-pyemscripten_2026_0_wasm32.whl
Size 9.5 kB
Tags PyEmscripten 2026.0+ WebAssembly Python 3
SHA-256 checksum
How to use checksums
a80f59207a9846eec264f0f54464fd90a78526546fa26488543287debf27198f
BLAKE2b-256 checksum
How to use checksums
4c1e59613596a4d97ec5a832f30e979869de7a65d156b357de66ad4269b9dc62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pymlkit-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 16.9 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b81363f35bf0d67f7278d7cf2c7ddb7928670b2369c76c159c9ea79aa22f89da
BLAKE2b-256 checksum
How to use checksums
fb55d30af3559e55a9d0543a13d220a1397268df98beb7db3330525ad32f26b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-macosx_11_0_arm64.whl

Download URL pymlkit-0.1.1-py3-none-macosx_11_0_arm64.whl
Size 19.9 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d3512cb6a40b4d6744017ee7f1c10931391d4a7815edb0e41451d174bdb3a82
BLAKE2b-256 checksum
How to use checksums
e5a317b042e4dc1c54461384ae522689f6c2fe6e31e6f67af37f33e3055e2639
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Release files / pymlkit-0.1.1-py3-none-macosx_10_13_x86_64.whl

Download URL pymlkit-0.1.1-py3-none-macosx_10_13_x86_64.whl
Size 21.5 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
9e3646be570544fe5ddc487dedb3d83390ea24eedc4ddc946b4e5746d464aaa5
BLAKE2b-256 checksum
How to use checksums
ad5469de54d28321c7fb7b2fc57573138eb4f9930c6a98c37cda0f466b5ed720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Security for pymlkit 0.1.1

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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pymlkit-0.1.1.tar.gz

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 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

7 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page