123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 |
- #include "sys.hpp" // for libcwd
- #include "debug.hpp" // for libcwd
- #include "objsimlibrary.hpp"
- #include "simmodule.hpp"
- #include "simmodules.hpp"
- ////////////////
- SimModuleITLayer::SimModuleITLayer(AnyOptionWrapper* _opt): SimModule(_opt), CompInh(_opt), ITLayer(0), ConITSelfInh(0)
- {
- }
- SimModuleITLayer::~SimModuleITLayer()
- {
- cout << "Destructor SimModuleITLayer::~SimModuleITLayer()\n";
- if (ConITSelfInh) {
- ConITSelfInh->Save();
- delete ConITSelfInh;
- }
- delete ITLayer;
- }
- void SimModuleITLayer::SetCmdLineOptions()
- {
- myAnyWrap->setOption( "ITNx", 'a', &ITNx, 4);
- myAnyWrap->setOption( "ITNy", 'a', &ITNy, 4);
- myAnyWrap->setOption("ITTauInhibition", 'a', &ITTauInhibition, 5.0);
- // myAnyWrap->setOption("ITTauFeeding", 'a', &ITTauFeeding, 5);
- myAnyWrap->setOption("NmdaAmpaRatio", 'a', &NmdaAmpaRatio, 0.3);
- myAnyWrap->setFlag( "LoadITWeights", 'a', &LoadITWeights);
- myAnyWrap->setOption("ITLateralInhibitionWeight", 'a', &ITLateralInhibitionWeight, 0.01);
- myAnyWrap->setFlag( "ITSelfInhFacilitation", 'a', &ITSelfInhFacilitation);
- myAnyWrap->setOption( "ITSelfLearnRate", 'a', &ITSelfLearnRate,0.0001);
- myAnyWrap->setOption("LatInhDistance", 'a', &LatInhDistance, 0.3);
- myAnyWrap->setOption("SelfInhCdep", 'a', &SelfInhCdep, 0.0001);
- myAnyWrap->setOption("SelfInhMaxWeight", 'a', &SelfInhMaxWeight, 6);
- myAnyWrap->setOption("SelfInhMinWeight", 'a', &SelfInhMinWeight, 1);
- CompInh.SetCmdLineOptions();
- }
- layer* SimModuleITLayer::Setup(SimLoop *MainSimLoop, int NeuronType, bool LoadWeights, bool Learn, bool InhResetable, bool SaveInitialWeights)
- {
-
- if (LoadWeights) {
- LoadITWeights=true;
- }
-
- IzhParas IzhLowDIntegrator (0.02, -0.1, -55, 2, 108, 4.1, 0.0);
-
- csimNeuronType NType;
- if (NeuronType<csimNumberNTypes) NType=csimNeuronType(NeuronType);
- NType = csimNType_DecoLif; // remove this
- switch (NType) {
- case csimNType_Izhikevich8:
- {
- float NmdaAmpaRatio=0.3;
- izh8layer* tmplayer = new izh8layer(ITNx*ITNy, IzhParaRegularSpiking);
- tmplayer->SetTauGaba(1.0, ITTauInhibition);
- tmplayer->SetTauGaba(13.5, 100); // remove this
- tmplayer->SetTauAmpa(0.5, 2.4);
- tmplayer->SetTauNmda(10, 100);
- tmplayer->SetNoiseAmplitude(0.259545);
- tmplayer->SetBalancedInhibition(1.58025);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- ITLayer = tmplayer;
- }
- break;
- case csimNType_Izhikevich8_integrator:
- {
- float NmdaAmpaRatio=0.3;
- izh8layer* tmplayer = new izh8layer(ITNx*ITNy, IzhParaIntegrator2);
- tmplayer->SetTauGaba(1.0, ITTauInhibition);
- tmplayer->SetTauGaba(13.5, 100); // remove this
- tmplayer->SetTauAmpa(0.5, 2.4);
- tmplayer->SetTauNmda(10, 100);
- tmplayer->SetNoiseAmplitude(0.172989);
- tmplayer->SetBalancedInhibition(1.48085);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- ITLayer = tmplayer;
- }
- break;
- case csimNType_Izhikevich9:
- {
- float NmdaAmpaRatio=0.3;
- // izh9layer* tmplayer = new izh9layer(ITNx*ITNy, IzhParaRegularSpiking);
- izh9layer* tmplayer = new izh9layer(ITNx*ITNy, IzhParaIntegrator2);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- tmplayer->SetTauAmpa(0.5, 2.4);
- tmplayer->SetTauNmda(10, 100);
- tmplayer->SetNoiseAmplitude(0.172989);
- tmplayer->SetBalancedInhibition(2.07651);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- ITLayer = tmplayer;
- }
- break;
- case csimNType_DecoLif:
- {
- float NmdaAmpaRatio=0.3;
- // izh9layer* tmplayer = new izh9layer(ITNx*ITNy, IzhParaRegularSpiking);
- DecoLifLayer* tmplayer = new DecoLifLayer(ITNx*ITNy, DecoParaExcitatory);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- // tmplayer->SetTauAmpa(0.5, 2.4);
- // tmplayer->SetTauNmda(10, 100);
- // tmplayer->TuneNoiseAmplitude(3);
- const float DECO_LIF_NOISE_3_HZ = 0.05294; // Noise: 3 Hz Background Firing Rate
- tmplayer->SetNoiseAmplitude(DECO_LIF_NOISE_3_HZ);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- // tmplayer->SetNoiseAmplitude(0.0769104); // Noise: 100 Hz Background Firing Rate
- // tmplayer->SetBalancedInhibition(11.7664); // Reduce Background Firing Rate to 3 Hz
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- ITLayer = tmplayer;
- }
- break;
- }
- ITLayer->SetName("RepresentationLayer");
- ITLayer->SetupPositions(ITNx,ITNy,true);
- ITLayer->SetRandomInputStrength(0);
- // ITLayer->StartBinRec(2);
- MainSimLoop->AddSimElement(ITLayer);
-
- // Setup ITSelfInhibition
- bool VecCon=true;
- layer* InhLayer = CompInh.Setup(ITLayer, LoadITWeights, VecCon, SaveInitialWeights);
- InhLayer->SetResetable(InhResetable);
-
- // ConITSelfInh=0;
- // if (ITLateralInhibitionWeight > 0) {
- // if (ITSelfInhFacilitation) {
- // FacilitativeConnection *tmpCon = new FacilitativeConnection(ITLayer, ITLayer, csimInputChannel_GABAa, 60, 0.005, 50, 0.01); // inputNumber=0
- // ConITSelfInh = tmpCon;
- // } else {
- // connection *tmpCon = new connection(ITLayer, ITLayer, csimInputChannel_GABAa, true); // inputNumber=0
- // ConITSelfInh = tmpCon;
- // }
- // ConITSelfInh->SetNonSelf(true);
-
- // ConITSelfInh->SetName("conSelfInh");
- // if (LoadITWeights) ConITSelfInh->Load();
- // else {
- // ConITSelfInh->ConnectFull(ITLateralInhibitionWeight, 0,0);
- // // ConITSelfInh->ConnectRandom(0.4, ITLateralInhibitionWeight, 1,0);
- // // DistanceProfile* profile = new CircleDistanceProfile(1000, LatInhDistance);
- // // ConITSelfInh->ConnectProfile(profile, ITLateralInhibitionWeight, 0,0, true);
-
- // // ConITSelfInh->ConnectRandom(0.2, ITLateralInhibitionWeight, 1,0);
- // }
-
- // float SelfInhMinWeight=0;
- // float InhLearnTauPost=100;
- // float InhLearnTauPre=30;
-
- // if (Learn && (ITSelfLearnRate >0)) {
- // LearnFBInh* LearnSelfITInh = new LearnFBInh(ConITSelfInh,
- // SelfInhMaxWeight, InhLearnTauPre, InhLearnTauPost, ITSelfLearnRate, SelfInhCdep);
- // // LearnHebbLP2* LearnSelfITInh = new LearnHebbLP2(
- // // ConITSelfInh, SelfInhMaxWeight, SelfInhLearnTauDec,
- // // SelfInhBaseLine, ITSelfLearnRate);
- // LearnSelfITInh->SetMinWeight(SelfInhMinWeight);
- // ConITSelfInh->SetLearnObj(LearnSelfITInh);
- // }
-
- // ConITSelfInh->Save();
- // ConITSelfInh->SetAutoSave(false);
- // MainSimLoop->AddSimElement(ConITSelfInh);
- // }
-
-
-
- return ITLayer;
- }
- void SimModuleITLayer::SetInhExWeightStrength(float NewInhExStrength)
- {
- CompInh.SetInhExWeightStrength(NewInhExStrength);
- }
- SpikeTrain* SimModuleITLayer::ItSpikeTrain()
- {
- if (ITLayer) {
- return ITLayer->GetSpikeTrain();
- } else {
- cerr << "ERROR in SimModuleITLayer::ItSpikeTrain(): this should not happen. ITLayer not initialized?\n";
- return 0;
- }
- };
- ////////////////////////
- InvarLayer::InvarLayer(AnyOptionWrapper* _opt): SimModule(_opt), MapLayer(0), VecCon(false)
- {
- NType = csimNType_DecoLif; // remove this
- Nx=Ny=10;
-
- }
- InvarLayer::~InvarLayer()
- {
- delete LInvar;
- delete conMapLInvar;
- }
- void InvarLayer::TurnOn()
- {
- LInvar->TurnOn();
- conMapLInvar->TurnOn();
- }
- void InvarLayer::TurnOff()
- {
- LInvar->TurnOff();
- conMapLInvar->TurnOff();
- }
- void InvarLayer::SetCmdLineOptions()
- {
- myAnyWrap->setOption((SimModuleName + "FWConStrength").c_str(), 'a', &FWConStrength, 0);
-
- }
- layer* InvarLayer::Setup(layer* MapLayer, bool _veccon, bool SaveInitialWeights)
- {
- VecCon=_veccon;
- MainSimLoop = GetGlobalSimLoop();
- if (FWConStrength > 0) {
- // Setup Invar Layer
- switch (NType) {
- case csimNType_DecoLif:
- {
- float NmdaAmpaRatio=0.3;
- DecoLifLayer* tmplayer = new DecoLifLayer(Nx*Ny, DecoParaExcitatory);
- tmplayer->SetName((SimModuleName+"InvarLayer").c_str());
- tmplayer->SetNoiseAmplitude(0.05294); // Noise: 3 Hz Background Firing Rate
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- tmplayer->SetupPositions(Nx, Ny, true);
- MainSimLoop->AddSimElement(tmplayer);
- LInvar = tmplayer;
- }
- break;
- }
- // Setup Forward Connections from MapLayer to Invar Layer
- float ConRange=0.2;
- if (VecCon) {
- VecConnection* tmpcon = new VecConnection(MapLayer, LInvar, csimInputChannel_AMPA);
- tmpcon->ConnectGaussian(ConRange, FWConStrength, 1,0, true);
- conMapLInvar=tmpcon;
- } else {
- connection* tmpcon = new connection(MapLayer, LInvar, csimInputChannel_AMPA);
- tmpcon->ConnectGaussian(ConRange, FWConStrength, 1,0, true);
- conMapLInvar=tmpcon;
- }
- conMapLInvar->SetName((SimModuleName+"conMapToInvar").c_str());
- if (SaveInitialWeights) {
- conMapLInvar->Save();
- }
- MainSimLoop->AddSimElement(conMapLInvar);
- }
-
- return LInvar; // if (FWConStrength == 0) LInvar stays "0"
- }
- //////////////////////////
- SimMod_CompetitiveInhibition::SimMod_CompetitiveInhibition(AnyOptionWrapper* _opt): SimModule(_opt), NInhNeurons(100), InhLayer(0), conInhEx(0), conInhInh(0), conExInh(0)
- {
- }
- void SimMod_CompetitiveInhibition::SetCmdLineOptions()
- {
- std::string ModName("CInh");
- myAnyWrap->setOption((ModName + "NInhNeurons").c_str(), 'a', &NInhNeurons, 100);
- myAnyWrap->setOption((ModName + "NExInhConnections").c_str(), 'a', &NExInhConnections, 10);
- myAnyWrap->setOption((ModName + "NInhExConnections").c_str(), 'a', &NInhExConnections, 10);
- myAnyWrap->setOption((ModName + "NInhInhConnections").c_str(), 'a', &NInhInhConnections, 10);
- myAnyWrap->setOption((ModName + "ExInhStrength").c_str(), 'a', &ExInhStrength, 0.1);
- myAnyWrap->setOption((ModName + "InhExStrength").c_str(), 'a', &InhExStrength, 0.1);
- myAnyWrap->setOption((ModName + "InhInhStrength").c_str(), 'a', &InhInhStrength, 0.1);
- myAnyWrap->setOption((ModName + "NmdaAmpaRatio").c_str(), 'a', &NmdaAmpaRatio, 0.1);
- }
- layer* SimMod_CompetitiveInhibition::Setup(layer* ExLayer, bool LoadWeights, bool VecCon, bool SaveInitialWeights)
- {
- // first: create inhibitory layer
- MainSimLoop = GetGlobalSimLoop();
- int InhNx, InhNy;
- InhNx = NInhNeurons;
- InhNy = 1;
- layer* InhLayer;
- csimNeuronType NType = csimNType_DecoLif;
- switch (NType) {
- case csimNType_Izhikevich9:
- {
- // izh9layer* tmplayer = new izh9layer(NInhNeurons, IzhParaRegularSpiking);
- izh9layer* tmplayer = new izh9layer(NInhNeurons, IzhParaIntegrator2);
- tmplayer->SetupPositions(InhNx, InhNy, true);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- tmplayer->SetTauAmpa(0.5, 2.4);
- tmplayer->SetTauNmda(10, 100);
- tmplayer->SetNoiseAmplitude(0.172989);
- tmplayer->SetBalancedInhibition(2.07651);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- tmplayer->SetName("InhibitionLayer");
- MainSimLoop->AddSimElement(tmplayer);
- InhLayer = tmplayer;
- }
- break;
- case csimNType_DecoLif:
- {
- float NmdaAmpaRatio=0.3;
- DecoLifLayer* tmplayer = new DecoLifLayer(NInhNeurons, DecoParaInhibitory);
- tmplayer->SetupPositions(InhNx, InhNy, true);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- tmplayer->SetTauAmpa(0.5, 2.4);
- tmplayer->SetTauNmda(10, 100);
- tmplayer->SetNoiseAmplitude(0.0504967);
- tmplayer->SetBalancedInhibition(4.52554);
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- tmplayer->SetName("InhibitionLayer");
- MainSimLoop->AddSimElement(tmplayer);
- InhLayer = tmplayer;
- }
- break;
- }
- // InhLayer->StartBinRec(2);
- // setup Ex->Inh connections
- {
- if (NExInhConnections > ExLayer->N) {
- NExInhConnections = ExLayer->N;
- }
- if (VecCon) {
- VecConnection* tmpcon = new VecConnection(ExLayer, InhLayer, csimInputChannel_NMDA_AMPA);
- tmpcon->ConnectRandomIncomming(NExInhConnections,ExInhStrength,1,0,true);
- conExInh=tmpcon;
- } else {
- connection* tmpcon = new connection(ExLayer, InhLayer, csimInputChannel_NMDA_AMPA);
- tmpcon->ConnectRandom2(NExInhConnections,ExInhStrength,1,0,true);
- conExInh=tmpcon;
- }
- conExInh->SetName("conExInh");
- if (SaveInitialWeights) {
- conExInh->Save();
- }
- MainSimLoop->AddSimElement(conExInh);
- }
- // setup Inh->Ex connections
- {
- if (NInhExConnections > InhLayer->N) {
- NInhExConnections = InhLayer->N;
- }
- if (VecCon) {
- VecConnection* tmpcon = new VecConnection(InhLayer, ExLayer, csimInputChannel_GABAa);
- tmpcon->SetName("conInhEx");
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectRandomIncomming(NInhExConnections,InhExStrength,1,0,true);
- }
- conInhEx=tmpcon;
- } else {
- connection* tmpcon = new connection(InhLayer, ExLayer, csimInputChannel_GABAa);
- tmpcon->SetName("conInhEx");
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectRandom2(NInhExConnections,InhExStrength,1,0,true);
- }
- conInhEx=tmpcon;
- }
- if (SaveInitialWeights) {
- conInhEx->Save();
- }
- MainSimLoop->AddSimElement(conInhEx);
- }
- // setup Inh->Inh connections
- {
- if (NInhInhConnections > InhLayer->N) {
- NInhInhConnections = InhLayer->N;
- }
-
- if (VecCon) {
- VecConnection* tmpcon = new VecConnection(InhLayer, InhLayer, csimInputChannel_GABAa);
- tmpcon->SetName("conInhInh");
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectRandomIncomming(NInhInhConnections,InhInhStrength,1,0,true);
- }
- conInhInh = tmpcon;
- } else {
- connection* tmpcon = new connection(InhLayer, InhLayer, csimInputChannel_GABAa);
- tmpcon->SetName("conInhInh");
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectRandom2(NInhInhConnections,InhInhStrength,1,0,true);
- }
- conInhInh = tmpcon;
- }
- if (SaveInitialWeights) {
- conInhInh->Save();
- }
- MainSimLoop->AddSimElement(conInhInh);
- }
- return InhLayer;
- }
- void SimMod_CompetitiveInhibition::SetAllInhExWeights(float WeightValue)
- {
- if (conInhEx) {
- conInhEx->SetAllWeights(WeightValue);
- }
- }
- /**
- * set strength of connections from inhibitory neurons to excitatory neurons to new value
- * new value is stored in InhExStrength
- * @param NewInhExStrength
- */
- void SimMod_CompetitiveInhibition::SetInhExWeightStrength(float NewInhExStrength)
- {
- if (InhExStrength == 0 || !conInhEx) {return;} // error handling
- conInhEx->MultiplyAllTargetWeights(NewInhExStrength/InhExStrength);
- InhExStrength=NewInhExStrength;
- }
- /////////////////////////////////
- SimModuleInput::SimModuleInput(AnyOptionWrapper* _opt): SimModule(_opt), MovieDir(GetDefaultMovieDir())
- {
- }
- void SimModuleInput::SetCmdLineOptions()
- {
- myAnyWrap->setOption( "StimulusSet", 'a', &StimulusSet, 3);
- myAnyWrap->setOption( "StimulusNumber", 'a', &StimulusNumber, 0);
- myAnyWrap->setOption( "StimFileName", 'a', &StimFileName, "");
- myAnyWrap->setOption( "StimSequence", 'a', &StimSequence, "oripos.sequence");
- myAnyWrap->setOption( "StimDur", 'a', &StimDur, 200);
- myAnyWrap->setOption( "IsiDur", 'a', &IsiDur, 20);
- myAnyWrap->setFlag ("XContinuous", 'a', &XContinuous);
- }
- input* SimModuleInput::Setup(layer* TargetLayer, csimInputChannel InputNumber, float InputStrength)
- {
- MainSimLoop = GetGlobalSimLoop();
- // enum SimMod_StimSetType {Test, Parametric, Scan, FileName};
- input* l1inp;
- switch (SType) {
- case Test:
- {
- int FltNr=0;
- float Isi2Dur=0;
- int TestStimDur=249;
- int TestIsiDur= 1;
-
- cout << "Test all Stimuli systematically, NX=" << NXParas << "NY=" << NYParas << "\n";
- ScanObjMovieInput* MovieInput = new ScanObjMovieInput(
- TargetLayer, InputNumber, MyMovie, FltNr, InputStrength, StimDur, NXParas, NYParas,XContinuous, NXParas, IsiDur, Isi2Dur);
- MovieInput->SetXCircle(true);
- MovieInput->SetYCircle(true);
- cout << "before setname simmodules.cpp\n";fflush(stdout);
- MovieInput->SetName("MovieScanInput");
- cout << "before adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- MainSimLoop->AddSimElement(MovieInput);
- cout << "after adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- XYpairList StimList;
- for (int x=0;x<NXParas;++x) for (int y=0;y<NYParas;++y) {
- // cout << "x=" << 4*x << " y=" << 4*y << "\n";
- if (!XContinuous) {
- StimList.push_back(XYpair(x,y));
- } else {
- StimList.push_back(XYpair(y,x));
- }
- }
- MovieInput->InitializeTestMode(&StimList, TestStimDur,TestIsiDur);
- l1inp = MovieInput;
- }
- break;
- case Parametric: ;
- case Scan:;
- break;
- case MovieScan:
- {
- PictureSequenceInput* WinkelInput = new PictureSequenceInput(TargetLayer, InputNumber,InputStrength, StimDur, IsiDur);
- WinkelInput->SetPictureArray(MyMovie);
- WinkelInput->SetName("WinkelInput");
- WinkelInput->SetMode(csimInputRandom);
- // WinkelInput->SetRandomNext(true);
- MainSimLoop->AddSimElement(WinkelInput);
- l1inp = WinkelInput;
- }
- break;
- case FileName:
- {
- int FltNr=0;
- float Isi2Dur=0;
- int TestStimDur=249;
- int TestIsiDur= 1;
-
- cout << "NX=" << NXParas << "NY=" << NYParas << "\n";
- ScanObjMovieInput* MovieInput = new ScanObjMovieInput(
- TargetLayer, InputNumber, MyMovie, FltNr, InputStrength, StimDur, NXParas, NYParas,XContinuous, NXParas, IsiDur, Isi2Dur);
- MovieInput->SetXCircle(true);
- MovieInput->SetYCircle(true);
- cout << "before setname simmodules.cpp\n";fflush(stdout);
- MovieInput->SetName("MovieScanInput");
- cout << "before adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- MainSimLoop->AddSimElement(MovieInput);
- cout << "after adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- XYpairList StimList;
- for (int x=0;x<NXParas;++x) for (int y=0;y<NYParas;++y) {
- // cout << "x=" << 4*x << " y=" << 4*y << "\n";
- if (!XContinuous) {
- StimList.push_back(XYpair(x,y));
- } else {
- StimList.push_back(XYpair(y,x));
- }
- }
- MovieInput->InitializeTestMode(&StimList, TestStimDur,TestIsiDur);
- l1inp = MovieInput;
- }
- break;
- case IdlMovieFile:
- {
- int FltNr=0;
- float Isi2Dur=0;
- int TestStimDur=249;
- int TestIsiDur= 1;
-
- ObjMovieInput* MovieInput = new ObjMovieInput(
- TargetLayer, InputNumber, MyMovie, FltNr, InputStrength, StimDur, IsiDur);
- MovieInput->SetName("MovieInput");
- MainSimLoop->AddSimElement(MovieInput);
- // MovieInput->InitializeTestMode(&StimList, TestStimDur,TestIsiDur);
- l1inp = MovieInput;
- }
- break;
- case Sequence:
- {
- StimulusSequence* MySequence = new StimulusSequence((MovieDir + StimSequence).c_str());
- int FltNr=0;
- SequenceObjMovieInput* MovieInput = new SequenceObjMovieInput(
- TargetLayer, InputNumber, MyMovie, MySequence,
- FltNr, InputStrength, StimDur, 500);
- MainSimLoop->AddSimElement(MovieInput);
- l1inp = MovieInput;
- }
- break;
- case Ascii:
- {
- // StimulusSequence* MySequence = new StimulusSequence((MovieDir+"text.sequence").c_str());
- StimulusSequence* MySequence = new StimulusSequence((MovieDir+"abcdefgh.sequence").c_str());
- int FltNr=0;
- SequenceObjMovieInput* MovieInput = new SequenceObjMovieInput(
- TargetLayer, InputNumber, MyMovie, MySequence,
- FltNr, InputStrength, StimDur, 500);
- MainSimLoop->AddSimElement(MovieInput);
- l1inp = MovieInput;
- }
- break;
- default: cout << "nothing";
- }
- return l1inp;
- }
- void SimModuleInput::LoadMovie(int &InputNx, int &InputNy, int &NStimuli)
- {
- if (StimulusSet<SimMod_NumberStimSetTypes) SType=SimMod_StimSetType(StimulusSet);
- std::string MetaFileName = MovieDir + StimFileName + ".meta.xml";
- MovieMetaFile MetaFile(MetaFileName.c_str());
- std::string MovieFileName;
- if (MetaFile.Loaded) {
- MovieFileName = MetaFile.MovieFileName;
- } else {
- cout << "MovieMetaFile not loaded\n";
- MovieFileName = StimFileName + ".idlmov";
- cout << "using movie file name: MovieFileName\n";
- }
- std::string StimName;
- {
- StimName = MovieDir + MovieFileName;
- cout << "Load movie: " << StimName << "\n";
- }
-
- MyMovie = new ObjMovie(StimName.c_str());
- InputNx = MyMovie->GetOutputWidth(0);
- InputNy = MyMovie->GetOutputHeight(0);
- NStimuli = MyMovie->GetNFrames();
- if (MetaFile.Loaded) {
- NXParas = MetaFile.NXParas;
- NYParas = MetaFile.NYParas;
- } else {
- NXParas = NStimuli; // assume 1d stimulus set
- NYParas = NXParas;
- cout << "Set NXParas to NStimuli=" << NStimuli << " and NYParas=1\n";
- fflush(stdout);
- // NXParas = int(sqrt(float(NStimuli))); // assume square number of stimuli
- // NYParas = NXParas;
- }
- }
- ///Input/////////////////////////
- ///////////////////////////////////////
- SimModuleMovieInput::SimModuleMovieInput(AnyOptionWrapper* _opt)
- : SimModule(_opt), NTestStimuli(0), CommonInhibition(true), InhLayer(0), MovieDir(GetDefaultMovieDir())
- {
- }
- SimModuleMovieInput::~SimModuleMovieInput()
- {
- if (InhLayer) {
- delete InhLayer;
- }
- // this could be done in the SimModule destructor for the LayerList, ConnectionList, ...
- }
- void SimModuleMovieInput::SetCmdLineOptions()
- {
- myAnyWrap->setOption( "StimFileName", 'a', &StimFileName, "");
- // myAnyWrap->setOption( "StimSequence", 'a', &StimSequence, "oripos.sequence");
- myAnyWrap->setOption( "StimDur", 'a', &StimDur, 200);
- myAnyWrap->setOption( "IsiDur", 'a', &IsiDur, 20);
- myAnyWrap->setFlag ("XContinuous", 'a', &XContinuous);
- myAnyWrap->setOption( "LearnRate", 'a', &LearnRate, 0.002);
- myAnyWrap->setOption( "InitialWeights", 'a', &InitialWeights, 0.1);
- myAnyWrap->setOption("FRateNormThreshold", 'a', &FRateNormThreshold, 30);
- myAnyWrap->setOption( "InputExInhWeights", 'a', &ExInhWeights, 0.5);
- myAnyWrap->setOption( "InputInhExWeights", 'a', &InhExWeights, 0.5);
- myAnyWrap->setOption( "TestStepSize", 'a', &TestStepSize, 1);
- myAnyWrap->setFlag ("RewireForwardCon", 'a', &RewireForwardCon);
- }
- void SimModuleMovieInput::LoadMovie()
- {
- std::string MetaFileName = MovieDir + StimFileName + ".meta.xml";
- MovieMetaFile MetaFile(MetaFileName.c_str());
- std::string MovieFileName = MetaFile.MovieFileName;
- std::string StimName;
- {
- StimName = MovieDir + MovieFileName;
- cout << "Load movie: " << StimName << "\n";
- }
-
- MyMovie = new ObjMovie(StimName.c_str());
- InputNx = MyMovie->GetOutputWidth(0);
- InputNy = MyMovie->GetOutputHeight(0);
- NStimuli = MyMovie->GetNFrames();
- NFilters = MyMovie->GetNFilters();
- if (MetaFile.Loaded) {
- NXParas = MetaFile.NXParas;
- NYParas = MetaFile.NYParas;
- } else {
- NXParas = int(sqrt(float(NStimuli))); // assume square number of stimuli
- NYParas = NXParas;
- }
- }
- void SimModuleMovieInput::SetTestMode()
- {
- if (InputList != 0) {
- for (InputIterator it = InputList->begin(); it!=InputList->end();++it) {
- (*it)->SetMode(csimInputTest);
- }
- }
- }
- void SimModuleMovieInput::SetInputMode(InputMode mode)
- {
- if (InputList != 0) {
- for (InputIterator it = InputList->begin(); it!=InputList->end();++it) {
- (*it)->SetMode(mode);
- }
- }
- }
- int SimModuleMovieInput::Setup(csimInputChannel InputNumber, float InputStrength, bool LoadWeights)
- {
- MainSimLoop = GetGlobalSimLoop();
- // enum SimMod_StimSetType {Test, Parametric, Scan, FileName};
- LoadMovie();
- CommonInhibition = true;
- bool OnOffInput = true;
- if (NFilters <2) {
- OnOffInput=false;
- CommonInhibition=false;
- }
- if (OnOffInput) {
- NLayers = 2*NFilters;
- } else {
- NLayers = NFilters;
- }
-
- cout << "SimModuleMovieInput::Setup: NLayers=" << NLayers << "\n";
- LayerList = new TLayerList;
- InputList = new TInputList;
- int LayerNr;
-
- {
- csimNeuronType NType;
- NType = csimNType_DecoLif; // remove this
- if (CommonInhibition) { // setup inhibition layer
- DecoLifLayer* tmplayer = new DecoLifLayer(InputNx*InputNy, DecoParaInhibitory);
- tmplayer->SetName("InputInhLayer");
- tmplayer->SetupPositions(InputNx, InputNy, true);
- // tmplayer->StartBinRec(1);
- MainSimLoop->AddSimElement(tmplayer);
- InhLayer = tmplayer;
- }
- switch (NType) {
- case csimNType_DecoLif:
- {
- float NmdaAmpaRatio=0.3;
- for (LayerNr=0;LayerNr<NLayers;++LayerNr) {
- DecoLifLayer* tmplayer = new DecoLifLayer(InputNx*InputNy, DecoParaExcitatory);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- // tmplayer->SetTauAmpa(0.5, 2.4);
- // tmplayer->SetTauNmda(10, 100);
- // tmplayer->TuneNoiseAmplitude(3);
- tmplayer->SetNoiseAmplitude(0.05294); // Noise: 3 Hz Background Firing Rate
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- // tmplayer->SetNoiseAmplitude(0.0769104); // Noise: 100 Hz Background Firing Rate
- // tmplayer->SetBalancedInhibition(11.7664); // Reduce Background Firing Rate to 3 Hz
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- tmplayer->SetName(("InputLayer"+ stringify(LayerNr)).c_str());
- tmplayer->SetupPositions(InputNx, InputNy, true);
- MainSimLoop->AddSimElement(tmplayer);
- LayerList->push_back(tmplayer);
- if ((CommonInhibition) && (InhLayer != 0)) {
- // Ex->Inh Connection 1-zu-1
- connection *tmpcon = new connection(tmplayer, InhLayer, csimInputChannel_AMPA);
- tmpcon->SetName(("InpL"+ stringify(LayerNr)+"ExInh").c_str());
- // tmpcon->ConnectSelf(ExInhWeights, 0,0);
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectGaussian(0.1,ExInhWeights, 0,0);
- }
- tmpcon->Save();
- MainSimLoop->AddSimElement(tmpcon);
- tmpcon = new connection(InhLayer, tmplayer, csimInputChannel_GABAa);
- tmpcon->SetName(("InpL"+ stringify(LayerNr)+"InhEx").c_str());
- tmpcon->ConnectSelf(InhExWeights, 0,0);
- tmpcon->Save();
- MainSimLoop->AddSimElement(tmpcon);
-
-
- // Inh->Ex Connection 1-zu-1
- }
- }
- }
- break;
- }
-
- input* l1inp;
- int FltNr=0;
- float Isi2Dur=0;
- int TestStimDur=249;
- int TestIsiDur= 1;
-
- cout << "NX=" << NXParas << "NY=" << NYParas << "\n";
- cout << "before setname simmodules.cpp\n";fflush(stdout);
- cout << "before adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- cout << "after adding to mainsimloop simmodules.cpp\n";fflush(stdout);
- NTestStimuli=0;
- XYpairList StimList;
- if (XContinuous) {
- for (int x=0;x<NXParas;++x)
- for (int y=0;y<NYParas;++y) {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
-
- }
- } else {
- for (int y=0;y<NYParas;++y)
- for (int x=0;x<NXParas;++x) {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
- }
- }
- cout << "SimModuleMovieInput::Setup: NTestStimiuli=" << NTestStimuli << "\n";
- for (LayerNr=0;LayerNr<NLayers;++LayerNr) {
- int PosNeg=1;
- FltNr = LayerNr;
- if (OnOffInput) {
- FltNr = LayerNr/2;
- int OnOff = LayerNr % 2;
- PosNeg = 1 - 2*OnOff;
- }
- ScanObjMovieInput* MovieInput = new ScanObjMovieInput(
- (*LayerList)[LayerNr], InputNumber, MyMovie, FltNr, PosNeg*InputStrength, StimDur, NXParas, NYParas,XContinuous, NXParas, IsiDur, Isi2Dur);
- MovieInput->SetXCircle(true);
- MovieInput->SetYCircle(true);
- MovieInput->SetName(("MovieScanInput"+stringify(LayerNr)).c_str());
- MovieInput->InitializeTestMode(&StimList, TestStimDur,TestIsiDur);
- MovieInput->SetMode(csimInputDefault);
- InputList->push_back(MovieInput);
- MainSimLoop->AddSimElement(MovieInput);
- }
- }
- return 0;
- }
- void SimModuleMovieInput::ConnectTo(layer* ToLayer, bool LoadForwardWeights, bool Learn)
- {
- cout << "ConnectTo " << ToLayer->Name << "\n";
- int LayerNr=0;
- if (LayerList) {
- ConnectionList = new TconnectionList;
- for (LayerIterator it = LayerList->begin(); it!=LayerList->end();++it) {
-
- connection *tmpcon = new connection((*it), ToLayer, csimInputChannel_AMPA);
- // DepressiveConnection *tmpcon = new DepressiveConnection((*it), ToLayer, csimInputChannel_AMPA, TauRec, U_se);
- tmpcon->SetName(("conForward"+stringify(LayerNr)).c_str());
- if (LoadForwardWeights) tmpcon->Load();
- else {
- tmpcon->SetNonSelf(false);
- if (RewireForwardCon) {
- float connectivity=0.4;
- tmpcon->ConnectRandom(connectivity, InitialWeights, 2,0);
- tmpcon->SetRewiring(0.0001, connectivity);
- } else {
- tmpcon->ConnectFull(InitialWeights, 2,0);
- }
- }
-
- float MaxWeights=2.2;
- float LearnTauDec=20;
- float PostLearnTauDec=10;
-
- float BaseLine = exp(-2*StimDur/LearnTauDec); // was war die Intention hier?
- if (Learn) tmpcon->SetLearnObj(
- // new LearnHebbLP2(tmpcon,
- // MaxWeights, LearnTauDec, BaseLine, LearnRate));
- new LearnHebbLP3(tmpcon, MaxWeights, LearnTauDec,
- PostLearnTauDec, BaseLine, LearnRate, true));
- // new LearnRossum1(tmpcon, RossumCp, 0.003, 0.00005));
-
-
- MainSimLoop->AddSimElement(tmpcon);
- tmpcon->Save();
- tmpcon->SetAutoSave(false);
- ConnectionList->push_back(tmpcon);
- ++LayerNr;
- }
- // Normalization
- FiringRateNormalize2* norm=0;
- if (Learn) {
- // FiringRateNormalization
- norm = new FiringRateNormalize2(FRateNormThreshold, 0.001, 10);
- norm->SetName("cnormForward");
- for (connectionIterator it = ConnectionList->begin(); it!=ConnectionList->end();++it) {
- norm->AddConnection(*it);
- }
- MainSimLoop->AddSimElement(norm);
- }
- } else {
- cout << "No Layer List \n";
- }
-
- }
- ///SimModuleMovieInput/////////////////////////
- ///////////////////////////////////////
- smodMovieInput::smodMovieInput(AnyOptionWrapper* _opt)
- : SimModule(_opt), NTestStimuli(0), CommonInhibition(true), InhLayer(0), MovieDir(GetDefaultMovieDir())
- {
- cout << "smodMovieInput::smodMovieInput()\n";
- }
- smodMovieInput::~smodMovieInput()
- {
- if (InhLayer) {
- delete InhLayer;
- }
- // this could be done in the SimModule destructor for the LayerList, ConnectionList, ...
- }
- void smodMovieInput::SetCmdLineOptions()
- {
- myAnyWrap->setOption( "StimFileName", 'a', &StimFileName, "");
- myAnyWrap->setOption( "TestStimFileName", 'a', &TestStimFileName, "");
- myAnyWrap->setOption( "SequenceFileName", 'a', &SequenceFileName, "");
- myAnyWrap->setOption( "StimDur", 'a', &StimDur, 200);
- myAnyWrap->setOption( "IsiDur", 'a', &IsiDur, 20);
- myAnyWrap->setFlag ( "XContinuous", 'a', &XContinuous);
- myAnyWrap->setOption( "LearnRate", 'a', &LearnRate, 0.002);
- myAnyWrap->setOption( "InitialWeights", 'a', &InitialWeights, 0.1);
- myAnyWrap->setOption( "FRateNormThreshold", 'a', &FRateNormThreshold, 30);
- myAnyWrap->setOption( "InputExInhWeights", 'a', &ExInhWeights, 0.5);
- myAnyWrap->setOption( "InputInhExWeights", 'a', &InhExWeights, 0.5);
- myAnyWrap->setOption( "TestStepSize", 'a', &TestStepSize, 1);
- myAnyWrap->setFlag ( "RewireForwardCon", 'a', &RewireForwardCon);
- myAnyWrap->setOption( "TauDecLearnPre", 'a', &TauDecLearnPre, 20);
- myAnyWrap->setOption( "TauDecLearnPost", 'a', &TauDecLearnPost, 10);
- myAnyWrap->setFlag ( "OnOffInput", 'a', &OnOffInput, false);
- }
- void smodMovieInput::LoadMovie(string _StimFileName)
- {
-
- std::string MetaFileName = MovieDir + _StimFileName + ".meta.xml";
- MovieMetaFile MetaFile(MetaFileName.c_str());
- std::string MovieFileName;
-
- if (MetaFile.Loaded)
- {
- MovieFileName = MetaFile.MovieFileName;
- cout << "MovieFileName=" << MovieFileName << "\n";
-
- } else
- {
- cout << "MovieMetaFile not loaded\n";
- MovieFileName = _StimFileName + ".idlmov";
- cout << "using movie file name: " << MovieFileName << "\n";
- }
-
- std::string StimName;
-
- {
- StimName = MovieDir + MovieFileName;
- cout << "Load movie: " << StimName << "\n";
- }
-
- MyMovie = new ObjMovie(StimName.c_str());
- InputNx = MyMovie->GetOutputWidth(0);
- InputNy = MyMovie->GetOutputHeight(0);
- NStimuli = MyMovie->GetNFrames();
- NFilters = MyMovie->GetNFilters();
-
- if (MetaFile.Loaded)
- {
- NXParas = MetaFile.NXParas;
- NYParas = MetaFile.NYParas;
-
- } else
- {
- NXParas = int(sqrt(float(NStimuli))); // assume square number of stimuli
- NYParas = NXParas;
- }
- }
- void smodMovieInput::SetTestMode()
- {
- if (InputList != 0) {
- for (InputIterator it = InputList->begin(); it!=InputList->end();++it) {
- (*it)->SetMode(csimInputTest);
- }
- }
- }
- void smodMovieInput::SetInputMode(InputMode mode)
- {
- if (InputList != 0) {
- for (InputIterator it = InputList->begin(); it!=InputList->end();++it) {
- (*it)->SetMode(mode);
- }
- }
- }
- void smodMovieInput::SetNoiseAmplitude(float sigma)
- {
- for (TLayerList::iterator it=LayerList->begin();it!=LayerList->end();++it) {
- (*it)->SetNoiseAmplitude(sigma);
- }
- }
- int smodMovieInput::Setup(csimInputChannel InputNumber, float InputStrength, bool LoadWeights)
- {
- MainSimLoop = GetGlobalSimLoop();
- // enum SimMod_StimSetType {Test, Parametric, Scan, FileName};
- LoadMovie(StimFileName);
- CommonInhibition = false;
- if (OnOffInput) {
- NLayers = 2*NFilters;
- } else {
- NLayers = NFilters;
- }
-
- cout << "smodMovieInput::Setup: NLayers=" << NLayers << "\n";
- LayerList = new TLayerList;
- InputList = new TInputList;
- int LayerNr;
-
- {
- csimNeuronType NType;
- NType = csimNType_DecoLif; // remove this
- if (CommonInhibition) { // setup inhibition layer
- DecoLifLayer* tmplayer = new DecoLifLayer(InputNx*InputNy, DecoParaInhibitory);
- tmplayer->SetName("InputInhLayer");
- tmplayer->SetupPositions(InputNx, InputNy, true);
- // tmplayer->StartBinRec(1);
- MainSimLoop->AddSimElement(tmplayer);
- InhLayer = tmplayer;
- }
- switch (NType) {
- case csimNType_DecoLif:
- {
- float NmdaAmpaRatio=0.3;
- // Quelle fuer NMDA/AMPA-Verhaeltnis:
- // \cite{Krukowski2001_thalamocortical_nmda}
- // \cite{Crair1995_ltp_thalamocortical_synapses}
- for (LayerNr=0;LayerNr<NLayers;++LayerNr) {
- int FltNr = LayerNr;
- if (OnOffInput) {
- FltNr = LayerNr/2;
- int OnOff = LayerNr % 2;
- }
- DecoLifLayer* tmplayer = new DecoLifLayer((MyMovie->GetOutputWidth(FltNr))*(MyMovie->GetOutputHeight(FltNr)), DecoParaExcitatory);
- // tmplayer->SetTauGaba(1.0, ITTauInhibition);
- // tmplayer->SetTauGabaA(13.5, 100); // remove this
- // tmplayer->SetTauAmpa(0.5, 2.4);
- // tmplayer->SetTauNmda(10, 100);
- // tmplayer->TuneNoiseAmplitude(3);
- tmplayer->SetNoiseAmplitude(0.05294); // Noise: 3 Hz Background Firing Rate
- // tmplayer->TuneNoiseAmplitude(100);
- // tmplayer->TuneBalancedInhibition(3);
- // tmplayer->SetNoiseAmplitude(0.0769104); // Noise: 100 Hz Background Firing Rate
- // tmplayer->SetBalancedInhibition(11.7664); // Reduce Background Firing Rate to 3 Hz
- tmplayer->SetNmdaAmpaRatio(NmdaAmpaRatio);
- tmplayer->SetName(("InputLayer"+ stringify(LayerNr)).c_str());
- tmplayer->SetupPositions(InputNx, InputNy, true);
- MainSimLoop->AddSimElement(tmplayer);
- LayerList->push_back(tmplayer);
- if ((CommonInhibition) && (InhLayer != 0)) {
- // Ex->Inh Connection 1-zu-1
- connection *tmpcon = new connection(tmplayer, InhLayer, csimInputChannel_AMPA);
- tmpcon->SetName(("InpL"+ stringify(LayerNr)+"ExInh").c_str());
- // tmpcon->ConnectSelf(ExInhWeights, 0,0);
- if (LoadWeights) {
- tmpcon->Load();
- } else {
- tmpcon->ConnectGaussian(0.1,ExInhWeights, 0,0);
- }
- tmpcon->Save();
- MainSimLoop->AddSimElement(tmpcon);
- tmpcon = new connection(InhLayer, tmplayer, csimInputChannel_GABAa);
- tmpcon->SetName(("InpL"+ stringify(LayerNr)+"InhEx").c_str());
- tmpcon->ConnectSelf(InhExWeights, 0,0);
- tmpcon->Save();
- MainSimLoop->AddSimElement(tmpcon);
-
-
- // Inh->Ex Connection 1-zu-1
- }
- }
- }
- break;
- }
-
- input* l1inp;
- int FltNr=0;
- float Isi2Dur=0;
- int TestStimDur=249;
- int TestIsiDur= 1;
-
- cout << "NX=" << NXParas << "NY=" << NYParas << "\n";
- cout << "teststepsize = " << TestStepSize << "\n";
-
- NTestStimuli=0;
- XYpairList StimList;
- if (XContinuous) {
- for (int x=0;x<NXParas;++x)
- for (int y=0;y<NYParas;++y) {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
-
- }
- } else {
- int ystart = NYParas/2;
- int xstart = NXParas/2;
- for (int y=ystart;y>=0;--y) {
- for (int x=xstart;x>=0;--x)
- {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
- }
- for (int x=NXParas-1;x>xstart;--x)
- {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
- }
- }
- for (int y=NYParas;y>ystart;--y) {
- for (int x=xstart;x>=0;--x)
- {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
- }
- for (int x=NXParas-1;x>xstart;--x)
- {
- if (((y % TestStepSize) == 0) && ((x % TestStepSize) == 0)) {
- StimList.push_back(XYpair(x,y));
- ++NTestStimuli;
- }
- }
- }
- }
- cout << "smodMovieInput::Setup: NTestStimiuli=" << NTestStimuli << "\n";
- for (LayerNr=0;LayerNr<NLayers;++LayerNr) {
- int PosNeg=1;
- FltNr = LayerNr;
- if (OnOffInput) {
- FltNr = LayerNr/2;
- int OnOff = LayerNr % 2;
- PosNeg = 1 - 2*OnOff;
- }
- ScanObjMovieInput* MovieInput = new ScanObjMovieInput(
- (*LayerList)[LayerNr], InputNumber, MyMovie, FltNr, PosNeg*InputStrength, StimDur, NXParas, NYParas,XContinuous, NXParas, IsiDur, Isi2Dur);
- MovieInput->SetXCircle(true);
- MovieInput->SetYCircle(true);
- MovieInput->SetName(("MovieScanInput"+stringify(LayerNr)).c_str());
- MovieInput->InitializeTestMode(&StimList, TestStimDur,TestIsiDur);
- if (!SequenceFileName.empty()) {
- string SequenceFilePath = MovieDir + SequenceFileName;
- cout << "SequenceFilePath = " << SequenceFilePath << "\n"; fflush(stdout);
- MovieInput->loadStimulusSequence(SequenceFilePath.c_str());
- }
- MovieInput->SetMode(csimInputDefault);
- InputList->push_back(MovieInput);
- MainSimLoop->AddSimElement(MovieInput);
- }
- }
- return 0;
- }
- void smodMovieInput::ChangeMovie(ObjMovie* _NewMovie)
- {
- for (int LayerNr=0;LayerNr<NLayers;++LayerNr) {
- int PosNeg=1;
- int FltNr = LayerNr;
- if (OnOffInput) {
- FltNr = LayerNr/2;
- int OnOff = LayerNr % 2;
- PosNeg = 1 - 2*OnOff;
- }
-
- ScanObjMovieInput* MovieInput = dynamic_cast<ScanObjMovieInput*>((*InputList)[LayerNr]);
- if (MovieInput) {
- MovieInput->SetMovieFile(_NewMovie, FltNr);
- } else {
- cerr << "ERROR in smodMovieInput::ChangeMovie. Dynamic cast failed.\n";
- }
- }
- }
- void smodMovieInput::ConnectTo(layer* ToLayer, bool LoadForwardWeights, bool Learn, bool VecCon, bool SaveInitialWeights)
- {
- cout << "ConnectTo " << ToLayer->Name << "\n";
- float connectivity=0.6; // for rewiring
- float RewireThreshold=0.05*InitialWeights;
- float RewInitialWeights=1.2*RewireThreshold;
- int LayerNr=0;
- if (LayerList) {
- ConnectionList = new TconnectionList;
- VConnectionList = new TVConList;
- for (LayerIterator it = LayerList->begin(); it!=LayerList->end();++it) {
-
- // learn parameter
- float MaxWeights=2.2;
- float LearnTauDec=TauDecLearnPre;
- float PostLearnTauDec=TauDecLearnPost;
- // float LearnTauDec=20;
- // float PostLearnTauDec=10;
-
- float BaseLine = exp(-2*StimDur/LearnTauDec); // was war die Intention hier?
- if (VecCon) {
- VecConnection *tmpcon = new VecConnection((*it), ToLayer, csimInputChannel_AMPA);
- tmpcon->SetName(("conForward"+stringify(LayerNr)).c_str());
- if (LoadForwardWeights) tmpcon->Load();
- else {
- tmpcon->SetNonSelf(false);
- if (RewireForwardCon) {
- tmpcon->ConnectRandomIncomming(connectivity, InitialWeights, 2,0);
- } else {
- tmpcon->ConnectFull(InitialWeights, 2,0);
- }
- }
-
- if (Learn) tmpcon->SetLearnObj(
- new VecLearnHebbLP3(tmpcon, MaxWeights, LearnTauDec,
- PostLearnTauDec, BaseLine, LearnRate, true));
-
- MainSimLoop->AddSimElement(tmpcon);
- if (SaveInitialWeights) {
- tmpcon->Save();
- }
- tmpcon->SetAutoSave(false);
- VConnectionList->push_back(tmpcon);
- ++LayerNr;
- } else {
- connection *tmpcon = new connection((*it), ToLayer, csimInputChannel_AMPA);
- // DepressiveConnection *tmpcon = new DepressiveConnection((*it), ToLayer, csimInputChannel_AMPA, TauRec, U_se);
- tmpcon->SetName(("conForward"+stringify(LayerNr)).c_str());
- if (LoadForwardWeights) tmpcon->Load();
- else {
- tmpcon->SetNonSelf(false);
- if (RewireForwardCon) {
- tmpcon->ConnectRandom(connectivity, InitialWeights, 2,0);
- tmpcon->SetRewiring(RewireThreshold, connectivity);
- } else {
- tmpcon->ConnectFull(InitialWeights, 2,0);
- }
- }
-
- if (Learn) tmpcon->SetLearnObj(
- // new LearnHebbLP2(tmpcon,
- // MaxWeights, LearnTauDec, BaseLine, LearnRate));
- new LearnHebbLP3(tmpcon, MaxWeights, LearnTauDec,
- PostLearnTauDec, BaseLine, LearnRate, true));
- // new LearnRossum1(tmpcon, RossumCp, 0.003, 0.00005));
-
-
- MainSimLoop->AddSimElement(tmpcon);
- if (SaveInitialWeights) {
- tmpcon->Save();
- }
- tmpcon->SetAutoSave(false);
- ConnectionList->push_back(tmpcon);
- ++LayerNr;
- }
- }
- // Normalization
- if (VecCon) {
- VecFiringRateNormalize2* norm=0;
- if (Learn) {
- // FiringRateNormalization
- norm = new VecFiringRateNormalize2(FRateNormThreshold, 0.001, 10);
- norm->SetName("cnormForward");
- cout << "Adding connections to norm obj\n";fflush(stdout);
- for (VConIterator it = VConnectionList->begin(); it!=VConnectionList->end();++it) {
- norm->AddConnection(*it);
- }
- if (RewireForwardCon) {
- norm->SetRewiring(RewireThreshold, connectivity, RewInitialWeights);
- }
- MainSimLoop->AddSimElement(norm);
- }
- } else {
-
- FiringRateNormalize2* norm=0;
- if (Learn) {
- // FiringRateNormalization
- norm = new FiringRateNormalize2(FRateNormThreshold, 0.001, 10);
- norm->SetName("cnormForward");
- for (connectionIterator it = ConnectionList->begin(); it!=ConnectionList->end();++it) {
- norm->AddConnection(*it);
- }
- MainSimLoop->AddSimElement(norm);
- }
- }
- } else {
- cout << "No Layer List \n";
- }
-
- }
- ///smodMovieInput/////////////////////////
|