Commit 93733b790109f861511daad65de37b64d93772f1
1 parent
03fe9a28
More verbose output in training
Also address an issue with retraining algorithms, using pre-trained submodules
Showing
1 changed file
with
18 additions
and
12 deletions
openbr/plugins/meta.cpp
| @@ -96,17 +96,15 @@ class PipeTransform : public CompositeTransform | @@ -96,17 +96,15 @@ class PipeTransform : public CompositeTransform | ||
| 96 | 96 | ||
| 97 | int i = 0; | 97 | int i = 0; |
| 98 | while (i < transforms.size()) { | 98 | while (i < transforms.size()) { |
| 99 | - fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName())); | ||
| 100 | - | ||
| 101 | // Conditional statement covers likely case that first transform is untrainable | 99 | // Conditional statement covers likely case that first transform is untrainable |
| 102 | if (transforms[i]->trainable) { | 100 | if (transforms[i]->trainable) { |
| 103 | - fprintf(stderr, " training..."); | 101 | + qDebug() << "Training " << transforms[i]->description() << "\n..."; |
| 104 | transforms[i]->train(dataLines); | 102 | transforms[i]->train(dataLines); |
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | // if the transform is time varying, we can't project it in parallel | 105 | // if the transform is time varying, we can't project it in parallel |
| 108 | if (transforms[i]->timeVarying()) { | 106 | if (transforms[i]->timeVarying()) { |
| 109 | - fprintf(stderr, "\n%s projecting...", qPrintable(transforms[i]->objectName())); | 107 | + qDebug() << "Projecting " << transforms[i]->description() << "\n..."; |
| 110 | for (int j=0; j < dataLines.size();j++) { | 108 | for (int j=0; j < dataLines.size();j++) { |
| 111 | TemplateList junk; | 109 | TemplateList junk; |
| 112 | splitFTEs(dataLines[j], junk); | 110 | splitFTEs(dataLines[j], junk); |
| @@ -132,7 +130,16 @@ class PipeTransform : public CompositeTransform | @@ -132,7 +130,16 @@ class PipeTransform : public CompositeTransform | ||
| 132 | !transforms[nextTrainableTransform]->timeVarying()) | 130 | !transforms[nextTrainableTransform]->timeVarying()) |
| 133 | nextTrainableTransform++; | 131 | nextTrainableTransform++; |
| 134 | 132 | ||
| 135 | - fprintf(stderr, " projecting..."); | 133 | + // No more trainable transforms? Don't need any more projects then |
| 134 | + if (nextTrainableTransform == transforms.size()) | ||
| 135 | + break; | ||
| 136 | + | ||
| 137 | + fprintf(stderr, "Projecting %s", qPrintable(transforms[i]->description())); | ||
| 138 | + for (int j=i+1; j < nextTrainableTransform; j++) | ||
| 139 | + fprintf(stderr,"+%s", qPrintable(transforms[j]->description())); | ||
| 140 | + fprintf(stderr, "\n...\n"); | ||
| 141 | + fflush(stderr); | ||
| 142 | + | ||
| 136 | QFutureSynchronizer<void> futures; | 143 | QFutureSynchronizer<void> futures; |
| 137 | for (int j=0; j < dataLines.size(); j++) | 144 | for (int j=0; j < dataLines.size(); j++) |
| 138 | futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &dataLines[j], i, nextTrainableTransform)); | 145 | futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &dataLines[j], i, nextTrainableTransform)); |
| @@ -512,7 +519,6 @@ class LoadStoreTransform : public MetaTransform | @@ -512,7 +519,6 @@ class LoadStoreTransform : public MetaTransform | ||
| 512 | 519 | ||
| 513 | public: | 520 | public: |
| 514 | Transform *transform; | 521 | Transform *transform; |
| 515 | - QString baseName; | ||
| 516 | 522 | ||
| 517 | LoadStoreTransform() : transform(NULL) {} | 523 | LoadStoreTransform() : transform(NULL) {} |
| 518 | 524 | ||
| @@ -542,8 +548,8 @@ private: | @@ -542,8 +548,8 @@ private: | ||
| 542 | void init() | 548 | void init() |
| 543 | { | 549 | { |
| 544 | if (transform != NULL) return; | 550 | if (transform != NULL) return; |
| 545 | - if (fileName.isEmpty()) baseName = QRegExp("^[_a-zA-Z0-9]+$").exactMatch(transformString) ? transformString : QtUtils::shortTextHash(transformString); | ||
| 546 | - else baseName = fileName; | 551 | + if (fileName.isEmpty()) fileName = QRegExp("^[_a-zA-Z0-9]+$").exactMatch(transformString) ? transformString : QtUtils::shortTextHash(transformString); |
| 552 | + | ||
| 547 | if (!tryLoad()) | 553 | if (!tryLoad()) |
| 548 | transform = make(transformString); | 554 | transform = make(transformString); |
| 549 | else | 555 | else |
| @@ -562,9 +568,9 @@ private: | @@ -562,9 +568,9 @@ private: | ||
| 562 | 568 | ||
| 563 | transform->train(data); | 569 | transform->train(data); |
| 564 | 570 | ||
| 565 | - qDebug("Storing %s", qPrintable(baseName)); | 571 | + qDebug("Storing %s", qPrintable(fileName)); |
| 566 | QtUtils::BlockCompression compressedOut; | 572 | QtUtils::BlockCompression compressedOut; |
| 567 | - QFile fout(baseName); | 573 | + QFile fout(fileName); |
| 568 | QtUtils::touchDir(fout); | 574 | QtUtils::touchDir(fout); |
| 569 | compressedOut.setBasis(&fout); | 575 | compressedOut.setBasis(&fout); |
| 570 | 576 | ||
| @@ -606,8 +612,8 @@ private: | @@ -606,8 +612,8 @@ private: | ||
| 606 | 612 | ||
| 607 | QString getFileName() const | 613 | QString getFileName() const |
| 608 | { | 614 | { |
| 609 | - if (QFileInfo(baseName).exists()) return baseName; | ||
| 610 | - const QString file = Globals->sdkPath + "/share/openbr/models/transforms/" + baseName; | 615 | + if (QFileInfo(fileName).exists()) return fileName; |
| 616 | + const QString file = Globals->sdkPath + "/share/openbr/models/transforms/" + fileName; | ||
| 611 | return QFileInfo(file).exists() ? file : QString(); | 617 | return QFileInfo(file).exists() ? file : QString(); |
| 612 | } | 618 | } |
| 613 | 619 |