From f6c7f5981ef13d657b31e2c0535c84edc002ae36 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 4 May 2024 11:41:45 +0200 Subject: [PATCH] IUM_06 --- Jenkinsfile | 8 ++++---- train_model.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 893d1fc..6c12bd5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { dockerfile true } - + triggers { upstream(upstreamProjects: 'z-s464913-create-dataset', threshold: hudson.model.Result.SUCCESS) } @@ -13,8 +13,8 @@ pipeline { description: 'Which build to use for copying artifacts', name: 'BUILD_SELECTOR' ) - string(name: 'learning_rate', defaultValue: '0.001', description: 'Learning rate') - string(name: 'epochs', defaultValue: '5', description: 'Number of epochs') + string(name: 'LEARNING_RATE', defaultValue: '0.001', description: 'Learning rate') + string(name: 'EPOCHS', defaultValue: '5', description: 'Number of epochs') } stages { @@ -33,7 +33,7 @@ pipeline { stage('Run train_model script') { steps { sh 'chmod +x train_model.py' - sh 'python3 ./train_model.py' + sh 'python3 ./train_model.py ${params.LEARNING_RATE} ${params.EPOCHS}' } } diff --git a/train_model.py b/train_model.py index 6706bdc..f76c10a 100644 --- a/train_model.py +++ b/train_model.py @@ -6,6 +6,7 @@ from keras.models import Sequential from keras.layers import BatchNormalization, Dropout, Dense, Flatten, Conv1D from keras.optimizers import Adam import pandas as pd +import sys def main(): @@ -22,6 +23,9 @@ def main(): X_train = X_train.reshape(X_train.shape[0], X_train.shape[1], 1) X_val = X_val.reshape(X_val.shape[0], X_val.shape[1], 1) + learning_rate = float(sys.argv[1]) + epochs = int(sys.argv[2]) + model = Sequential( [ Conv1D(32, 2, activation="relu", input_shape=X_train[0].shape), @@ -38,7 +42,7 @@ def main(): ) model.compile( - optimizer=Adam(learning_rate=1e-3), + optimizer=Adam(learning_rate=learning_rate), loss="binary_crossentropy", metrics=["accuracy"], ) @@ -47,7 +51,7 @@ def main(): X_train, y_train, validation_data=(X_val, y_val), - epochs=5, + epochs=epochs, verbose=1, )