Commit 5f87009828bf064f7b9091d6617d66dfe88b4c4b
1 parent
42ad4aaf
Consider timeVarying status of child transforms in pipe project
In the train loop, consider timeVarying in addition to trainable. When setting up partial projects, stop at timeVarying stages in addition to trainable stages. Call projectUpdate (with the full training set) on timeVarying stages.
Showing
1 changed file
with
21 additions
and
1 deletions
openbr/plugins/meta.cpp
| @@ -104,6 +104,25 @@ class PipeTransform : public CompositeTransform | @@ -104,6 +104,25 @@ class PipeTransform : public CompositeTransform | ||
| 104 | fprintf(stderr, " training..."); | 104 | fprintf(stderr, " training..."); |
| 105 | transforms[i]->train(copy); | 105 | transforms[i]->train(copy); |
| 106 | } | 106 | } |
| 107 | + // if the transform is time varying, we batch project it. | ||
| 108 | + if (transforms[i]->timeVarying()) { | ||
| 109 | + fprintf(stderr, "\n%s projecting...", qPrintable(transforms[i]->objectName())); | ||
| 110 | + transforms[i]->projectUpdate(copy, copy); | ||
| 111 | + | ||
| 112 | + // advance i since we already projected for this stage. | ||
| 113 | + i++; | ||
| 114 | + | ||
| 115 | + // set up the single item lists since they are inconsistent again. | ||
| 116 | + singleItemLists.clear(); | ||
| 117 | + for (int j=0; j < copy.size(); j++) | ||
| 118 | + { | ||
| 119 | + TemplateList temp; | ||
| 120 | + temp.append(copy[j]); | ||
| 121 | + singleItemLists.append(temp); | ||
| 122 | + } | ||
| 123 | + // the next stage might be trainable, so continue to evaluate it. | ||
| 124 | + continue; | ||
| 125 | + } | ||
| 107 | 126 | ||
| 108 | // We project through any subsequent untrainable transforms at once | 127 | // We project through any subsequent untrainable transforms at once |
| 109 | // as a memory optimization in case any of these intermediate | 128 | // as a memory optimization in case any of these intermediate |
| @@ -112,7 +131,8 @@ class PipeTransform : public CompositeTransform | @@ -112,7 +131,8 @@ class PipeTransform : public CompositeTransform | ||
| 112 | // by that transform at once if we can avoid it. | 131 | // by that transform at once if we can avoid it. |
| 113 | int nextTrainableTransform = i+1; | 132 | int nextTrainableTransform = i+1; |
| 114 | while ((nextTrainableTransform < transforms.size()) && | 133 | while ((nextTrainableTransform < transforms.size()) && |
| 115 | - !transforms[nextTrainableTransform]->trainable) | 134 | + !transforms[nextTrainableTransform]->trainable && |
| 135 | + !transforms[nextTrainableTransform]->timeVarying()) | ||
| 116 | nextTrainableTransform++; | 136 | nextTrainableTransform++; |
| 117 | 137 | ||
| 118 | fprintf(stderr, " projecting..."); | 138 | fprintf(stderr, " projecting..."); |