Update 'train.py'
This commit is contained in:
parent
02ca9f72b1
commit
457379e45a
45
train.py
45
train.py
@ -1,31 +1,44 @@
|
||||
import pandas
|
||||
import os
|
||||
|
||||
from sacred import Experiment
|
||||
from sacred.observers import MongoObserver
|
||||
from sacred.observers import FileStorageObserver
|
||||
from keras.applications.densenet import layers
|
||||
|
||||
from sklearn.model_selection import train_test_split
|
||||
import tensorflow
|
||||
|
||||
EPOCHS = int(os.environ['EPOCHS'])
|
||||
exint = Experiment('z-s434686-training')
|
||||
|
||||
train_data_x = pandas.read_csv('./X_train.csv')
|
||||
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'])
|
||||
train_data_x = exint.open_resource('./X_train.csv', 'r')
|
||||
games_all = train_data_x.copy()
|
||||
games_predict = train_data_x.pop('User_Score')
|
||||
normalize = layers.Normalization()
|
||||
_run.info["epochs"] = EPOCHS
|
||||
|
||||
|
||||
games_all = train_data_x.copy()
|
||||
games_predict = train_data_x.pop('User_Score')
|
||||
normalize = layers.Normalization()
|
||||
normalize.adapt(games_all)
|
||||
|
||||
norm_games_model = tensorflow.keras.Sequential([
|
||||
@exint.main
|
||||
def my_main(EPOCHS, games_all, games_predict,normalize):
|
||||
_run.info["prepare_message_ts"] = str(datetime.now())
|
||||
normalize.adapt(games_all)
|
||||
norm_games_model = tensorflow.keras.Sequential([
|
||||
normalize,
|
||||
layers.Dense(64),
|
||||
layers.Dense(1)
|
||||
])
|
||||
|
||||
norm_games_model.compile(
|
||||
])
|
||||
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.fit(games_all, games_predict, epochs=EPOCHS)
|
||||
|
||||
norm_games_model.save('test')
|
||||
norm_games_model.save('test')
|
||||
print(f'done:')
|
||||
|
||||
exint.run()
|
||||
exint.add_artifact("test")
|
||||
exint.add_source_file('train.py')
|
||||
|
Loading…
Reference in New Issue
Block a user