Skip to main content

YAML Keras Trainer for quick AI development

Project description

YAKET: Yaml Keras Trainer (or Yet Another Keras Trainer)

pipeline status coverage report Latest Release

Installation 💻

pip install yaket

Description 🔥

Yaket is a lightweight and simple module to train Keras modules by defining parameters directly using YAML file.

YAML parameters are validated using Pydantic, hence typos or not allowed parameters will throw errors at the beginning of the execution. This allows developer to focus uniquely on what matters: data and model development.

Data Scientists and ML Engineer won't need to add manually all training parameters, such as optimizer, callbacks, schedulers, thus reducing the likelihood of human-induced code bugs.

Features 🎊

  1. Train models with tensorflow default optimizers, metrics, callbacks, and losses.

  2. Convert the saved model to ONNX or Tensorflow-Lite for on edge-deploymnet or faster inference.

  3. Quickly use distributed multi-gpu and TPU training with tf.distributed.strategy (Experimental)

  4. Train models with custom modules defined in python script.

  5. Log training parameters, models, and results using mlflow.tensorflow.autolog() module. The run will be saved in mlruns folder.

  6. Save the model in a particular folder and particular format (i.e., SavedModel,H5, or .pb)

  7. Train with sample_weight_mode = 'temporal' when training sequence models.

  8. More to come!

Visuals 📖

The YAML file contains most of the parameters used in Keras model.fit, such as epochs, verbose, callbacks. Below an example:

    autolog: False
    optimizer: 
    - Adam:
       learning_rate: 0.001
    batch_size: 64 
    loss: 
    SparseCategoricalCrossentropy: 
        from_logits: True
    callbacks:
        - EarlyStopping:
            monitor: val_accuracy
            patience: 2
            restore_best_weights: True  
    verbose: 1 
    epochs: 100
    shuffle: True
    accelerator: mgpu 

The usage is very simple using python:

    
    model = ... # define your tf.keras.Model

    # Define path to yaml file
    path = "/yaket/examples/files/trainer.yaml"

    # Initialize trainer
    trainer = Trainer(
        config_path=path,
        train_dataset=(x_train, y_train),
        val_dataset=(x_test, y_test),
        model=model, 
    )
    trainer.train() # train based on the parameters defined in the yaml file
    trainer.clear_ram() # clear RAM after training

    trainer.convert_model(format_model = 'onnx') # Convert to ONNX

    

Other scenarios are visible in examples folder.

License

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

yaket-1.3.10.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

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

yaket-1.3.10-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file yaket-1.3.10.tar.gz.

File metadata

  • Download URL: yaket-1.3.10.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for yaket-1.3.10.tar.gz
Algorithm Hash digest
SHA256 596f1019673cf5fb9d7f3ba991667aa957e964039313b807d7f5a431519a1910
MD5 5f42effd6065eb7534141e928f7b5900
BLAKE2b-256 feed3652a3f06d0f92631956558727cb715eb836fd9e1b181f93a414f00ab051

See more details on using hashes here.

File details

Details for the file yaket-1.3.10-py3-none-any.whl.

File metadata

  • Download URL: yaket-1.3.10-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for yaket-1.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 57dc69f74674805659a34008892200b28bf533e1ac495916332aae8f6cbcf76e
MD5 ef93c37475410f03c8ef2e64298b8d9b
BLAKE2b-256 162ce41053b502bc54df1a4f28594e61921ad5297592e81f16fff5ccf08a994d

See more details on using hashes here.

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