s
This commit is contained in:
parent
d1d20f6968
commit
e089fb1453
31
evaluate.py
31
evaluate.py
@ -1,18 +1,3 @@
|
||||
from sacred import Experiment
|
||||
from sacred.observers import MongoObserver, FileStorageObserver
|
||||
|
||||
ex = Experiment('s487187-evaluate', interactive=True)
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
model_path = 'model.h5'
|
||||
test_data_path = 'data.csv'
|
||||
metrics_file_path = 'metrics.txt'
|
||||
plot_path = 'plot.png'
|
||||
|
||||
@ex.capture
|
||||
def evaluate_model(model_path, test_data_path, metrics_file_path, plot_path):
|
||||
import tensorflow as tf
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
@ -20,6 +5,12 @@ def evaluate_model(model_path, test_data_path, metrics_file_path, plot_path):
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
|
||||
|
||||
model_path = 'model.h5'
|
||||
test_data_path = 'data.csv'
|
||||
metrics_file_path = 'metrics.txt'
|
||||
plot_path = 'plot.png'
|
||||
|
||||
model = tf.keras.models.load_model(model_path)
|
||||
|
||||
test_data = pd.read_csv(test_data_path, sep=';')
|
||||
@ -55,13 +46,3 @@ def evaluate_model(model_path, test_data_path, metrics_file_path, plot_path):
|
||||
plt.plot(metrics_df['top_5_accuracy'], label='Top-5 Accuracy')
|
||||
plt.legend()
|
||||
plt.savefig(plot_path)
|
||||
|
||||
ex.log_scalar('top_1_accuracy', np.mean(top_1_accuracy.numpy()))
|
||||
ex.log_scalar('top_5_accuracy', np.mean(top_5_accuracy.numpy()))
|
||||
ex.add_artifact(model_path)
|
||||
ex.add_artifact(metrics_file_path)
|
||||
ex.add_artifact(plot_path)
|
||||
|
||||
@ex.automain
|
||||
def main():
|
||||
evaluate_model()
|
||||
|
4
train.py
4
train.py
@ -1,7 +1,7 @@
|
||||
from sacred import Experiment
|
||||
from sacred.observers import MongoObserver, FileStorageObserver
|
||||
|
||||
ex = Experiment('s487187-training')
|
||||
ex = Experiment('s487187-training', interactive=True)
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
@ex.config
|
||||
@ -65,3 +65,5 @@ def run_experiment():
|
||||
accuracy = train_model()
|
||||
ex.log_scalar('accuracy', accuracy)
|
||||
ex.add_artifact('model.h5')
|
||||
|
||||
ex.run()
|
Loading…
Reference in New Issue
Block a user