Dodanie 'training.py'
This commit is contained in:
parent
ac19da521a
commit
515272460e
50
training.py
Normal file
50
training.py
Normal file
@ -0,0 +1,50 @@
|
||||
import pandas
|
||||
import os
|
||||
from sacred import Experiment
|
||||
from sacred.observers import MongoObserver
|
||||
from sacred.observers import FileStorageObserver
|
||||
from keras.applications.densenet import layers
|
||||
import tensorflow
|
||||
import random
|
||||
|
||||
exint = Experiment('z-s434743-training')
|
||||
|
||||
exint.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017',
|
||||
db_name='sacred'))
|
||||
exint.observers.append(FileStorageObserver('z-s434743-training/master'))
|
||||
|
||||
@exint.config
|
||||
def my_config():
|
||||
EPOCHS = int(os.environ['EPOCHS'])
|
||||
|
||||
|
||||
@exint.main
|
||||
def my_main(EPOCHS, _run):
|
||||
_run.info["epochs"] = EPOCHS,
|
||||
normalize = layers.Normalization()
|
||||
train_data_x = pandas.read_csv('./X_train.csv')
|
||||
_run.info["data"] = train_data_x
|
||||
movies_all = train_data_x.copy()
|
||||
movies_predict = train_data_x.pop('audienceScore')
|
||||
normalize.adapt(movies_all)
|
||||
norm_movies_model = tensorflow.keras.Sequential([
|
||||
normalize,
|
||||
layers.Dense(64),
|
||||
layers.Dense(1)
|
||||
])
|
||||
norm_movies_model.compile(
|
||||
loss=tensorflow.keras.losses.MeanSquaredError(),
|
||||
optimizer=tensorflow.keras.optimizers.Adam())
|
||||
|
||||
norm_movies_model.fit(movies_all, movies_predict, epochs=EPOCHS)
|
||||
counter = 0
|
||||
while counter < 20:
|
||||
counter+=1
|
||||
value = counter * random.randint(5, 5000)
|
||||
_run.log_scalar("training.accuracy", value * 2)
|
||||
norm_movies_model.save('test')
|
||||
|
||||
exint.run()
|
||||
|
||||
exint.add_artifact('test/saved_model.pb')
|
||||
exint.add_source_file('./ium_z434743/train.py')
|
Loading…
Reference in New Issue
Block a user