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
pip install enchanter
or
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=5
)
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.5.3.tar.gz
(30.4 kB
view hashes)
Built Distribution
enchanter-0.5.3-py3-none-any.whl
(49.0 kB
view hashes)
Close
Hashes for enchanter-0.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d35625ecf4ccd9f7fe87095506801304d7bcb4d8b4fa72b9c510b0f06cf02548 |
|
MD5 | 437087d3af8fb20ccac0ee9dfc858668 |
|
BLAKE2b-256 | 23256cc081eea113ddeefd43da5c1703a24d3f0a79d571e50f2672a904d13a88 |