Definition at line 98 of file mainActiveLearner.cpp. References Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::Core::Database::RawDataSet::GetQuidClass(), ILOG_ERROR, ILOG_INFO, ILOG_VAR, LearnConceptFromAnnotations(), Impala::Core::Training::LoadDistributedAccess(), Impala::Core::Database::MakeRawDataSet(), Impala::QuidClassToString(), Impala::Persistency::RepositoryGetFile(), Impala::Core::Matrix::DistributedAccess::StartEventLoop(), Impala::Core::Matrix::DistributedAccess::Subscribe(), and Impala::Core::Matrix::DistributedAccess::Unsubscribe(). Referenced by mainActiveLearner(). 00099 { 00100 ILOG_VAR(Application.RunDistributedLearningEngine); 00101 String setName = options.GetArg(0); 00102 String conceptsName = options.GetArg(1); //"conceptsActiveLearn.txt"; 00103 String model = options.GetArg(2); 00104 String kernel = options.GetArg(3); 00105 00106 Database::RawDataSet* dataSet = Database::MakeRawDataSet(setName); 00107 int quidClass = dataSet->GetQuidClass(); 00108 00109 int startnode = 1; 00110 int nodes = Link::Mpi::NrProcs() - startnode; 00111 Matrix::DistributedAccess* da = 00112 LoadDistributedAccess(model, kernel, dataSet, 0, startnode, nodes); 00113 if ((Link::Mpi::MyId() <= nodes + startnode) && (Link::Mpi::MyId() != 0)) 00114 { 00115 da->StartEventLoop(); 00116 } 00117 else 00118 { 00119 da->Subscribe(); 00120 ILOG_INFO_NODE("engine loaded, waiting for annotations."); 00121 00122 while (true) 00123 { 00124 // announce waiting for table 00125 // receive table 00126 String identifier; 00127 while (true) 00128 { 00129 String fName = "Annotations/" + QuidClassToString(quidClass) 00130 + "/" + conceptsName + "/startlearner.txt"; 00131 FileLocator fLoc(dataSet->GetLocator(), fName); 00132 Persistency::File file = RepositoryGetFile(fLoc, false, true); 00133 if (file.Valid()) 00134 { 00135 std::vector<String> ids; 00136 file.ReadStrings(ids); 00137 if (ids.size() > 0) 00138 { 00139 identifier = ids[0]; 00140 ILOG_INFO("Starting model train cycle for "<<identifier); 00141 ids.clear(); 00142 file = RepositoryGetFile(fLoc, true, false); 00143 file.WriteStrings(ids.begin(), ids.end()); 00144 break; 00145 } 00146 } 00147 } 00148 00149 AnnotationTableLocator annoLoc(dataSet->GetLocator(), quidClass, 00150 conceptsName, identifier); 00151 if (!AnnotationTableRepository().Exists(annoLoc)) 00152 continue; 00153 Table::AnnotationTable* annotationtable = 00154 AnnotationTableRepository().Get(annoLoc); 00155 00156 ModelLocator modelLoc(dataSet->GetLocator(), conceptsName, 00157 "activelearn", "activelearn", identifier); 00158 Timer timer; 00159 Table::SimilarityTableSet* simSet = 00160 LearnConceptFromAnnotations(options, da, identifier, modelLoc, 00161 annotationtable); 00162 ILOG_INFO("Learned in " << timer.SplitTimeStr()); 00163 00164 if (!simSet) 00165 { 00166 ILOG_ERROR("Learning aborted, no positives or negatives?"); 00167 continue; 00168 } 00169 00170 // save concept 00171 SimilarityTableSetLocator simLoc(dataSet->GetLocator(), true, "", 00172 conceptsName, "activelearn", 00173 "activelearn", ""); 00174 SimilarityTableSetRepository().Add(simLoc, simSet); 00175 00176 delete annotationtable; 00177 delete simSet; 00178 00179 ILOG_INFO("Loop done: " << timer.SplitTimeStr()); 00180 } 00181 da->Unsubscribe(); 00182 } 00183 delete da; 00184 Link::Mpi::Finalize(); 00185 return 0; 00186 }
Here is the call graph for this function: ![]()
|