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

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 {
git 'https://git.wmi.amu.edu.pl/s434749/ium_434749.git'
copyArtifacts fingerprintArtifacts: true, projectName: 's434749-create-dataset', selector: lastSuccessful()
sh 'python3 train_model.py'
sh 'python3 train_model.py train'
}
post {
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 random
import os
import sys
from tqdm import tqdm
from Levenshtein import distance as levenshtein_distance
@ -174,9 +175,13 @@ cnn = CNN(kernel_size=3, hidden_layers=14, channels=MAX_LEN, embedding_size=MAX_
if os.path.isfile('cnn.pth'):
cnn.load_state_dict(torch.load('cnn.pth', map_location=torch.device('cpu')))
else:
if len(sys.argv) > 1 and sys.argv[1] == 'train':
train_model(cnn)
torch.save(cnn.state_dict(), 'cnn.pth')
else:
print("cnn.pth missing!")
exit(2)
if len(sys.argv) > 1 and sys.argv[1] == 'eval':
cnn.eval()
print("Training finished! Starting evaluation!")
evaluate_monte_carlo(cnn, 1)