archive model
All checks were successful
s444452-training/pipeline/head This commit looks good

This commit is contained in:
AdamOsiowy123 2022-05-02 19:21:28 +02:00
parent 02a091883a
commit 6bb9783533
2 changed files with 6 additions and 4 deletions

View File

@ -24,7 +24,7 @@ node {
} }
} }
stage('Archive artifacts') { stage('Archive artifacts') {
archiveArtifacts "neural_network_evaluation.txt, neural_network_model" archiveArtifacts "neural_network_evaluation.txt, model/**"
} }
} }
} }

View File

@ -1,4 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import datetime
import os import os
import pprint import pprint
import sys import sys
@ -40,8 +41,9 @@ def load_trained_model(abs_path, model_name):
return load_model(os.path.join(abs_path, model_name)) return load_model(os.path.join(abs_path, model_name))
def save_model(model, abs_path, model_name): def save_model(model):
model.save(os.path.join(abs_path, model_name), save_format='h5') model_name = 'neural_net_' + datetime.datetime.today().strftime('%d-%b-%Y-%H:%M:%S')
model.save(os.path.join(os.getcwd(), 'model', model_name), save_format='h5', overwrite=True)
def train_model(model, x_train, y_train): def train_model(model, x_train, y_train):
@ -82,7 +84,7 @@ def main():
x_train, x_test, vocab_size = tokenize(pd.concat([x_train, x_test]), x_train, x_test, 100) x_train, x_test, vocab_size = tokenize(pd.concat([x_train, x_test]), x_train, x_test, 100)
model = get_model(50, vocab_size) model = get_model(50, vocab_size)
train_model(model, x_train, y_train) train_model(model, x_train, y_train)
save_model(model, abs_data_path, 'neural_network_model') save_model(model)
evaluate_and_save(model, x_test, y_test, abs_data_path) evaluate_and_save(model, x_test, y_test, abs_data_path)