evaluation
This commit is contained in:
parent
6853d49f20
commit
32d3679a52
23
evaluation.Jenkinsfile
Normal file
23
evaluation.Jenkinsfile
Normal 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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
@ -167,16 +168,20 @@ def evaluate_monte_carlo(model, repeats):
|
||||
outer_bar.update(1)
|
||||
with open('results.txt', 'w+') as r:
|
||||
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)
|
||||
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)
|
||||
|
||||
cnn.eval()
|
||||
print("Training finished! Starting evaluation!")
|
||||
evaluate_monte_carlo(cnn, 1)
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'eval':
|
||||
cnn.eval()
|
||||
evaluate_monte_carlo(cnn, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user