Neptune is a lightweight experiment logging/tracking tool that helps you with your machine learning experiments. Neptune is suitable for indvidual, commercial and research projects.
- Rich experiment logging and tracking capabilities
- Python and R clients
- Experiments dashboards, views and comparison features
- Team management
- 25+ integrations with popular data science stack libraries
- Fast, reliable UI
pip install neptune-client
or
conda install -c conda-forge neptune-client
For the hands-on intro to neptune-client check this API Tour, below simple example is presented:
import neptune
neptune.init('my_workspace/my_project')
neptune.create_experiment()
for epoch in range(train_epochs):
...
neptune.log_metric('loss', loss)
neptune.log_metric('metric', accuracy)
score = ...
neptune.log_metric('val_score', score)
neptune.log_artifact('model_weights.pth')
Neptune can especially helpful with the following problems:
- Logging runs metadata
- Monitoring ML runs live
- Organizing and exploring runs
- Comparing/debugging ML runs and models
- Sharing results of experiments with your team/departament
Neptune comes with 25+ integrations with Python libraries popular in machine learning, deep learning and reinforcement learning.
Integrations lets you automatically:
- log training, validation and testing metrics, and visualize them in Neptune UI,
- log experiment hyper-parameters,
- monitor hardware usage,
- log performance charts and images,
- save model checkpoints,
- log interactive visualizations,
- log csv files, pandas Datraframes,
- log much more.
PyTorch Lightning is a lightweight PyTorch wrapper for high-performance AI research. You can automatically log PyTorch Lightning experiments to Neptune using NeptuneLogger
(part of the pytorch-lightning library).
Example:
from pytorch_lightning.loggers.neptune import NeptuneLogger
# Create NeptuneLogger
neptune_logger = NeptuneLogger(
api_key="ANONYMOUS",
project_name="shared/pytorch-lightning-integration",
params=PARAMS)
# Pass NeptuneLogger to the Trainer
trainer = pl.Trainer(max_epochs=PARAMS['max_epochs'],
logger=neptune_logger)
# Fit model, have everything logged automatically
model = LitModel()
trainer.fit(model, train_loader)
Check full code example:
TensorFlow is an open source deep learning framework commonly used for building neural network models. Keras is an official higher level API on top of TensorFlow. Neptune helps with keeping track of model training metadata.
Neptune integrates with both TensorFlow / Keras directly and via TensorBoard.
Example:
import neptune
import tensorflow as tf
from neptunecontrib.monitoring.keras import NeptuneMonitor
neptune.init(api_token='ANONYMOUS', project_qualified_name='my_workspace/my_project')
neptune.create_experiment('tensorflow-keras-quickstart')
x_train, x_test = ...
model = tf.keras.models.Sequential([
...
])
optimizer = tf.keras.optimizers.SGD(lr=0.005, momentum=0.4,)
model.compile(optimizer=optimizer,
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train,
epochs=5,
batch_size=64,
callbacks=[NeptuneMonitor()])
Check full code example:
Scikit-learn is an open source machine learning framework commonly used for building predictive models. Neptune helps with keeping track of model training metadata.
Example:
import neptune
from neptunecontrib.monitoring.sklearn import log_regressor_summary
neptune.init('my_workspace/my_project')
neptune.create_experiment(params=parameters,
name='regression-example',
tags=['RandomForestRegressor', 'regression'])
rfr = RandomForestRegressor(**parameters)
X, y = load_boston(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=28743)
rfr.fit(X_train, y_train)
log_regressor_summary(rfr, X_train, X_test, y_train, y_test)
Check full code example:
LightGBM is a popular gradient boosting library.
Example:
import lightgbm as lgb
import neptune
from neptunecontrib.monitoring.lightgbm import neptune_monitor
neptune.init('my_project/my_workspace')
neptune.create_experiment()
X_train, X_test, y_train, y_test = ...
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)
params = {'boosting_type': 'gbdt',
'objective': 'multiclass',
'num_class': 3,
'num_leaves': 31,
'learning_rate': 0.05,
'feature_fraction': 0.9
}
gbm = lgb.train(params,
lgb_train,
num_boost_round=500,
valid_sets=[lgb_train, lgb_eval],
valid_names=['train','valid'],
callbacks=[neptune_monitor()],
)
Check full code example:
Optuna is an open source hyperparameter optimization framework to automate hyperparameter search.
Example:
import neptune
import lightgbm as lgb
import optuna
import neptunecontrib.monitoring.optuna as opt_utils
def objective(trial):
data, target = load_breast_cancer(return_X_y=True)
train_x, test_x, train_y, test_y = train_test_split(data, target, test_size=0.25)
dtrain = lgb.Dataset(train_x, label=train_y)
param = {'verbose': -1,
'objective': 'binary',
'metric': 'binary_logloss',
'num_leaves': trial.suggest_int('num_leaves', 2, 256),
'feature_fraction': trial.suggest_uniform('feature_fraction', 0.2, 1.0),
'bagging_fraction': trial.suggest_uniform('bagging_fraction', 0.2, 1.0),
'min_child_samples': trial.suggest_int('min_child_samples', 3, 100)}
gbm = lgb.train(param, dtrain)
preds = gbm.predict(test_x)
accuracy = roc_auc_score(test_y, preds)
return accuracy
neptune.init('my_workspace/my_project')
neptune.create_experiment('optuna-sweep')
neptune_callback = opt_utils.NeptuneCallback()
study = optuna.create_study(direction='maximize')
study.optimize(objective, n_trials=100, callbacks=[neptune_callback])
Check full code example:
If you got stuck or simply want to talk to us about something here are your options:
- documentation,
- video tutorials,
- Chat! When in application click on the blue message icon in the bottom-right corner and send a message. A real person will talk to you ASAP (typically very ASAP),
- You can just shoot us an email at contact@neptune.ai.
Created with ❤️ by the Neptune.ai team:
Piotr, Michał, Jakub, Paulina, Kamil, Małgorzata, Piotr, Aleksandra, Marcin, Hubert, Adam, Szymon, Jakub, Maciej, Piotr, Paweł, Patrycja, Grzegorz, Paweł, Natalia, Marcin and you?