ium_z434686/train.py

44 lines
1.3 KiB
Python
Raw Normal View History

2023-05-10 20:30:03 +02:00
import pandas
import os
2023-05-11 21:24:52 +02:00
from sacred import Experiment
from sacred.observers import MongoObserver
from sacred.observers import FileStorageObserver
2023-05-10 20:30:03 +02:00
from keras.applications.densenet import layers
import tensorflow
2023-05-11 21:24:52 +02:00
exint = Experiment('z-s434686-training')
exint.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017',
db_name='sacred'))
exint.observers.append(FileStorageObserver('my_runs'))
@exint.config
def my_config():
EPOCHS = int(os.environ['EPOCHS'])
2023-05-11 21:32:10 +02:00
2023-05-11 21:24:52 +02:00
@exint.main
2023-05-11 21:36:27 +02:00
def my_main(EPOCHS, _run):
2023-05-11 21:32:10 +02:00
_run.info["epochs"] = EPOCHS
2023-05-11 21:30:50 +02:00
normalize = layers.Normalization()
2023-05-11 21:33:24 +02:00
train_data_x = exint.open_resource('./X_train.csv', 'r')
2023-05-11 21:29:38 +02:00
games_all = train_data_x.copy()
games_predict = train_data_x.pop('User_Score')
2023-05-11 21:24:52 +02:00
normalize.adapt(games_all)
norm_games_model = tensorflow.keras.Sequential([
normalize,
layers.Dense(64),
layers.Dense(1)
])
norm_games_model.compile(
loss=tensorflow.keras.losses.MeanSquaredError(),
optimizer=tensorflow.keras.optimizers.Adam())
norm_games_model.fit(games_all, games_predict, epochs=EPOCHS)
norm_games_model.save('test')
print(f'done:')
exint.run()
exint.add_artifact("test")
exint.add_source_file('train.py')