本文整理汇总了C++中Network::Reset方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::Reset方法的具体用法?C++ Network::Reset怎么用?C++ Network::Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::Reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
while (true)
{
scanf("%d%d",&n,&m);
if (n == 0 && m == 0) break;
g.Reset(n+2,0,n+1);
g.InsertEdge(0,1,n*2);
for (int i = 1;i <= n;i++)
{
int cnt,v;
scanf("%d",&cnt);
for (int j = 1;j <= cnt;j++)
{
scanf("%d",&v);
g.InsertEdge(i,v,1);
}
g.InsertEdge(i,n+1,2);
}
cout << g.Dinic() << endl;
}
}
示例2: NetworkTestTrieschAndFoldiak
//.........这里部分代码省略.........
float eta1 = 0.5, eta2= 0.02, eta3 = 0.02, alpha = 0.0005, beta = 10;//alpha = 1.0/8.0, beta = 10;
bool lateral = false;
ProjectionModifierFoldiak* eFoldiak = new ProjectionModifierFoldiak(eta1, eta2, eta3, alpha, beta, lateral);
lateral = true;
alpha = 0.75;
ProjectionModifierFoldiak* eFoldiakLateral = new ProjectionModifierFoldiak(eta1, eta2, eta3, alpha, beta, lateral);
//ProjectionModifierBCM* eBCM = new ProjectionModifierBCM(0.1,0.05,20);
if(!isTriesch)
{
full2 = new FullConnectivity();
layer2->AddPre(layer2,full2);
full->AddProjectionsEvent(eFoldiak);
full2->AddProjectionsEvent(eFoldiakLateral);
}
else
{
full3NoLocal = new FullConnectivityNoLocalHypercolumns();
//full3NoLocal->AddProjectionsEvent(eBCM);
full3NoLocal->AddProjectionsEvent(eFoldiakLateral);
layer2->AddPre(layer2,full3NoLocal);
}
// implements N here
SoftMax* softmax = new SoftMax(SoftMax::WTAThresholded,0.5);//(10.0, SoftMax::ProbWTA);
WTA* wta = new WTA();
//layer2->AddPopulationModifier(wta);
layer2->AddPopulationModifier(softmax);
network->Initialize();
//////////////////////////////
// Meters
char* name1 = new char[50];
char* name2 = new char[50];
sprintf(name1,"Projection_triesch_n%d.csv",mpiRank);
Meter* connMeter = new Meter(name1, Storage::CSV);
connMeter->AttachProjection(layer2->GetIncomingProjections()[0],0);
network->AddMeter(connMeter);
sprintf(name2,"Layer2Activity_triesch.csv");
Meter* layerMeter = new Meter(name2, Storage::CSV);
layerMeter->AttachPopulation(layer2);
network->AddMeter(layerMeter);
// end Meters
//////////////////////////////
vector<vector<float> > trainData = dataSources.GetBars(sizeX,sizeY, nrItems);
int iterations = 1;
int iterSameStimuli = 100;
if(!isTriesch)
iterSameStimuli = 10;
layer1->SwitchOnOff(false); // fixed during training phase
for(int j=0;j<iterations;j++)
{
for(int i=0;i<trainData.size();i++)
{
/*if(!isTriesch)
{
// in order to settle recurrent activity
eFoldiak->SwitchOnOff(false);
eFoldiakLateral->SwitchOnOff(false);
}*/
for(int k=0;k<iterSameStimuli;k++)
{
/* if(!isTriesch && k==iterSameStimuli-1)
{
eFoldiak->SwitchOnOff(true);
eFoldiakLateral->SwitchOnOff(true);
}
*/
for(int m=0;m<1;m++)
{
layer1->SetValuesAll(trainData[i]);
//for(int n=0;n<3;n++)
network->Simulate();
}
}
// allow units to reset
network->Reset();
/*if(i%50 == 0)
{
network->RecordAll();
if(mpiRank == 0)
cout<<"Storing.";
}*/
}
}
network->RecordAll();
}
示例3: NetworkTestMNISTClassification
//.........这里部分代码省略.........
}
if(j==plastStopIter)
{
bFeedforward->SwitchOnOff(false);//SetAlpha(0.0);
bInhib->SwitchOnOff(false);//SetImpactBeta(0.0);
softmax->SetType(SoftMax::WTA);
}
}
// next time step
network->Simulate();
cout.flush();
}
connMeter.RecordAll(0);
if(mpiRank == 0)
{
cout<<"\n";
cout.flush();
layerMeter.RecordAll(0);
layer3Meter.RecordAll(0);
}
}
// save data
if(mpiRank == 0)
vqMeter.RecordAll(0);
// 2. Testing phase
//network->Simulate();
network->Reset(); // Clears values
//network->Simulate();
//network->Simulate();
layer1->SwitchOnOff(false);
layer3->SwitchOnOff(true);
bFeedforward->SwitchOnOff(false);//->SetAlpha(0.0);
bClassification->SwitchOnOff(false);
kClassification->SwitchOnOff(false);
bInhib->SwitchOnOff(false);//SetImpactBeta(0.0);
softmax->SetType(SoftMax::WTA);
vector<vector<float> > testingData = storageH5.LoadDataFloatCSV(filenameTesting,nrTestImages,true);//storageH5.LoadDataFloatHDF5(filename,"trainingData",0,nrTrainImages);//storageH5.LoadDataFloatHDF5(filename,"trainingData",partsOfDataToUseAsInput,0,nrTrainImages);
vector<vector<float> > testingLabels = storageLabels.LoadDataFloatCSV(filenameTestingLabels,nrTestImages,true);
// A. Training data
for(int i=0;i<nrTrainImages;i++)
{
if(mpiRank == 0)
{
cout<<i;
cout.flush();
}
binData = toBinary(trainingData[i],trainingData[i].size(), nrInputRateUnits);//vector<float> binData = toBinary(currentTrainingData[0],currentTrainingData[0].size(),nrInputRateUnits);//trainingData[i],trainingData[i].size(), nrInputRateUnits);
binDataOut = toBinary(trainingLabels[i],trainingLabels[i].size(), nrOutputRateUnits);
layer1->SetValuesAll(binData);
network->Simulate();
}