本文整理汇总了C++中Holder::doit方法的典型用法代码示例。如果您正苦于以下问题:C++ Holder::doit方法的具体用法?C++ Holder::doit怎么用?C++ Holder::doit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Holder
的用法示例。
在下文中一共展示了Holder::doit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selfOrganizingMap
//.........这里部分代码省略.........
if(args.if_pop("-tofile")){
saveTo = args.pop_string();
}else if(args.if_pop("-fromfile")){
loadFrom = args.pop_string();
}else if(args.if_pop("-seed")){
GRand::global().setSeed(args.pop_uint());
}else if(args.if_pop("-neighborhood")){
string name = args.pop_string();
if(name == "gaussian"){
windowFunc.reset(new SOM::GaussianWindowFunction());
}else if(name == "uniform"){
windowFunc.reset(new SOM::UniformWindowFunction());
}else{
throw Ex("Only gaussian and uniform are acceptible ",
"neighborhood types");
}
}else if(args.if_pop("-printMeshEvery")){
using namespace SOM;
unsigned interval = args.pop_uint();
string baseFilename = args.pop_string();
unsigned xDim = args.pop_uint();
unsigned yDim = args.pop_uint();
bool showTrain = false;
if(args.if_pop("showTrain") || args.if_pop("showtrain")){
showTrain = true;
}
smart_ptr<Reporter> weightReporter
(new SVG2DWeightReporter(baseFilename, xDim, yDim, showTrain));
Holder<IterationIntervalReporter> intervalReporter
(new IterationIntervalReporter(weightReporter, interval));
reporters->add(intervalReporter.release());
}else if(args.if_pop("-batchTrain")){
algoName = "batch";
startWidth = args.pop_double();
endWidth = args.pop_double();
numIter = args.pop_uint();
numConverge = args.pop_uint();
}else if(args.if_pop("-stdTrain")){
algoName = "standard";
startWidth = args.pop_double();
endWidth = args.pop_double();
startRate = args.pop_double();
endRate = args.pop_double();
numIter = args.pop_uint();
}else{
throw Ex("Invalid option: ", args.peek());
}
}
//Create the training algorithm
Holder<SOM::TrainingAlgorithm> algo;
if(algoName == "batch"){
double netRadius = *std::max_element(netDims.begin(), netDims.end());
if(startWidth < 0){ startWidth = 2*netRadius; }
if(endWidth < 0){ endWidth = 1; }
algo.reset( new SOM::BatchTraining
(startWidth, endWidth, numIter, numConverge,
weightInit.release(), windowFunc.release(),
reporters.release()));
}else if(algoName == "standard"){
algo.reset( new SOM::TraditionalTraining
(startWidth, endWidth, startRate, endRate, numIter,
weightInit.release(), windowFunc.release(),
reporters.release()));
}else{
throw Ex("Unknown type of training algorithm: \"",
algoName, "\"");
}
//Create the network & transform the data
Holder<GSelfOrganizingMap> som;
Holder<GMatrix> out;
if(loadFrom == ""){
//Create map from arguments given
som.reset(new GSelfOrganizingMap
(netDims, numNodes, topology.release(), algo.release(),
weightDist.release(), nodeDist.release()));
//Train the network and transform the data in place
out.reset(som->doit(*pData));
}else{
//Create map from file
GDom source;
source.loadJson(loadFrom.c_str());
som.reset(new GSelfOrganizingMap(source.root()));
//Transform using the loaded network
out.reset(som->transformBatch(*pData));
}
//Save the trained network
if(saveTo != ""){
GDom serialized;
GDomNode* root = som->serialize(&serialized);
serialized.setRoot(root);
serialized.saveJson(saveTo.c_str());
}
//Print the result
out->print(cout);
}