Skip to main content

LeanAI

A library that helps with writing ai functions fast.

It ships with a full Documentation of its API and Examples.

Getting Started

Please make sure you have pytorch installed properly as a first step.

pip install leanai

Then follow one of the examples or check out the api documentation.

Design Principles

The api consists of 3+1 parts: Data, Model, Training and Core:

  • Data is concerned about loading and preprocessing the data for training, evaluation and deployment.
  • Model is concerned with implementing the model. Everything required for the forward pass of the model is here.
  • Training contains all required for training a model on data. This includes loss, metrics, optimizers and trainers.
  • Core contains functionality that is shared across model, data and training.

Scientific Principles in your work are encouraged and actively supported by the library. For scientific working, it is assumed, that your results are documented in a way, that peer reviewers can agree on the correctness of the results achieved. This includes two parts. Firstly, your results must be reproducible and secondly they need to be documented in a way that proves to reviewers, that you actually achieved these results. To facilitate this leanai creates a list of artifacts when running an experiment. The artifacts and their importance can be found in the scientific_artifacts.md. We argue, that you should store these artifacts even when not using leanai, to ensure reproducibility and proof that you conducted the experiment.

Tutorials & Examples

  1. Getting Started with MNIST
  2. Exploring Custom Code on MNIST
  3. Detection on COCO (TODO update and notebook)
  4. Scaling to Multi-GPU (TODO write up)

Fashion MNIST Classsification Example

Here is the simplest mnist example, it is so short it can be part of the main readme.

import torch
from torch.optim import SGD

from leanai.core.config import DictLike
from leanai.core.experiment import Experiment, set_seeds
from leanai.data.datasets import FashionMNISTDataset
from leanai.training.losses import SparseCrossEntropyLossFromLogits
from leanai.model.configs.simple_classifier import buildSimpleClassifier

set_seeds()
experiment = Experiment(
    model=buildSimpleClassifier(num_classes=10, logits=True),
    example_input=torch.zeros((2, 28, 28, 1), dtype=torch.float32),
    output_path="outputs",
)
experiment.run_training(
    load_dataset=DictLike(
        type=FashionMNISTDataset,
        data_path="outputs",
    ),
    build_loss=DictLike(
        type=SparseCrossEntropyLossFromLogits,
    ),
    build_optimizer=DictLike(
        type=SGD,
        lr=1e-3,
    ),
    batch_size=32,
    epochs=10,
)

Contributing

Currently there are no guidelines on how to contribute, so the best thing you can do is open up an issue and get in contact that way. In the issue we can discuss how you can implement your new feature or how to fix that nasty bug.

To contribute, please fork the repositroy on github, then clone your fork. Make your changes and submit a merge request.

Origin of the Name

This library is the child of all previous libraries for deep learning I have created. However, this time I want to have a simple, easy and lean library. The goal is to encourage lean development, but also more literally, that the library tries to keep your code lean, as less code means less bugs.

License

This repository is under MIT License. Please see the full license here.

Release files for leanai 2.3.0

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

Source distribution (sdist)

Source distribution for leanai 2.3.0
File Size Uploaded
leanai-2.3.0.tar.gz 79.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for leanai 2.3.0
File Interpreter ABI Platform
leanai-2.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 179.5 kB

Release files / leanai-2.3.0.tar.gz

Download URL leanai-2.3.0.tar.gz
Size 79.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04987c1ae55811ccf6313d561d6b5294a5b6846aa3ea59604515c3dae8dbeb12
BLAKE2b-256 checksum
How to use checksums
fab8d99023d76d654f7b8bf6d83d846788f7d6a30e7244e1e1a3d1c07a3141db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / leanai-2.3.0-py3-none-any.whl

Download URL leanai-2.3.0-py3-none-any.whl
Size 99.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ce6148a4c15afd6da2a5eb38506cc01d5daedaa9abc1b338be84c58d803711c
BLAKE2b-256 checksum
How to use checksums
98d7ee2ac39ae117d1ff35e94a3a48dca92ee5c03f5fb655633b8b860a24c020
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0

2 release files

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