simmodules.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #ifndef _H_SIMMODULES
  2. #define _H_SIMMODULES
  3. #include "libcsim.hpp"
  4. #include "input.hpp"
  5. #include "simmodule.hpp"
  6. using namespace std;
  7. enum SimMod_StimSetType {Test, Parametric, Scan, FileName, IdlMovieFile, Ascii, MovieScan, Sequence};
  8. static const int SimMod_NumberStimSetTypes=8;
  9. class SimMod_CompetitiveInhibition: SimModule
  10. {
  11. private:
  12. layer* ExLayer;
  13. layer* InhLayer;
  14. int NInhNeurons;
  15. int NExInhConnections;
  16. int NInhExConnections;
  17. int NInhInhConnections;
  18. float ExInhStrength;
  19. float InhExStrength;
  20. float InhInhStrength;
  21. float NmdaAmpaRatio;
  22. Connection* conInhEx;
  23. Connection* conInhInh;
  24. Connection* conExInh;
  25. public:
  26. SimMod_CompetitiveInhibition(AnyOptionWrapper* _opt);
  27. virtual void SetCmdLineOptions();
  28. virtual layer* Setup(layer* _ExLayer, bool LoadWeights=false, bool VecCon=false, bool SaveInitialWeights=true);
  29. void SetAllInhExWeights(float WeightValue);
  30. void SetInhExWeightStrength(float WeightStrength);
  31. };
  32. class SimModuleITLayer: SimModule
  33. {
  34. private:
  35. float ITTauInhibition;
  36. // float ITTauFeeding;
  37. float NmdaAmpaRatio;
  38. int ITNx, ITNy;
  39. float ITLateralInhibitionWeight;
  40. float ITSelfLearnRate;
  41. bool ITSelfInhFacilitation;
  42. float SelfInhCdep;
  43. float SelfInhMaxWeight;
  44. float SelfInhMinWeight;
  45. float LatInhDistance;
  46. layer* ITLayer;
  47. connection *ConITSelfInh;
  48. SimMod_CompetitiveInhibition CompInh;
  49. public:
  50. SimModuleITLayer(AnyOptionWrapper* _opt);
  51. ~SimModuleITLayer();
  52. virtual void SetCmdLineOptions();
  53. virtual layer* Setup(
  54. SimLoop *MainSimLoop,
  55. int NType,
  56. bool LoadWeights,
  57. bool Learn,
  58. bool InhResetable=false, // inhibition layer per default not resetable (to keep inhibition level in network after reset)
  59. bool SaveInitialWeights=true
  60. );
  61. void SetInhExWeightStrength(float NewInhExStrength);
  62. bool LoadITWeights;
  63. SimMod_CompetitiveInhibition* GetCompInhibitionPtr(){return &CompInh;};
  64. SpikeTrain* ItSpikeTrain();
  65. };
  66. // erhaelt nur Gauss-Blob-verschalteten Vorwaerts-Input von MapLayer
  67. class InvarLayer: SimModule
  68. {
  69. private:
  70. float FWConStrength;
  71. layer* MapLayer;
  72. csimNeuronType NType;
  73. layer* LInvar;
  74. Connection* conMapLInvar;
  75. int Nx, Ny;
  76. bool VecCon;
  77. public:
  78. InvarLayer(AnyOptionWrapper* _opt);
  79. ~InvarLayer();
  80. virtual void SetCmdLineOptions();
  81. virtual layer* Setup(layer* _MapLayer, bool _veccon=false, bool SaveInitialWeights=true);
  82. virtual void TurnOn();
  83. virtual void TurnOff();
  84. };
  85. class SimModuleInput: SimModule
  86. {
  87. private:
  88. int StimulusSet;
  89. int StimulusNumber;
  90. string MovieDir;
  91. string StimFileName;
  92. string StimSequence;
  93. ObjMovie* MyMovie;
  94. SimMod_StimSetType SType;
  95. bool XContinuous;
  96. int NXParas, NYParas;
  97. int NTestStimuli;
  98. public:
  99. SimModuleInput(AnyOptionWrapper* _opt);
  100. // ~SimModuleInput();
  101. virtual void SetCmdLineOptions();
  102. virtual input* Setup(layer* TargetLayer, csimInputChannel InputNumber, float InputStrength);
  103. virtual void LoadMovie(int &InputNx, int &InputNy, int &NStimuli);
  104. int StimDur;
  105. int IsiDur;
  106. };
  107. class SimModuleMovieInput: SimModule
  108. {
  109. private:
  110. int NFilters, NLayers;
  111. string MovieDir;
  112. string StimFileName;
  113. string StimSequence;
  114. ObjMovie* MyMovie;
  115. // SimMod_StimSetType SType;
  116. bool XContinuous;
  117. int NXParas, NYParas;
  118. int InputNx, InputNy;
  119. float InitialWeights;
  120. float FRateNormThreshold;
  121. bool CommonInhibition;
  122. bool RewireForwardCon;
  123. layer* InhLayer;
  124. float ExInhWeights, InhExWeights;
  125. int TestStepSize; // default==1, wenn ==2, dann wird nur jeder zweite Stimulus in X bzw. Y Richtung als Test verwendet
  126. void LoadMovie();
  127. public:
  128. SimModuleMovieInput(AnyOptionWrapper* _opt);
  129. ~SimModuleMovieInput();
  130. virtual void SetCmdLineOptions();
  131. virtual int Setup(csimInputChannel InputNumber, float InputStrength, bool LoadWeights=false);
  132. virtual void SetTestMode();
  133. virtual void SetInputMode(InputMode mode);
  134. virtual void ConnectTo(layer* tolayer, bool LoadForwardWeights, bool Learn);
  135. int NStimuli;
  136. int NTestStimuli;
  137. int StimDur;
  138. int IsiDur;
  139. float LearnRate;
  140. };
  141. // smodMovieInput ist eine Weiterentwicklung von SimModuleMovieInput
  142. // sie soll die Nutzung von VecConnections ermoeglichen
  143. // smodMovieInput soll SimModuleMovieInput abloesen
  144. class smodMovieInput: SimModule
  145. {
  146. private:
  147. int NFilters, NLayers;
  148. string MovieDir;
  149. string StimFileName;
  150. string TestStimFileName;
  151. string SequenceFileName;
  152. ObjMovie* MyMovie;
  153. ObjMovie* StimMovie, TestMovie;
  154. // SimMod_StimSetType SType;
  155. bool XContinuous;
  156. int NXParas, NYParas;
  157. int InputNx, InputNy;
  158. float InitialWeights;
  159. float TauDecLearnPre;
  160. float TauDecLearnPost;
  161. float FRateNormThreshold;
  162. bool CommonInhibition;
  163. bool RewireForwardCon;
  164. bool OnOffInput; //< true: every input frame is feed into two layers: on layer (positive values) and off layer (negative values)
  165. layer* InhLayer;
  166. float ExInhWeights, InhExWeights;
  167. int TestStepSize; // default==1, wenn ==2, dann wird nur jeder zweite Stimulus in X bzw. Y Richtung als Test verwendet
  168. void LoadMovie(string _StimFileName);
  169. void ChangeMovie(ObjMovie* _NewMovie);
  170. public:
  171. smodMovieInput(AnyOptionWrapper* _opt);
  172. ~smodMovieInput();
  173. virtual void SetCmdLineOptions();
  174. virtual int Setup(csimInputChannel InputNumber, float InputStrength, bool LoadWeights=false);
  175. void SetNoiseAmplitude(float sigma);
  176. virtual void SetTestMode();
  177. virtual void SetInputMode(InputMode mode);
  178. virtual void ConnectTo(layer* tolayer, bool LoadForwardWeights, bool Learn, bool VecCon=false, bool SaveInitialWeights=true);
  179. int NStimuli;
  180. int NTestStimuli;
  181. int StimDur;
  182. int IsiDur;
  183. float LearnRate;
  184. };
  185. #endif /*_H_SIMMODULES */