add training

This commit is contained in:
jakubknczny 2021-05-15 17:34:13 +02:00
parent 448e9612ea
commit 6467019d8d
4 changed files with 57 additions and 5 deletions

View File

@ -18,6 +18,8 @@ The container downloads the dataset and installs software needed,
then trains and evaluates model on the dataset. then trains and evaluates model on the dataset.
Loss and accuracy are saved to test_eval.txt file. Loss and accuracy are saved to test_eval.txt file.
### Zadanie 6
added create, train, eval directories in lab5
ium01.ipynb is a notebook used to develop previously mentioned scripts. ium01.ipynb is a notebook used to develop previously mentioned scripts.

49
lab5/train/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,49 @@
pipeline {
agent none
stages {
stage('copy files') {
agent any
steps {
sh '''
cp ./lab5/train/script.sh .
cp ./lab5/train/train.py .
cp ./lab5/train/requirements.txt .
'''
}
}
stage('docker') {
agent {
dockerfile true
parameters {
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR')
string(name: 'LEARNING_RATE', defaultValue: '0.0003', description: 'learning rate')
}
}
stages {
stage('copyArtifacts') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's434684-create-dataset', selector: buildParameter('BUILD_SELECTOR')
}
}
stage('ls') {
steps {
sh '''
chmod +x script.sh
./script.sh
ls -lah
'''
}
}
stage('archive artifact') {
steps {
archiveArtifacts 'grid-stability-dense.h5'
}
}
}
}
}
}

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
python3 train.py python3 train.py "$1"

View File

@ -1,4 +1,6 @@
import numpy as np
import pandas as pd import pandas as pd
import sys
import tensorflow as tf import tensorflow as tf
from tensorflow.keras import layers from tensorflow.keras import layers
@ -24,12 +26,11 @@ model = tf.keras.Sequential([
model.compile( model.compile(
loss=tf.losses.BinaryCrossentropy(), loss=tf.losses.BinaryCrossentropy(),
optimizer=tf.optimizers.Adam(), optimizer=tf.optimizers.Adam(lr=float(sys.argv[1])),
metrics=[tf.keras.metrics.BinaryAccuracy()]) metrics=[tf.keras.metrics.BinaryAccuracy()])
history = model.fit(tf.convert_to_tensor(X_train, np.float32), history = model.fit(tf.convert_to_tensor(X_train, np.float32),
Y_train, epochs=2, validation_data=(X_valid, Y_valid)) Y_train, epochs=2, validation_data=(X_valid, Y_valid))
model.save('grid-stability-dense.h5') model.save('grid-stability-dense.h5')