-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainerthread.cpp
More file actions
37 lines (34 loc) · 1.55 KB
/
trainerthread.cpp
File metadata and controls
37 lines (34 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "trainerthread.h"
TrainerThread::TrainerThread()
{
trainer = QSharedPointer <NodeTrainer> (new NodeTrainer());
connect(&*trainer, SIGNAL(echo(QString)), this, SLOT(echoSlot(QString)));
connect(&*trainer, SIGNAL(error(QString)), this, SLOT(errorSlot(QString)));
// wtf ^
}
void TrainerThread::run()
{
if(trainer->loadClassNames(classFileName))
{
if(trainer->loadData(dataFileName))
{
trainer->initWeights();
fann_type mse = trainer->trainNodes();
emit echoSignal("Закончено обучение нейронных сетей (" + QDateTime::currentDateTime().time().toString("HH:mm:ss") + "), MSE: " + QString::number(mse));
if(mse > 1e-2f)
emit error("Ошибка сети слишком высокая, точность работы не гарантируется!");
if(trainer->saveNetworks())
{
if(trainer->saveXML())
{
emit echoSignal("Файлы классификатора сохранены. \r\n");
emit resultReady(mse);
}
else emit error("Ошибка сохранения файла конфигурации.");
}
else emit error("Ошибка сохранения нейронных сетей.");
}
else emit error("Ошибка загрузки файла данных.");
}
else emit error("Ошибка загрузки файла названий классов.");
}