A model wrapper for automatic model design and visualization purposes.
Project description
AIronSuit
AIronSuit (Beta) is a Python library for automatic model design/selection and visualization purposes built to work with tensorflow as a backend. It aims to accelerate the development of deep learning approaches for research/development purposes by providing components relying on cutting edge approaches. It is flexible and its components can be replaced by customized ones from the user. The user mostly focuses on defining the input and output, and AIronSuit takes care of its optimal mapping.
Key features:
- Automatic model design/selection with hyperopt.
- Parallel computing for multiple models across multiple GPUs when using a k-fold approach.
- Built-in model trainer that saves training progression to be visualized with TensorBoard.
- Machine learning tools from AIronTools:
model_constructor
,block_constructor
,layer_constructor
, preprocessing utils, etc. - Flexibility: the user can replace AIronSuit components by a customized one. For instance, the model constructor can be easily replaced by a customized one.
Installation
pip install aironsuit
Example
# Databricks notebook source
import numpy as np
from hyperopt.hp import choice
from hyperopt import Trials
from tensorflow.keras.datasets import mnist
from tensorflow.keras.optimizers import Adam
import os
from aironsuit.suit import AIronSuit
from airontools.preprocessing import train_val_split
from airontools.constructors.models.unsupervised import ImageVAE
from airontools.tools import path_management
HOME = os.path.expanduser("~")
OS_SEP = os.path.sep
# COMMAND ----------
# Example Set-Up #
model_name = 'VAE_NN'
working_path = os.path.join(HOME, 'airon', model_name) + OS_SEP
num_classes = 10
batch_size = 128
epochs = 30
patience = 3
max_evals = 3
max_n_samples = None
precision = 'float32'
# COMMAND ----------
# Make/remove paths
path_management(working_path, modes=['rm', 'make'])
# COMMAND ----------
# Load and preprocess data
(train_dataset, target_dataset), _ = mnist.load_data()
if max_n_samples is not None:
train_dataset = train_dataset[-max_n_samples:, ...]
target_dataset = target_dataset[-max_n_samples:, ...]
train_dataset = np.expand_dims(train_dataset, -1) / 255
# Split data per parallel model
x_train, x_val, _, meta_val, _ = train_val_split(input_data=train_dataset, meta_data=target_dataset)
# COMMAND ----------
# VAE Model constructor
def vae_model_constructor(latent_dim):
# Create VAE model and compile it
vae = ImageVAE(latent_dim)
vae.compile(optimizer=Adam())
return vae
# COMMAND ----------
# Hyper-parameter space
hyperparam_space = {'latent_dim': choice('latent_dim', np.arange(3, 6))}
# COMMAND ----------
# Invoke AIronSuit
aironsuit = AIronSuit(
model_constructor=vae_model_constructor,
force_subclass_weights_saver=True,
force_subclass_weights_loader=True,
path=working_path
)
# COMMAND ----------
# Automatic Model Design
print('\n')
print('Automatic Model Design \n')
aironsuit.design(
x_train=x_train,
x_val=x_val,
hyper_space=hyperparam_space,
max_evals=max_evals,
epochs=epochs,
trials=Trials(),
name=model_name,
seed=0,
patience=patience
)
aironsuit.summary()
del x_train
# COMMAND ----------
# Get latent insights
aironsuit.visualize_representations(
x_val,
metadata=meta_val,
hidden_layer_name='z',
)
More Examples
see usage examples in aironsuit/examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file aironsuit-0.1.20-py3-none-any.whl
.
File metadata
- Download URL: aironsuit-0.1.20-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0cf6dc438cb8819eec187fe4febd5404e86b2797875570dee53a214877e72fe |
|
MD5 | cef438a18ae3ccbdb3e8f0e2ec700fbc |
|
BLAKE2b-256 | 472689d4fbf22310381bb84fa2187724acfe1a2dc17e991f412856182d9e0f20 |