mlflow save model

This commit is contained in:
jakubknczny 2021-05-21 16:26:48 +02:00
parent 01e186e8a4
commit e819ccf084
2 changed files with 6 additions and 0 deletions

View File

@ -46,6 +46,7 @@ pipeline {
steps {
archiveArtifacts 'grid-stability-dense.h5'
archiveArtifacts 'my_runs/**'
archiveArtifacts 'grid-stability-dense/**'
}
}
}

View File

@ -1,5 +1,6 @@
from datetime import datetime
import mlflow
from mlflow.models.signature import infer_signature
import pandas as pd
from sacred import Experiment
from sacred.observers import FileStorageObserver, MongoObserver
@ -47,6 +48,10 @@ def prepare_train_model(learning_rate, _run):
history = model.fit(X_train, Y_train, epochs=2, validation_data=(X_valid, Y_valid))
model.save('grid-stability-dense.h5')
mlflow.keras.save_model(keras_model=model,
path='grid-stability-dense',
signature=infer_signature(X_train, Y_train),
input_example=X_train.iloc[0])
_run.info['history'] = str(history.history['loss'][-1])
mlflow.log_metric('loss', history.history['loss'][-1])