new Jenkins try

This commit is contained in:
Kamila 2022-05-03 11:09:00 +02:00
parent 44e58f3583
commit 7075223969
2 changed files with 39 additions and 3 deletions

35
Jenkinsfile_train Normal file
View File

@ -0,0 +1,35 @@
pipeline {
agent {
dockerfile true
}
parameters {
epochs(
defaultValue: '200',
description: 'number of epochs',
name: 'EPOCH'
)
}
stages {
stage('Stage 1') {
steps {
echo 'Hello world!'
}
}
stage('Copy from different Pipeline') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's444517-create-dataset', selector: lastSuccessful()
}
}
stage('Get data save artifacts') {
steps {
sh 'python3 ./nn_train.py $EPOCH'
archiveArtifacts artifacts: 'my_model/saved_model.pb'
}
}
}
}

View File

@ -1,6 +1,7 @@
import pandas as pd
import numpy as np
import sys
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
@ -52,13 +53,13 @@ model = Sequential()
model.add(Dense(number_of_classes, activation='relu'))
model.add(Dense(number_of_classes, activation='softmax',input_dim=number_of_features))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy', 'categorical_accuracy'])
model.fit(x_train_set, dummy_y, epochs=200, validation_data=(x_validate_set, dummy_yv))
#model.save("my_model/")
model.fit(x_train_set, dummy_y, epochs=int(sys.argv[1]), validation_data=(x_validate_set, dummy_yv))
model.save("my_model/")
#model predictions
#model = keras.models.load_model('my_model')
yhat = model.predict(x_test_set)
f = open("results.txt", "w")
for numerator, single_pred in enumerate(yhat):
f.write(f"PREDICTED: {sorted(y_class_names)[np.argmax(single_pred)]}, ACTUAL: {y_test_set[numerator]} {sorted(y_class_names)[np.argmax(single_pred)] == y_test_set[numerator]}\n")
f.write(f"{sorted(y_class_names)[np.argmax(single_pred)]},{y_test_set[numerator]}\n")
f.close()