Skip to main content

Pure Python Deep/Machine Learning Framework

Project description

Marquetry

Marquetry means Yosegi-zaiku, a traditional Japanese woodworking technique, in Japan. It is a beautiful culture craft originated in Japan, which is a box or ornament or so by small wooden pieces. The design is UNIQUE, it depends on the arrangement of the wood tips. I believe Deep Learning is similar with the concept. Deep Learning models are constructed through the combination of the layers or functions. Just as a slight variation in arrangement can result in a completely distinct model. I want you can enjoy the deep/machine learning journey like you craft a Marquetry from combination of various wood tips.

About this Framework

You can use this framework for help your learning Machine/Deep Learning. This framework is written only Python, so you can understand the implementation easily if you are python engineer. For simplify the construct, there are un-efficiency implementations. I develop this framework to enjoy learning the construction of the machine/deep learning not Practical Usage. I hope to enjoy your journey!

Features

  • Define-by-run automatic differentiation — the computation graph is recorded while your Python code runs, so any control flow just works
  • Neural network building blocks — layers (Linear, Convolution2D, Deconvolution2D, BatchNormalization, BatchRenormalization, LayerNormalization, RNN/LSTM/BiLSTM/GRU, Embedding, ...), 70+ functions (activations, losses, evaluation metrics, ...), and ready-made models (MLP, CNN, Sequential)
  • Optimizers — SGD, MomentumSGD, Nesterov, AdaGrad, AdaDelta, RMSProp, Adam, AdamW, AdaMax, Nadam, and Lion
  • Data utilities — built-in datasets (FashionMNIST, Titanic, synthetic toy sets), DataLoader / SeqDataLoader, transformers, and pandas-based tabular preprocessing (encoding, imputation, normalization)
  • Classic machine learning — decision trees, random forest, and SVM, implemented from scratch with the same fit / predict interface
  • Model export
    • ONNX (model.export_onnx(...)) — run your model anywhere ONNX Runtime works
    • marquetry archive (model.export_archive(...), .mq) — graph + weights in one file; reload it without the original model class, and keep training the restored model
    • save_params / load_params — plain npz weight checkpoints
  • GPU support via CuPy (optional)

Quick Start

import numpy as np

import marquetry
import marquetry.functions as funcs
from marquetry import optimizers, transformers
from marquetry.dataloaders import DataLoader
from marquetry.datasets import Spiral
from marquetry.models import MLP

train_set = Spiral(transform=transformers.ToFloat(), target_transform=np.argmax)
train_loader = DataLoader(train_set, batch_size=30)

model = MLP([32, 32, 3], activation=funcs.relu, is_dropout=False)
optimizer = optimizers.Adam().prepare(model)

for epoch in range(100):
    for x, t in train_loader:
        loss = funcs.softmax_cross_entropy(model(x), t)
        model.clear_grads()
        loss.backward()
        optimizer.update()

model.export_onnx(x, "spiral.onnx")     # needs the `onnx` package
model.export_archive(x, "spiral.mq")    # marquetry archive: graph + weights

More runnable examples live in samples/ — autograd basics, FashionMNIST training, LSTM time-series forecasting, classic ML, and model export.

Installation

pip install marquetry

With the ONNX export feature:

pip install "marquetry[onnx]"

Dependencies

Optional

  • onnx — ONNX export (pip install "marquetry[onnx]"), and onnxruntime to run the exported models
  • CuPy — GPU support
  • Graphviz — computation graph visualization (Model.plot)

For running the test suite

The test suite runs on Python 3.10 through 3.14 in CI.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marquetry-0.3.0.tar.gz (142.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marquetry-0.3.0-py3-none-any.whl (202.5 kB view details)

Uploaded Python 3

File details

Details for the file marquetry-0.3.0.tar.gz.

File metadata

  • Download URL: marquetry-0.3.0.tar.gz
  • Upload date:
  • Size: 142.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for marquetry-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2c4abc413b50c0b23eb60c0eac0397eb8db49b63935bf8d8073dba2b22d5120b
MD5 8e26af56f0c2b3d89155210272faebfc
BLAKE2b-256 9285198d12d57463daf239c97bfa3b0f87e13156b99ad7725b919d2e7a0f62a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for marquetry-0.3.0.tar.gz:

Publisher: release.yml on SHIMA0111/Marquetry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marquetry-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: marquetry-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 202.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for marquetry-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79386d5aa455d2f91d5a9168464d4d8b922223ee3deaf5cbc103a532327bd269
MD5 c656028bfd9cf826da7afdb13f57a15f
BLAKE2b-256 d1dc16ec6fce83fd8f1cb0fa509a9ff693efd447268cb452fc0cdf2d22b3b4e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for marquetry-0.3.0-py3-none-any.whl:

Publisher: release.yml on SHIMA0111/Marquetry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page