working on lab8
Some checks failed
s449288-training/pipeline/head There was a failure building this commit
Some checks failed
s449288-training/pipeline/head There was a failure building this commit
This commit is contained in:
parent
d1e9d6235f
commit
97f05db3b9
Binary file not shown.
@ -21,11 +21,9 @@ pipeline {
|
||||
sh 'tar -czf lego_reg_model.tar.gz lego_reg_model/'
|
||||
archiveArtifacts 'lego_reg_model.tar.gz'
|
||||
echo 'Model archived'
|
||||
echo 'Archiving Sacreds output repo...'
|
||||
sh 'ls -lh runs/*/'
|
||||
sh 'tar -czf sacred_runs.tar.gz runs/'
|
||||
archiveArtifacts 'sacred_runs.tar.gz'
|
||||
echo 'Sacreds repo archived'
|
||||
echo 'Archiving the MLflow repo...'
|
||||
archiveArtifacts 'mlruns'
|
||||
echo 'MLflow repo archived'
|
||||
echo 'Launching the s449288-evaluation job...'
|
||||
build job: 's449288-evaluation/master/'
|
||||
}
|
||||
|
@ -1 +1,14 @@
|
||||
|
||||
name lego_sets
|
||||
|
||||
docker_env:
|
||||
image: s449288/ium:lab8
|
||||
|
||||
entry_points:
|
||||
main:
|
||||
parameters:
|
||||
epochs: {type: float, default: 100}
|
||||
units: {type: float, default: 1}
|
||||
learning_rate: {type: float, default: 0.1}
|
||||
command: python3 simple_regression_lab8.py {epochs} {units} {learning_rate}
|
||||
test:
|
||||
command: python3 evaluate.py
|
||||
|
@ -4,37 +4,22 @@ from keras.models import save_model
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
from sacred.observers import MongoObserver
|
||||
import mlflow
|
||||
import mlflow.keras
|
||||
from urllib.parse import urlparse
|
||||
|
||||
# Konfiguracja serwera i nazwy eksperymentu MLflow
|
||||
#mlflow.set_tracking_uri('http://tzietkiewicz.vm.wmi.amu.edu.pl:5000')
|
||||
mlflow.set_experiment('s449288')
|
||||
|
||||
# Stworzenie obiektu klasy Experiment do śledzenia przebiegu regresji narzędziem Sacred
|
||||
ex = Experiment(save_git_info=False)
|
||||
|
||||
# Dodanie obserwatora FileObserver
|
||||
ex.observers.append(FileStorageObserver('runs'))
|
||||
|
||||
#Dodanie obserwatora Mongo
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
# Przykładowa modyfikowalna z Sacred konfiguracja wybranych parametrów treningu
|
||||
@ex.config
|
||||
def config():
|
||||
epochs = 100
|
||||
units = 1
|
||||
learning_rate = 0.1
|
||||
import sys
|
||||
|
||||
|
||||
# Reszta kodu wrzucona do udekorowanej funkcji train do wywołania przez Sacred, żeby coś było capture'owane
|
||||
@ex.capture
|
||||
def train(epochs, units, learning_rate, _run):
|
||||
def train():
|
||||
|
||||
# Definicja wartości parametrów treningu
|
||||
epochs = int(sys.argv[1]) if len(sys.argv) > 1 else 100
|
||||
units = int(sys.argv[2]) if len(sys.argv) > 2 else 1
|
||||
learning_rate = float(sys.argv[3]) if len(sys.argv) > 3 else 0.1
|
||||
|
||||
# Konfiguracja serwera i nazwy eksperymentu MLflow
|
||||
# mlflow.set_tracking_uri("http://172.17.0.1:5000")
|
||||
mlflow.set_experiment('s449288')
|
||||
|
||||
# Podpięcie treningu do MLflow
|
||||
with mlflow.start_run() as run:
|
||||
@ -81,17 +66,12 @@ def train(epochs, units, learning_rate, _run):
|
||||
|
||||
# Zapis predykcji do pliku
|
||||
results = pd.DataFrame(
|
||||
{'test_set_piece_count': test_piece_counts.tolist(), 'predicted_price': [round(a[0], 2) for a in y_pred.tolist()]})
|
||||
{'test_set_piece_count': test_piece_counts.tolist(),
|
||||
'predicted_price': [round(a[0], 2) for a in y_pred.tolist()]})
|
||||
results.to_csv('lego_reg_results.csv', index=False, header=True)
|
||||
|
||||
# Zapis modelu do pliku standardowo poprzez metodę kerasa i poprzez metodę obiektu Experiment z Sacred
|
||||
# Zapis modelu do pliku
|
||||
model.save('lego_reg_model')
|
||||
ex.add_artifact('lego_reg_model/saved_model.pb')
|
||||
|
||||
# Przykładowo zwracamy loss ostatniej epoki w charakterze wyników, żeby było widoczne w plikach zapisanych przez obserwator
|
||||
hist = pd.DataFrame(history.history)
|
||||
hist['epoch'] = history.epoch
|
||||
_run.log_scalar('final.training.loss', hist['loss'].iloc[-1])
|
||||
|
||||
# Ewaluacja MAE na potrzeby MLflow (kopia z evaluate.py)
|
||||
mae = model.evaluate(
|
||||
@ -109,11 +89,10 @@ def train(epochs, units, learning_rate, _run):
|
||||
tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
|
||||
if tracking_url_type_store != 'file':
|
||||
mlflow.keras.log_model(model, 'lego-model', registered_model_name='TFLegoModel',
|
||||
signature=signature)
|
||||
signature=signature)
|
||||
else:
|
||||
mlflow.keras.log_model(model, 'model', signature=signature, input_example=500)
|
||||
mlflow.keras.log_model(model, 'model', signature=signature, input_example=np.array(500))
|
||||
|
||||
|
||||
@ex.automain
|
||||
def main(epochs, units, learning_rate):
|
||||
if __name__ == '__main__':
|
||||
train()
|
||||
|
@ -4,37 +4,22 @@ from keras.models import save_model
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sacred import Experiment
|
||||
from sacred.observers import FileStorageObserver
|
||||
from sacred.observers import MongoObserver
|
||||
import mlflow
|
||||
import mlflow.keras
|
||||
from urllib.parse import urlparse
|
||||
|
||||
# Konfiguracja serwera i nazwy eksperymentu MLflow
|
||||
#mlflow.set_tracking_uri("http://172.17.0.1:5000")
|
||||
mlflow.set_experiment('s449288')
|
||||
|
||||
# Stworzenie obiektu klasy Experiment do śledzenia przebiegu regresji narzędziem Sacred
|
||||
ex = Experiment(save_git_info=False)
|
||||
|
||||
# Dodanie obserwatora FileObserver
|
||||
ex.observers.append(FileStorageObserver('runs'))
|
||||
|
||||
#Dodanie obserwatora Mongo
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
# Przykładowa modyfikowalna z Sacred konfiguracja wybranych parametrów treningu
|
||||
@ex.config
|
||||
def config():
|
||||
epochs = 100
|
||||
units = 1
|
||||
learning_rate = 0.1
|
||||
import sys
|
||||
|
||||
|
||||
# Reszta kodu wrzucona do udekorowanej funkcji train do wywołania przez Sacred, żeby coś było capture'owane
|
||||
@ex.capture
|
||||
def train(epochs, units, learning_rate, _run):
|
||||
def train():
|
||||
|
||||
# Definicja wartości parametrów treningu
|
||||
epochs = int(sys.argv[1]) if len(sys.argv) > 1 else 100
|
||||
units = int(sys.argv[2]) if len(sys.argv) > 2 else 1
|
||||
learning_rate = float(sys.argv[3]) if len(sys.argv) > 3 else 0.1
|
||||
|
||||
# Konfiguracja serwera i nazwy eksperymentu MLflow
|
||||
# mlflow.set_tracking_uri("http://172.17.0.1:5000")
|
||||
mlflow.set_experiment('s449288')
|
||||
|
||||
# Podpięcie treningu do MLflow
|
||||
with mlflow.start_run() as run:
|
||||
@ -81,17 +66,12 @@ def train(epochs, units, learning_rate, _run):
|
||||
|
||||
# Zapis predykcji do pliku
|
||||
results = pd.DataFrame(
|
||||
{'test_set_piece_count': test_piece_counts.tolist(), 'predicted_price': [round(a[0], 2) for a in y_pred.tolist()]})
|
||||
{'test_set_piece_count': test_piece_counts.tolist(),
|
||||
'predicted_price': [round(a[0], 2) for a in y_pred.tolist()]})
|
||||
results.to_csv('lego_reg_results.csv', index=False, header=True)
|
||||
|
||||
# Zapis modelu do pliku standardowo poprzez metodę kerasa i poprzez metodę obiektu Experiment z Sacred
|
||||
# Zapis modelu do pliku
|
||||
model.save('lego_reg_model')
|
||||
ex.add_artifact('lego_reg_model/saved_model.pb')
|
||||
|
||||
# Przykładowo zwracamy loss ostatniej epoki w charakterze wyników, żeby było widoczne w plikach zapisanych przez obserwator
|
||||
hist = pd.DataFrame(history.history)
|
||||
hist['epoch'] = history.epoch
|
||||
_run.log_scalar('final.training.loss', hist['loss'].iloc[-1])
|
||||
|
||||
# Ewaluacja MAE na potrzeby MLflow (kopia z evaluate.py)
|
||||
mae = model.evaluate(
|
||||
@ -109,11 +89,10 @@ def train(epochs, units, learning_rate, _run):
|
||||
tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
|
||||
if tracking_url_type_store != 'file':
|
||||
mlflow.keras.log_model(model, 'lego-model', registered_model_name='TFLegoModel',
|
||||
signature=signature)
|
||||
signature=signature)
|
||||
else:
|
||||
mlflow.keras.log_model(model, 'model', signature=signature, input_example=np.array(500))
|
||||
|
||||
|
||||
@ex.automain
|
||||
def main(epochs, units, learning_rate):
|
||||
if __name__ == '__main__':
|
||||
train()
|
||||
|
Loading…
Reference in New Issue
Block a user