123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- #include <iostream.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <libcsim.h>
- #include <anyoption.h>
- #include <valarray>
- #include <time.h>
- ////////////////////
- const float connectivity = 0.1;
- int main(int argc, char** argv)
- {
- clock_t cpu_start, cpu_end;
- double cpu_time_used;
- ////////////////Begin//ProcessCommandLineArguments//////////////
- cpu_start = clock();
- // 'a' = dummy; do not use -a !! (setOption without second para doesn't work!!)
- AnyOptionWrapper *myAnyWrap = new AnyOptionWrapper(argc, argv,"settings_sensorycancel.cfg");
- float NoiseSigma; myAnyWrap->setOption( "NoiseSigma", 'n', &NoiseSigma, 0);
- float InputNoiseSigma; myAnyWrap->setOption( "InputNoiseSigma", 'n', &InputNoiseSigma, 0);
- float InhNoiseSigma; myAnyWrap->setOption( "InhNoiseSigma", 'n', &InhNoiseSigma, 0);
- float istrength; myAnyWrap->setOption( "InputStrength", 'i', &istrength, 1);
- float InitialWeights; myAnyWrap->setOption( "InitialWeights", 'w', &InitialWeights, 0.01);
- float InitialFWInhWeights; myAnyWrap->setOption( "InitialFWInhWeights", 'w', &InitialFWInhWeights, 0.02);
- float InputSat; myAnyWrap->setOption( "InputSaturation", 'S', &InputSat, 1.0);
- float ris; myAnyWrap->setOption( "RandomInputStrength", 'r', &ris, 10.0);
- float WeightSum; myAnyWrap->setOption( "WeightSum", 'u', &WeightSum, 1);
- bool TestSim; myAnyWrap->setFlag ("Test", 'T', &TestSim);
- bool LoadWeights; myAnyWrap->setFlag ( "LoadWeights", 'L', &LoadWeights);
- bool LoadITWeights; myAnyWrap->setFlag ( "LoadITWeights", 'a', &LoadITWeights);
- bool LoadForwardWeights; myAnyWrap->setFlag ( "LoadForwardWeights", 'a', &LoadForwardWeights);
- float LtpInc; myAnyWrap->setOption( "LtpInc", 'c', &LtpInc, 0.7);
- int MaxTrials; myAnyWrap->setOption("MaxTrials", 'a', &MaxTrials, 80);
- int probesteps=0; myAnyWrap->setOption("ProbeSteps", 'a', &probesteps, 4);
- // int learnsteps= 150;
- int learnsteps= 20; myAnyWrap->setOption("LearnSteps", 'a', &learnsteps, 20);
- // float TauRec; myAnyWrap->setOption("TauRec", 'a', &TauRec, 50);
- // float U_se; myAnyWrap->setOption("U_se", 'a', &U_se, 0.05);
- float BInpInhWeight; myAnyWrap->setOption("BInpInhWeight", 'a', &BInpInhWeight, 0.03);
- float MaxFWInhWeights; myAnyWrap->setOption("MaxFWInhWeights", 'a', &MaxFWInhWeights, 0.1);
- float FwdInhLinkingWeight; myAnyWrap->setOption("FwdInhLinkingWeight", 'a', &FwdInhLinkingWeight, 0.1);
- float ExInhWeight; myAnyWrap->setOption("ExInhWeight", 'a', &ExInhWeight, 0.1);
- float InhExWeight; myAnyWrap->setOption("InhExWeight", 'a', &InhExWeight, 0.2);
- float ITExInhWeight; myAnyWrap->setOption("ITExInhWeight", 'a', &ITExInhWeight, 0.1);
- float ITInhExWeight; myAnyWrap->setOption("ITInhExWeight", 'a', &ITInhExWeight, 0.2);
- float ITExExWeight; myAnyWrap->setOption("ITExExWeight", 'a', &ITExExWeight, 0.1);
- float ITExCInhWeight; myAnyWrap->setOption("ITExCInhWeight", 'a', &ITExCInhWeight, 0.001);
- float ITCInhExWeight; myAnyWrap->setOption("ITCInhExWeight", 'a', &ITCInhExWeight, 0.005);
- float ITFBInhWeight; myAnyWrap->setOption("ITFBInhWeight", 'a', &ITFBInhWeight, 0.005);
- float FBInhWeight; myAnyWrap->setOption("FBInhWeight", 'a', &FBInhWeight, 0.005);
- float ITSelfInhibitionWeight; myAnyWrap->setOption("ITSelfInhibitionWeight", 'a', &ITSelfInhibitionWeight, 0.01);
- float LearnRate; myAnyWrap->setOption("LearnRate", 'a', &LearnRate, 0.0001);
- float InhLearnRate; myAnyWrap->setOption("InhLearnRate", 'a', &InhLearnRate, 0.00001);
- float InhLearnBaseLine; myAnyWrap->setOption("InhLearnBaseLine", 'a', &InhLearnBaseLine, 1);
- float FBInhLearnRate; myAnyWrap->setOption("FBInhLearnRate", 'a', &FBInhLearnRate, 0.001);
- float Cdep; myAnyWrap->setOption("Cdep", 'a', &Cdep, 0.00001);
- float FBInhMaxWeight;myAnyWrap->setOption("FBInhMaxWeight", 'a', &FBInhMaxWeight, 1.0);
- float RossumCp; myAnyWrap->setOption("RossumCp", 'a', &RossumCp, 0.000001);
- float ITNormFrequency; myAnyWrap->setOption("ITNormFrequency", 'a', &ITNormFrequency, 30);
- bool RandomInputOrder; myAnyWrap->setFlag ("RandomInputOrder", 'a', &RandomInputOrder);
- float StimDur; myAnyWrap->setOption("StimDur", 'a', &StimDur, 30);
- float IsiDur; myAnyWrap->setOption("IsiDur", 'a', &IsiDur, 30);
- float TestStimDur; myAnyWrap->setOption("TestStimDur", 'a', &TestStimDur, 100);
- bool Teach; myAnyWrap->setFlag ("Teach", 'a', &Teach);
- bool XContinuous; myAnyWrap->setFlag ("XContinuous", 'a', &XContinuous);
- float ExExRange; myAnyWrap->setOption("ExExRange", 'a', &ExExRange, 0.02);
- float ExInhRange; myAnyWrap->setOption("ExInhRange", 'a', &ExInhRange, 0.02);
- float InhExRange; myAnyWrap->setOption("InhExRange", 'a', &InhExRange, 0.08);
- float ExExMinDelay; myAnyWrap->setOption("ExExMinDelay", 'a', &ExExMinDelay, 3);
- float ExExMaxDelay; myAnyWrap->setOption("ExExMaxDelay", 'a', &ExExMaxDelay, 6);
- std::string DataDirectory; myAnyWrap->setOption("DataDirectory", 'a', &DataDirectory, "/home/frank/data/");
- float SelfInhMaxWeight; myAnyWrap->setOption("SelfInhMaxWeight", 'a', &SelfInhMaxWeight, 6);
- float SelfInhMinWeight; myAnyWrap->setOption("SelfInhMinWeight", 'a', &SelfInhMinWeight, 1);
- float SelfInhLearnTauDec; myAnyWrap->setOption("SelfInhLearnTauDec", 'a', &SelfInhLearnTauDec, 20);
- float SelfInhBaseLine; myAnyWrap->setOption("SelfInhBaseLine", 'a', &SelfInhBaseLine, 0.1);
- float SelfLearnRate; myAnyWrap->setOption("SelfLearnRate", 'a', &SelfLearnRate, 0.0001);
- float SelfInhWeightSum; myAnyWrap->setOption("SelfInhWeightSum", 'a', &SelfInhWeightSum, 5);
- myAnyWrap->process();
- delete myAnyWrap;
- ////////////////End//ProcessCommandLineArguments//////////////
- ////////////////Begin//InitializeGlobalSimLoop
- SimLoop* MainSimLoop = InitLibCSim();
- // MainSimLoop->SetDataDirectory("/home/frank/data/sim/csim/v4learn/");
- MainSimLoop->SetDataDirectory(DataDirectory.c_str());
- float dt=MainSimLoop->GetDeltaT(); // milli sec
- cout << "int main(): dt = " << dt << "\n";
- ////////////////End//InitializeGlobalSimLoop
-
- bool Learn=true;
- if ((LearnRate == 0) || TestSim) {
- Learn=false;
- cout << "No Learning\n";
- }
- int i, j, k, sec, t;
- // lif2layer *ca3layer;
- // ca3layer=new lif2layer(N, dt, 20, 0.0033, 1, 4,4,ffi,fbi,2, 0.004, 10);
- if (TestSim) LoadWeights=true;
-
- if (LoadWeights)
- {
- LoadITWeights=true;
- LoadForwardWeights=true;
- }
- ////////////////End//ProcessCommandLineArguments//////////////
- //////////////////////////////////////////////
-
-
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/crystal_all_dirchange.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/tetraeder02.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/verticalbar.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/horizontalbar.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/twobar_o3.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/twooris.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/16oris.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/16bars.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/winkel.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/winkelbars256.idlmov");
- // ObjMovie MyMovie("/home/frank/prog/crystal/movies/winkelbars64.idlmov");
- ObjMovie MyMovie("/home/frank/prog/crystal/movies/winkelbars2.idlmov");
- // generate InputLayers
- typedef izhlayer TInputLayer;
- TInputLayer* TmpInputLayer;
- vector<TInputLayer*> InputLayerList;
- //////// Setup Input Layer
- int InputNx, InputNy;
- InputNx=InputNy=20;
- izh2layer* BlobInputLayer = new izh2layer(InputNx*InputNy, IzhParaIntegrator, InputSat);
- BlobInputLayer->SetName("BInpLayer");
- BlobInputLayer->SetupPositions(InputNx, InputNy, true);
- BlobInputLayer->SetRandomInputStrength(0);
- BlobInputLayer->SetNoiseSigma(InputNoiseSigma);
- BlobInputLayer->SetTauInh(7.0);
- MainSimLoop->AddSimElement(BlobInputLayer);
- //////// Setup IT Module
- int ITNx, ITNy;
- ITNx = ITNy = 8;
- // ITNx = 1; ITNy = 2;
- IzhParas IzhLowDIntegrator (0.02, -0.1, -55, 2, 108, 4.1, 0.0);
- // izh3layer* ITLayer = new izh3layer(ITNx*ITNy, IzhLowDIntegrator,InputSat);
- izh3layer* ITLayer = new izh3layer(ITNx*ITNy, IzhParaIntegrator,InputSat);
- ITLayer->SetName("ITLayer");
- ITLayer->SetupPositions(ITNx,ITNy,true);
- ITLayer->SetRandomInputStrength(0);
- ITLayer->SetNoiseSigma(NoiseSigma);
- ITLayer->SetTauInh(5.0);
- ITLayer->StartBinRec(2);
- MainSimLoop->AddSimElement(ITLayer);
- int ITInhNx, ITInhNy;
- ITInhNx = ITInhNy = ITNx/2;
- // izh3layer* ITInhLayer = new izh3layer(ITInhNx*ITInhNy, IzhParaFastSpiking,InputSat);
- izh3layer* ITInhLayer = 0;
- if ((ITInhExWeight > 0) || (ITExInhWeight > 0)) {
- ITInhLayer = new izh3layer(ITInhNx*ITInhNy, IzhParaClass2,InputSat);
- ITInhLayer->SetName("ITInhLayer");
- ITInhLayer->SetupPositions(ITInhNx,ITInhNy,true);
- ITInhLayer->SetRandomInputStrength(0);
- ITInhLayer->SetNoiseSigma(InhNoiseSigma);
- ITInhLayer->SetTauEx(15);
- MainSimLoop->AddSimElement(ITInhLayer);
- }
- int ITCommonInhNx, ITCommonInhNy;
- ITCommonInhNx = ITCommonInhNy = 2;
- izh3layer* ITCommonInhLayer = new izh3layer(ITCommonInhNx*ITCommonInhNy, IzhParaFastSpiking,InputSat);
- // izh3layer* ITCommonInhLayer = new izh3layer(ITCommonInhNx*ITCommonInhNy, IzhParaClass2,InputSat);
- ITCommonInhLayer->SetName("ITCommonInhLayer");
- ITCommonInhLayer->SetupPositions(ITCommonInhNx,ITCommonInhNy,true);
- ITCommonInhLayer->SetRandomInputStrength(0);
- ITCommonInhLayer->SetNoiseSigma(0);
- ITCommonInhLayer->SetTauEx(10);
- MainSimLoop->AddSimElement(ITCommonInhLayer);
- //////////connections
- FacilitativeConnection *ConITSelfInh=0;
- if (ITSelfInhibitionWeight > 0) {
- // connection *ConITSelfInh = new connection(ITLayer, ITLayer, 1, true); // inputNumber=0
- ConITSelfInh = new FacilitativeConnection(ITLayer, ITLayer, 1, 60, 0.005, 50, 0.01); // inputNumber=0
- ConITSelfInh->SetNonSelf(true);
- ConITSelfInh->SetName("conIT_SelfInh");
- if (LoadITWeights) ConITSelfInh->Load();
- else {
- ConITSelfInh->ConnectFull(ITSelfInhibitionWeight, 1,0);
- // ConITSelfInh->ConnectRandom(0.4, ITSelfInhibitionWeight, 1,0);
- // DistanceProfile* profile = new CircleDistanceProfile(1000, 0.2);
- // ConITSelfInh->ConnectProfile(profile, ITSelfInhibitionWeight, 1,0, true);
- // ConITSelfInh->ConnectRandom(0.2, ITSelfInhibitionWeight, 1,0);
- }
- ConITSelfInh->StartBinRec(1);
-
- if (Learn && (SelfLearnRate >0)) {
- LearnHebbLP2* LearnSelfITInh = new LearnHebbLP2(
- ConITSelfInh, SelfInhMaxWeight, SelfInhLearnTauDec,
- SelfInhBaseLine, SelfLearnRate);
- LearnSelfITInh->SetMinWeight(SelfInhMinWeight);
- ConITSelfInh->SetLearnObj(LearnSelfITInh);
- }
-
- // ConstSumNormalize* SelfInhNorm=0;
- // if (Learn) {
- // SelfInhNorm = new ConstSumNormalize(SelfInhWeightSum, false);
- // SelfInhNorm->AddConnection(ConITSelfInh);
- // // SelfInhNorm->CalcInitWeightSum();
- // SelfInhNorm->NormalizeAll();
- // MainSimLoop->AddSimElement(SelfInhNorm);
- // }
- ConITSelfInh->Save();
- ConITSelfInh->SetAutoSave(false);
- MainSimLoop->AddSimElement(ConITSelfInh);
- }
- if (ITExCInhWeight > 0) {
- connection *ConITExCInh = new connection(ITLayer, ITCommonInhLayer, 0); // inputNumber=0
- ConITExCInh->SetName("conIT_ExCInh");
- if (LoadITWeights) ConITExCInh->Load();
- else {
- ConITExCInh->ConnectFull(ITExCInhWeight, 1,0);
- }
- ConITExCInh->Save();
- MainSimLoop->AddSimElement(ConITExCInh);
- }
- // if (ITCInhExWeight > 0) {
- // connection *ConITCInhEx = new connection(ITCommonInhLayer, ITLayer, 1);
- // ConITCInhEx->SetName("conIT_CInhEx");
- // if (LoadITWeights) ConITCInhEx->Load();
- // else {
- // ConITCInhEx->ConnectFull(ITCInhExWeight, 1,0);
- // }
- // ConITCInhEx->Save();
- // MainSimLoop->AddSimElement(ConITCInhEx);
- // }
- float InhLearnTauDec=30;
- float InhLearnTauPre=30;
- float InhLearnTauPost=100;
- float FBInhMaxWeights=3;
- connection *ConITFbInh =0;
- if (ITFBInhWeight > 0) {
- ConITFbInh = new connection(ITCommonInhLayer, BlobInputLayer, 1);
- ConITFbInh->SetName("conIT_FBInh");
- if (LoadITWeights) ConITFbInh->Load();
- else {
- ConITFbInh->ConnectFull(ITFBInhWeight, 1,0);
- }
- if (Learn && (FBInhLearnRate>0)) {
- ConITFbInh->SetLearnObj(
- new LearnFBInh(ConITFbInh,
- FBInhMaxWeight, InhLearnTauPre,InhLearnTauPost, FBInhLearnRate, Cdep));
- // new LearnHebbLP2(ConITFbInh,
- // FBInhMaxWeights, InhLearnTauDec, 0.1, LearnRate));
- // // new LearnRossum1(ConITFBInh, RossumCp, 0.003, 0.0002));
-
- }
- ConITFbInh->Save();
- ConITFbInh->SetAutoSave(false);
- MainSimLoop->AddSimElement(ConITFbInh);
- }
- connection *ConInpIT = new connection(BlobInputLayer, ITLayer, 0, false);
- // FacilitativeConnection *ConInpIT = new FacilitativeConnection(BlobInputLayer, ITLayer, 0, 300, 0.003, 50, 0.002);
- ConInpIT->SetName("conForward");
- if (LoadForwardWeights) ConInpIT->Load();
- else {
- ConInpIT->ConnectFull(InitialWeights, 2,0);
- }
- // ConInpIT->StartBinRec(InputNx/4+InputNx*InputNy/2);
- float MaxWeights=2.2;
- float LearnTauDec=20;
- float PostLearnTauDec=10;
- float BaseLine = exp(-2*StimDur/LearnTauDec);
- if (Learn) ConInpIT->SetLearnObj(
- // new LearnHebbLP2(ConInpIT,
- // MaxWeights, LearnTauDec, BaseLine, LearnRate));
- // new LearnRossum1(ConInpIT, RossumCp, 0.003, 0.0002));
- new LearnHebbLP3(ConInpIT, MaxWeights, LearnTauDec,
- PostLearnTauDec, BaseLine, LearnRate, true));
- // new LearnRossum1(ConInpIT, RossumCp, 0.003, 0.00005));
- ConInpIT->Save();
- ConInpIT->SetAutoSave(false);
- MainSimLoop->AddSimElement(ConInpIT);
- ConstSumNormalize* norm=0;
- if (Learn) {
- norm = new ConstSumNormalize(WeightSum, true);
- norm->AddConnection(ConInpIT);
- norm->NormalizeAll();
- MainSimLoop->AddSimElement(norm);
- }
- // FiringRateNormalize* norm=0;
- // if (Learn) {
- // norm = new FiringRateNormalize(1.3, 0.999, 100);
- // norm->AddConnection(ConInpIT);
- // MainSimLoop->AddSimElement(norm);
- // }
- // ConstSFNormalize* norm=0;
- // if (Learn && ConInpIT && (ITNormFrequency>0)) {
- // norm = new ConstSFNormalize(ITNormFrequency, 0.0005, 100);
- // norm->AddConnection(ConInpIT);
- // MainSimLoop->AddSimElement(norm);
- // }
- connection *ConInhInpIT = 0;
- if (InitialFWInhWeights>0) {
- float InhRossumCp=0.05*InitialFWInhWeights;
- ConInhInpIT = new connection(BlobInputLayer, ITLayer, 1);
- ConInhInpIT->SetName("conInhForward");
- if (LoadForwardWeights) ConInhInpIT->Load();
- else {
- ConInhInpIT->ConnectFull(InitialFWInhWeights, 2,0);
- }
-
- if (InhLearnRate > 0) ConInhInpIT->SetLearnObj(
- new LearnHebbLP2(ConInhInpIT,
- MaxFWInhWeights, InhLearnTauDec, InhLearnBaseLine, -InhLearnRate, false));
- // new LearnAntiRossum1(ConInhInpIT, InhRossumCp, 0.003, 0.001));
- ConInhInpIT->Save();
- ConInhInpIT->SetAutoSave(false);
- MainSimLoop->AddSimElement(ConInhInpIT);
- ConstSFNormalize* FWInhNorm=0;
- if (Learn) {
- FWInhNorm = new ConstSFNormalize(15, -0.001, 40);
- FWInhNorm->AddConnection(ConInhInpIT);
- MainSimLoop->AddSimElement(FWInhNorm);
- }
- }
- connection *ConITFBInh = 0;
- // if (FBInhWeight > 0)
- // {
- // ConITFBInh = new connection(ITLayer, BlobInputLayer, 1);
- // ConITFBInh->SetName("conFBInh");
- // ConITFBInh->ConnectFull(FBInhWeight, 2,0);
- // float LearnInhTauDec=30;
- // if (Learn) ConITFBInh->SetLearnObj(
- // new LearnFBInh(ConITFBInh,
- // FBInhMaxWeight, LearnInhTauDec,LearnInhTauDec, FBInhLearnRate, Cdep));
- // // new LearnHebbLP2(ConITFBInh,
- // // MaxWeights, LearnInhTauDec, 0.5, LearnRate));
- // // new LearnRossum1(ConITFBInh, RossumCp, 0.003, 0.0002));
- // ConITFBInh->Save();
- // ConITFBInh->SetAutoSave(false);
- // MainSimLoop->AddSimElement(ConITFBInh);
- // // ConstSumNormalize* norm=0;
- // // if (Learn) {
- // // norm = new ConstSumNormalize(WeightSum, false);
- // // norm->AddConnection(ConITFBInh);
- // // norm->NormalizeAll();
- // // MainSimLoop->AddSimElement(norm);
- // // }
- // }
- ////////// Setup Input
- float l1inpStimDur=StimDur;
- float Radius=0.2;
- bool Tune=false;
- input* l1inp;
- enum InputType {InpHighOverlap, InpNoOverlap, OnePicture};
- InputType CurInputType=OnePicture;
- // InputType CurInputType=InpNoOverlap;
-
- switch (CurInputType) {
- case InpHighOverlap:
- {
- PictureSequenceInput* TuneInp = new PictureSequenceInput(BlobInputLayer, 0,istrength, l1inpStimDur, 1*l1inpStimDur);
- vector<vector<float> > StimulusArray;
- int NStim=4;
- for (int i=0;i<NStim;++i) {
- vector<float> CurStimArray(InputNx*InputNy);
- for (int xx=0;xx<InputNx;++xx)
- for (int yy=0;yy<InputNy/2;++yy)
- CurStimArray[xx + InputNx*yy]=1;
- for (int yy=InputNy/2;yy<InputNy;++yy)
- for (int xx=InputNx*i/NStim;xx<InputNx*(i+1)/NStim;++xx)
- CurStimArray[xx + InputNx*yy]=1;
- StimulusArray.push_back(CurStimArray);
- }
- TuneInp->SetPictureArray(StimulusArray);
- TuneInp->SetName("HighOverlapInput");
- // TuneInp->SetTestMode(l1inpStimDur, 2*l1inpStimDur);
- TuneInp->SetMode(csimInputRandom);
- // TuneInp->SetMode(csimInputTest);
- MainSimLoop->AddSimElement(TuneInp);
- l1inp=TuneInp;
- }
- break;
- case InpNoOverlap:
- {
- PictureSequenceInput* TuneInp = new PictureSequenceInput(BlobInputLayer, 0,istrength, l1inpStimDur, 1*l1inpStimDur);
- vector<vector<float> > StimulusArray;
- int NStim=4;
- for (int i=0;i<NStim;++i) {
- vector<float> CurStimArray(InputNx*InputNy);
- for (int yy=InputNy/2;yy<InputNy;++yy)
- for (int xx=InputNx*i/NStim;xx<InputNx*(i+1)/NStim;++xx)
- CurStimArray[xx + InputNx*yy]=1;
- StimulusArray.push_back(CurStimArray);
- }
- TuneInp->SetPictureArray(StimulusArray);
- TuneInp->SetName("HighOverlapInput");
- // TuneInp->SetTestMode(l1inpStimDur, 0.2*l1inpStimDur);
- // TuneInp->SetMode(csimInputTest);
- TuneInp->SetMode(csimInputRandom);
- MainSimLoop->AddSimElement(TuneInp);
- l1inp=TuneInp;
- }
- break;
- case OnePicture:
- {
- PictureSequenceInput* WinkelInput = new PictureSequenceInput(BlobInputLayer, 0,istrength, l1inpStimDur, IsiDur);
- WinkelInput->SetPictureArray(&MyMovie);
- WinkelInput->SetName("WinkelInput");
- WinkelInput->SetMode(csimInputRandom);
- // WinkelInput->SetRandomNext(true);
- MainSimLoop->AddSimElement(WinkelInput);
- l1inp = WinkelInput;
- }
- break;
- default: cout << "nothing";
- }
- ////////////////////////////////////
- int trial, step;
- sec =0;
-
- if (TestSim) {
- probesteps=200;
- learnsteps= 0; // 80;
- MaxTrials=1;
- cout << "Test (recall) ----------------------Simulation\n";
- // l1inp->SetTestMode(100,1000);
- } else cout << "NOtestsim------------------------\n";
- fflush(stdout);
- int TotalTime=0;
- MainSimLoop->Hallo();
- MainSimLoop->SaveSimInfo();
- for (trial=0; trial<MaxTrials; ++trial)
- {
- cout << "TrialNr=" << trial << "\n";
- // l1inp->TurnOn();
- // learn
- for(step=0;step<learnsteps;++step)
- {
- cpu_end=clock();
- cpu_time_used = ((double) (cpu_end - cpu_start)) / CLOCKS_PER_SEC;
- cout << "T" << trial << " Step=" << step
- << " sec= " << dt*(sec++) << " cputime="
- << cpu_time_used << " sec \n "; fflush(stdout);
- for (t=0;t<1000;t++) // simulation of 1 sec
- {
- MainSimLoop->proceede(1000*step+t);
- }
- MainSimLoop->prepare(step);
- }
- // SaveWeights
- ConInpIT->Save(trial);
- if (ConITFbInh) ConITFbInh->Save(trial);
- if (ConITSelfInh) ConITSelfInh->Save(trial);
- if (ConInhInpIT) ConInhInpIT->Save(trial);
- // probe
- // change input, turn off learning, turn off normalization
- // cout << "probe\n";
- // if (Learn) {
- // ConInpIT->SetLearn(false);
- // if (ConInhInpIT) ConInhInpIT->SetLearn(false);
- // if (norm) norm->TurnOff();
- // }
- // MainSimLoop->SetSimTag("TEST");
- // for(step=0;step<probesteps;++step)
- // {
- // cpu_end=clock();
- // cpu_time_used = ((double) (cpu_end - cpu_start)) / CLOCKS_PER_SEC;
- // cout << "sec= " << dt*(sec++) << "cputime=" << cpu_time_used << " sec \n "; fflush(stdout);
- // for (t=0;t<1000;t++) // simulation of 1 sec
- // {
- // MainSimLoop->proceede(1000*step+t);
- // }
- // MainSimLoop->prepare(step);
- // }
- // if (Learn) {
- // ConInpIT->SetLearn(true);
- // if (ConInhInpIT) ConInhInpIT->SetLearn(true);
- // if (norm) norm->TurnOn();
- // }
- MainSimLoop->SetSimTag("");
- }
- ConInpIT->Save();
- if (ConITFbInh) ConITFbInh->Save();
- if (ConITSelfInh) ConITSelfInh->Save();
- if (ConInhInpIT) ConInhInpIT->Save();
-
- // delete Layer1;
- // delete Layer2;
- // delete l1l2con;
- // delete l1inp;
- cpu_end=clock();
- cpu_time_used = ((double) (cpu_end - cpu_start)) / CLOCKS_PER_SEC;
- cout << "\n\n***********CpuTimeUsed= " << cpu_time_used << " seconds \n";
- system("bluetclbutton v4learn finished &");
- }
|