Enchanter is a library for machine learning tasks for comet.ml users.
Project description
Enchanter
Enchanter is a library for machine learning tasks for comet.ml users.
Installation
To install the stable release.
pip install enchanter
or
To install the latest(unstable) release.
pip install git+https://github.com/khirotaka/enchanter.git
Documentation
Getting Started
Try your first Enchanter Program
Training Neural Network
from comet_ml import Experiment
import torch
import enchanter
model = torch.nn.Linear(6, 10)
optimizer = torch.optim.Adam(model.parameters())
runner = enchanter.wrappers.ClassificationRunner(
model,
optimizer,
criterion=torch.nn.CrossEntropyLoss(),
experiment=Experiment()
)
runner.add_loader("train", train_loader)
runner.train_config(epochs=10)
runner.run()
Hyper parameter searching using Comet.ml
from comet_ml import Optimizer
import torch
import torch.nn as nn
import torch.optim as optim
from sklearn.datasets import load_iris
import enchanter.wrappers as wrappers
import enchanter.addons as addons
import enchanter.addons.layers as layers
from enchanter.utils import comet
config = comet.TunerConfigGenerator(
algorithm="bayes",
metric="train_avg_loss",
objective="minimize",
seed=0,
trials=1,
max_combo=10
)
config.suggest_categorical("activation", ["addons.mish", "torch.relu", "torch.sigmoid"])
opt = Optimizer(config.generate())
x, y = load_iris(return_X_y=True)
x = x.astype("float32")
y = y.astype("int64")
for experiment in opt.get_experiments():
model = layers.MLP([4, 512, 128, 3], eval(experiment.get_parameter("activation")))
optimizer = optim.Adam(model.parameters())
runner = wrappers.ClassificationRunner(
model, optimizer=optimizer, criterion=nn.CrossEntropyLoss(), experiment=experiment
)
runner.fit(x, y, epochs=1, batch_size=32)
License
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 Distribution
enchanter-0.6.0rc4.tar.gz
(33.3 kB
view hashes)
Built Distribution
Close
Hashes for enchanter-0.6.0rc4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2871f1a7772ae5b7938531945c7694dfeeb2482601e1c9e6ab237fe57b6f5b49 |
|
MD5 | 3ef2477182d60de918e9d611b7e3fd26 |
|
BLAKE2b-256 | 0b4a25022f7d711cda3913d1f3384c92338aa11c82df7a5005f55e9026de2055 |