Skip to main content

Morty

Morty is a lightweight experiment and configuration manager for small ML/DL projects and Kaggling.

Main Features:

  • Configuration Management. Morty includes a config loading system based on the python files that makes you configure a wide variety of moving parts quickly and without overheads.
  • Experiment Management. Morty provides a flexible, simple and local experiment management system that tracks a lots of context about your project state to make it possible to reproduce experiments.

Installation

pip install morty
# or
poetry add morty

Example of Usage

Trains a Keras model on MNIST:

import numpy as np
from tensorflow import keras
from tensorflow.keras import layers

from morty.config import config, ConfigManager
from morty import ExperimentManager, Experiment
from morty.trainers import TensorflowTrainingTracker


@config(path="configs", name="basic_config")
def train(configs: ConfigManager) -> None:
    experiment: Experiment = ExperimentManager(configs=config).create()

    # the data, split between train and test sets
    (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()

    # Scale images to the [0, 1] range
    x_train = x_train.astype("float32") / 255
    x_test = x_test.astype("float32") / 255

    # Make sure images have shape (28, 28, 1)
    x_train = np.expand_dims(x_train, -1)
    x_test = np.expand_dims(x_test, -1)

    # convert class vectors to binary class matrices
    y_train = keras.utils.to_categorical(y_train, configs.num_classes)
    y_test = keras.utils.to_categorical(y_test, configs.num_classes)

    model = keras.Sequential(
        [
            keras.Input(shape=configs.image_shape),
            layers.Conv2D(32, kernel_size=(3, 3), activation="relu"),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Conv2D(64, kernel_size=(3, 3), activation="relu"),
            layers.MaxPooling2D(pool_size=(2, 2)),
            layers.Flatten(),
            layers.Dropout(0.5),
            layers.Dense(configs.num_classes, activation="softmax"),
        ]
    )

    model.compile(
        loss="categorical_crossentropy",
        optimizer="adam",
        metrics=("accuracy",),
    )

    model.summary()

    training_history = model.fit(
        x_train, y_train,
        epochs=configs.epochs,
        batch_size=configs.batch_size,
        validation_split=configs.val_dataset_fraction,
        callbacks=(
            TensorflowTrainingTracker(experiment),
        )
    )

    experiment.log_artifact("training_history.pkl", training_history)

    test_loss, test_accuracy = model.evaluate(x_test, y_test, verbose=0)

    print(f"Test loss: {test_loss}")
    print(f"Test accuracy: {test_accuracy}")


if __name__ == "__main__":
    train()

Citation

If Morty helped you to streamline your research, be sure to mention it via the following BibTeX entry:

@Misc{Glushko2021Morty,
  author =       {Roman Glushko},
  title =        {Morty - a lightweight experiment and configuration tracking library for small ML/DL projects and Kaggling},
  howpublished = {Github},
  year =         {2021},
  url =          {https://github.com/roma-glushko/morty}
}

Acknowledgment

Credentials

Made with ❤️ by Roman Glushko (c)

Metadata

Release files for morty 0.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 morty 0.3.0
File Size Uploaded
morty-0.3.0.tar.gz 29.3 kB Details

Built distribution (wheel)

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

Total release size: 51.0 kB

Release files / morty-0.3.0.tar.gz

Download URL morty-0.3.0.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d1aa187a21dfa82cc53664c0f5a89235dd9ec1a413c8490a12039786ccc89c1b
BLAKE2b-256 checksum
How to use checksums
d01f20c9729fab5989830150d88c793d25b627f6c08946d10bc6bf377b0958d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.4 Darwin/20.6.0

Release files / morty-0.3.0-py3-none-any.whl

Download URL morty-0.3.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b842c97bd29fa40b4c44a05efa6f4993ff7a1f4205a2bccc37d60d36850a3c45
BLAKE2b-256 checksum
How to use checksums
bc1e575c8114cf5629afafe3e8bf27e22fdd522a3784747e41ed17eb3c55c2e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.4 Darwin/20.6.0
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