s
This commit is contained in:
parent
134226fa79
commit
44a4f174c0
28
train.py
28
train.py
@ -1,13 +1,13 @@
|
||||
from sacred import Experiment
|
||||
from sacred.observers import MongoObserver, FileStorageObserver
|
||||
|
||||
# ex = Experiment('s487187-training')
|
||||
# ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
# ex.observers.append(FileStorageObserver('results'))
|
||||
# ex.use_git = False
|
||||
ex = Experiment('s487187-training')
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
ex.observers.append(FileStorageObserver('results'))
|
||||
ex.use_git = False
|
||||
|
||||
# @ex.config
|
||||
# def my_config():
|
||||
@ex.config
|
||||
def my_config():
|
||||
data_file = 'data.csv'
|
||||
model_file = 'model.h5'
|
||||
epochs = 10
|
||||
@ -15,8 +15,8 @@ batch_size = 32
|
||||
test_size = 0.2
|
||||
random_state = 42
|
||||
|
||||
# @ex.capture
|
||||
# def train_model(data_file, model_file, epochs, batch_size, test_size, random_state):
|
||||
@ex.capture
|
||||
def train_model(data_file, model_file, epochs, batch_size, test_size, random_state):
|
||||
import pandas as pd
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.preprocessing import MinMaxScaler
|
||||
@ -60,10 +60,10 @@ print('Test accuracy:', accuracy)
|
||||
|
||||
model.save(model_file)
|
||||
|
||||
# return accuracy
|
||||
return accuracy
|
||||
|
||||
# @ex.main
|
||||
# def run_experiment():
|
||||
# accuracy = train_model()
|
||||
# ex.log_scalar('accuracy', accuracy)
|
||||
# ex.add_artifact('model.h5')
|
||||
@ex.main
|
||||
def run_experiment():
|
||||
accuracy = train_model()
|
||||
ex.log_scalar('accuracy', accuracy)
|
||||
ex.add_artifact('model.h5')
|
||||
|
Loading…
Reference in New Issue
Block a user