Add sacred
This commit is contained in:
parent
8439d39d7b
commit
02fae476bf
@ -16,7 +16,8 @@ RUN pip3 install pandas
|
|||||||
RUN pip3 install seaborn
|
RUN pip3 install seaborn
|
||||||
RUN pip3 install matplotlib
|
RUN pip3 install matplotlib
|
||||||
RUN pip3 install --no-cache-dir tensorflow
|
RUN pip3 install --no-cache-dir tensorflow
|
||||||
|
RUN pip3 install sacred
|
||||||
|
RUN pip3 install pymongo
|
||||||
|
|
||||||
CMD ./run.sh
|
CMD ./run.sh
|
||||||
CMD ./run_training.sh
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Archive artifacts') {
|
stage('Archive artifacts') {
|
||||||
steps{
|
steps{
|
||||||
archiveArtifacts artifacts: 'model_movies.h5'
|
archiveArtifacts artifacts: 'model_movies.h5,my_runs/**'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,23 @@ from tensorflow import convert_to_tensor
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from sklearn.metrics import mean_squared_error
|
from sklearn.metrics import mean_squared_error
|
||||||
|
from sacred.observers import FileStorageObserver, MongoObserver
|
||||||
|
from sacred import Experiment
|
||||||
|
from sacred.observers import MongoObserver
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
ex = Experiment("434684", interactive=False, save_git_info=False)
|
||||||
|
ex.observers.append(MongoObserver(url='mongodb://mongo_user:mongo_password_IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||||
|
ex.observers.append(FileStorageObserver('my_runs'))
|
||||||
|
|
||||||
|
@ex.config
|
||||||
|
def my_config():
|
||||||
|
learning_rate = float(sys.argv[1])
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_train_model(learning_rate, _run):
|
||||||
|
_run.info["prepare_model"] = str(datetime.now())
|
||||||
|
|
||||||
movies_train = pd.read_csv('movies_train.csv')
|
movies_train = pd.read_csv('movies_train.csv')
|
||||||
|
|
||||||
@ -23,11 +40,22 @@ model.add(layers.Dense(1))
|
|||||||
|
|
||||||
model.compile(loss='mean_absolute_error', optimizer=Adam(learning_rate))
|
model.compile(loss='mean_absolute_error', optimizer=Adam(learning_rate))
|
||||||
|
|
||||||
model.fit(
|
_run.info["train model"] = str(datetime.now())
|
||||||
|
|
||||||
|
history = model.fit(
|
||||||
x = convert_to_tensor(x_train, np.float32),
|
x = convert_to_tensor(x_train, np.float32),
|
||||||
y = y_train,
|
y = y_train,
|
||||||
verbose=0, epochs=99)
|
verbose=0, epochs=99)
|
||||||
|
|
||||||
|
loss = history.history['loss'][-1]
|
||||||
|
_run.info["Loss"] = str(loss)
|
||||||
model.save('model_movies.h5')
|
model.save('model_movies.h5')
|
||||||
|
|
||||||
|
|
||||||
|
@ex.main
|
||||||
|
def my_main(learning_rate):
|
||||||
|
print(prepare_train_model())
|
||||||
|
|
||||||
|
|
||||||
|
r = ex.run()
|
||||||
|
ex.add_artifact("model_movies.h5")
|
||||||
|
Loading…
Reference in New Issue
Block a user