evaluation
s434749-evaluation/pipeline/head There was a failure building this commit Details
s434749-training/pipeline/head This commit looks good Details

This commit is contained in:
Alagris 2021-04-26 17:36:15 +02:00
parent 6853d49f20
commit 32d3679a52
3 changed files with 37 additions and 8 deletions

23
evaluation.Jenkinsfile Normal file
View File

@ -0,0 +1,23 @@
pipeline {
agent {
dockerfile true
}
stages {
stage('Build') {
steps {
git 'https://git.wmi.amu.edu.pl/s434749/ium_434749.git'
copyArtifacts fingerprintArtifacts: true, projectName: 's434749-training', selector: lastSuccessful()
sh 'python3 train_model.py eval'
}
post {
success {
def results = readFile "${env.WORKSPACE}/results.txt"
emailext body: 'Evaluation of CNN for english phonetic embeddings has finished successfully!\n'+results, subject: 's434749 evaluation finished', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
archiveArtifacts 'results.txt'
}
}
}
}
}

View File

@ -8,12 +8,13 @@ pipeline {
steps { steps {
git 'https://git.wmi.amu.edu.pl/s434749/ium_434749.git' git 'https://git.wmi.amu.edu.pl/s434749/ium_434749.git'
copyArtifacts fingerprintArtifacts: true, projectName: 's434749-create-dataset', selector: lastSuccessful() copyArtifacts fingerprintArtifacts: true, projectName: 's434749-create-dataset', selector: lastSuccessful()
sh 'python3 train_model.py' sh 'python3 train_model.py train'
} }
post { post {
success { success {
archiveArtifacts 'cnn.pth,results.txt' emailext body: 'Training of CNN for english phonetic embeddings has finished successfully', subject: 's434749 training finished', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
archiveArtifacts 'cnn.pth'
} }
} }
} }

View File

@ -13,6 +13,7 @@ from torch.utils.data import Dataset, DataLoader
import re import re
import random import random
import os import os
import sys
from tqdm import tqdm from tqdm import tqdm
from Levenshtein import distance as levenshtein_distance from Levenshtein import distance as levenshtein_distance
@ -167,16 +168,20 @@ def evaluate_monte_carlo(model, repeats):
outer_bar.update(1) outer_bar.update(1)
with open('results.txt', 'w+') as r: with open('results.txt', 'w+') as r:
print("Average estimation error " + str(diff.item() / i)) print("Average estimation error " + str(diff.item() / i))
r.write("Average estimation error " + str(diff.item() / i)+"\n") r.write("Average estimation error " + str(diff.item() / i) + "\n")
cnn = CNN(kernel_size=3, hidden_layers=14, channels=MAX_LEN, embedding_size=MAX_LEN).to(DEVICE) cnn = CNN(kernel_size=3, hidden_layers=14, channels=MAX_LEN, embedding_size=MAX_LEN).to(DEVICE)
if os.path.isfile('cnn.pth'): if os.path.isfile('cnn.pth'):
cnn.load_state_dict(torch.load('cnn.pth', map_location=torch.device('cpu'))) cnn.load_state_dict(torch.load('cnn.pth', map_location=torch.device('cpu')))
else: else:
train_model(cnn) if len(sys.argv) > 1 and sys.argv[1] == 'train':
torch.save(cnn.state_dict(), 'cnn.pth') train_model(cnn)
torch.save(cnn.state_dict(), 'cnn.pth')
else:
print("cnn.pth missing!")
exit(2)
cnn.eval() if len(sys.argv) > 1 and sys.argv[1] == 'eval':
print("Training finished! Starting evaluation!") cnn.eval()
evaluate_monte_carlo(cnn, 1) evaluate_monte_carlo(cnn, 1)