@@ -19,39 +19,10 @@ namespace NeoCortexApi.Entities
1919 public class Connections
2020 {
2121
22- public static readonly double EPSILON = 0.00001 ;
23-
22+
2423 /////////////////////////////////////// Spatial Pooler Vars ///////////////////////////////////////////
2524
2625
27- //private int potentialRadius = 16;
28- //private double potentialPct = 0.5;
29- //private bool m_GlobalInhibition = false;
30- //private double m_LocalAreaDensity = -1.0;
31- //private double m_NumActiveColumnsPerInhArea;
32- //private double m_StimulusThreshold = 0;
33- //private double synPermInactiveDec = 0.008;
34- //private double synPermActiveInc = 0.05;
35- //private double synPermConnected = 0.10;
36- //private double synPermBelowStimulusInc;// = synPermConnected / 10.0;
37- //private double minPctOverlapDutyCycles = 0.001;
38- //private double minPctActiveDutyCycles = 0.001;
39- //private double predictedSegmentDecrement = 0.0;
40- //private int dutyCyclePeriod = 1000;
41- //private double maxBoost = 10.0;
42- //private bool wrapAround = true;
43- //private bool isBumpUpWeakColumnsDisabled = false;
44-
45- //private int numInputs = 1; //product of input dimensions
46- //private int numColumns = 1; //product of column dimensions
47-
48- //Extra parameter settings
49- //private double synPermMin = 0.0;
50- //private double synPermMax = 1.0;
51- //private double synPermTrimThreshold;// = synPermActiveInc / 2.0;
52- //private int updatePeriod = 50;
53- //private double initConnectedPct = 0.5;
54-
5526 //Internal state
5627 private double version = 1.0 ;
5728 public int SpIterationNum { get ; set ; } = 0 ;
@@ -61,34 +32,7 @@ public class Connections
6132 private double [ ] m_BoostedmOverlaps ;
6233 private int [ ] m_Overlaps ;
6334
64- /// <summary>
65- /// Manages input neighborhood transformations
66- /// </summary>
67- //private Topology inputTopology;
68- /// <summary>
69- /// Manages column neighborhood transformations
70- /// </summary>
71- //private Topology columnTopology;
72- /// <summary>
73- /// A matrix representing the shape of the input.
74- /// </summary>
75- //protected ISparseMatrix<int> inputMatrix;
76- /**
77- * Store the set of all inputs that are within each column's potential pool.
78- * 'potentialPools' is a matrix, whose rows represent cortical columns, and
79- * whose columns represent the input bits. if potentialPools[i][j] == 1,
80- * then input bit 'j' is in column 'i's potential pool. A column can only be
81- * connected to inputs in its potential pool. The indices refer to a
82- * flattened version of both the inputs and columns. Namely, irrespective
83- * of the topology of the inputs and columns, they are treated as being a
84- * one dimensional array. Since a column is typically connected to only a
85- * subset of the inputs, many of the entries in the matrix are 0. Therefore
86- * the potentialPool matrix is stored using the SparseObjectMatrix
87- * class, to reduce memory footprint and computation time of algorithms that
88- * require iterating over the data structure.
89- */
90- //private IFlatMatrix<Pool> potentialPools;
91-
35+
9236 /// <summary>
9337 /// Initialize a tiny random tie breaker. This is used to determine winning
9438 /// columns where the overlaps are identical.
@@ -104,23 +48,23 @@ public class Connections
10448 private AbstractSparseBinaryMatrix connectedCounts2 ;
10549
10650 /// <summary>
107- /// All cells. Initialized during initialization of the TemporalMemory .
51+ /// The cells currently active as a result of the TM compute .
10852 /// </summary>
109- public Cell [ ] Cells { get ; set ; }
53+ public ISet < Cell > ActiveCells { get => m_ActiveCells ; set => m_ActiveCells = value ; }
11054
11155 /// <summary>
112- /// The inhibition radius determines the size of a column's local
113- /// neighborhood. of a column. A cortical column must overcome the overlap
114- /// score of columns in its neighborhood in order to become actives. This
115- /// radius is updated every learning round. It grows and shrinks with the
116- /// average number of connected synapses per column.
56+ /// The winner cells in the current TM compute cycle. Cctive cells are winner cells in the trained TM.
57+ /// If the TM is not trained, segment has no active cells and all cells will be activated (bursting).
58+ /// One of all active column cells will be selected as the winner cell.
11759 /// </summary>
118- //private int m_InhibitionRadius = 0;
60+ public ISet < Cell > WinnerCells { get => winnerCells ; set => winnerCells = value ; }
61+
62+
63+ /// <summary>
64+ /// All cells. Initialized during initialization of the TemporalMemory.
65+ /// </summary>
66+ public Cell [ ] Cells { get ; set ; }
11967
120- //private double[] overlapDutyCycles;
121- //private double[] activeDutyCycles;
122- //private volatile double[] minOverlapDutyCycles;
123- //private volatile double[] minActiveDutyCycles;
12468 private double [ ] m_BoostFactors ;
12569
12670 /////////////////////////////////////// Temporal Memory Vars ///////////////////////////////////////////
@@ -131,88 +75,7 @@ public class Connections
13175 protected List < DistalDendrite > m_ActiveSegments = new List < DistalDendrite > ( ) ;
13276 protected List < DistalDendrite > m_MatchingSegments = new List < DistalDendrite > ( ) ;
13377
134- /// <summary>
135- /// Total number of columns
136- /// </summary>
137- //protected int[] columnDimensions = new int[] { 2048 };
138- /// <summary>
139- /// Total number of cells per column
140- /// </summary>
141- //protected int cellsPerColumn = 32;
142- /// <summary>
143- /// What will comprise the Layer input. Input (i.e. from encoder)
144- /// </summary>
145- //protected int[] inputDimensions = new int[] { 100 };
146- /// <summary>
147- /// If the number of active connected synapses on a segment
148- /// is at least this threshold, the segment is said to be active.
149- /// </summary>
150- //private int activationThreshold = 13;
151- /// <summary>
152- /// Radius around cell from which it can
153- /// sample to form distal {@link DistalDendrite} connections.
154- /// </summary>
155- //private int learningRadius = 2048;
156- /// <summary>
157- /// If the number of synapses active on a segment is at least this
158- /// threshold, it is selected as the best matching
159- /// cell in a bursting column.
160- /// </summary>
161- //private int minThreshold = 10;
162- /// <summary>
163- /// The maximum number of synapses added to a segment during learning.
164- /// </summary>
165- //private int maxNewSynapseCount = 20;
166- /// <summary>
167- /// The maximum number of segments (distal dendrites) allowed on a cell
168- /// </summary>
169- //private int maxSegmentsPerCell = 255;
170- /// <summary>
171- /// The maximum number of synapses allowed on a given segment (distal dendrite)
172- /// </summary>
173- //private int maxSynapsesPerSegment = 255;
174- /// <summary>
175- /// Initial permanence of a new synapse
176- /// </summary>
177- //private double initialPermanence = 0.21;
178- /// <summary>
179- /// If the permanence value for a synapse
180- /// is greater than this value, it is said
181- /// to be connected.
182- /// </summary>
183- //private double connectedPermanence = 0.50;
184- /// <summary>
185- /// Amount by which permanences of synapses
186- /// are incremented during learning.
187- /// </summary>
188- //private double permanenceIncrement = 0.10;
189- /// <summary>
190- /// Amount by which permanences of synapses
191- /// are decremented during learning.
192- /// </summary>
193- //private double permanenceDecrement = 0.10;
194-
195- /// <summary>
196- /// The main data structure containing columns, cells, and synapses
197- /// </summary>
198- //private AbstractSparseMatrix<Column> memory;
199-
200- //public HtmModuleTopology ColumnTopology
201- //{
202- // get
203- // {
204- // return this.HtmConfig.Memory?.ModuleTopology;
205- // }
206- //}
207-
208- //public HtmModuleTopology InputTopology
209- //{
210- // get
211- // {
212- // return this.HtmConfig.InputMatrix?.ModuleTopology;
213- // }
214- //}
215-
78+
21679 private HtmConfig m_HtmConfig = new HtmConfig ( ) ;
21780
21881 public HtmConfig HtmConfig
@@ -282,20 +145,24 @@ private set
282145
283146
284147
285- /////////////////////// Structural Elements /////////////////////////
148+ /////////////////////// Synapses and segments /////////////////////////
286149
287150 /// <summary>
288151 /// Reverse mapping from source cell to <see cref="Synapse"/>
289152 /// </summary>
290153 private Dictionary < Cell , LinkedHashSet < Synapse > > m_ReceptorSynapses ;
291154
155+ /// <summary>
156+ /// Distal segments of cells.
157+ /// </summary>
292158 protected Dictionary < Cell , List < DistalDendrite > > m_DistalSegments ;
293159
294160 /// <summary>
295161 /// Synapses, which belong to some distal dentrite segment.
296162 /// </summary>
297163 private Dictionary < Segment , List < Synapse > > m_DistalSynapses ;
298164
165+ // Proximal synapses are a part of the column.
299166 //protected Dictionary<Segment, List<Synapse>> proximalSynapses;
300167
301168 /** Helps index each new proximal Synapse */
@@ -324,7 +191,8 @@ private set
324191 protected List < int > m_FreeFlatIdxs = new List < int > ( ) ;
325192
326193 /// <summary>
327- /// Indexed segments by their global index (can contain nulls)
194+ /// Indexed segments by their global index (can contain nulls).
195+ /// Indexed list of distal segments.
328196 /// </summary>
329197 protected List < DistalDendrite > m_SegmentForFlatIdx = new List < DistalDendrite > ( ) ;
330198
@@ -2135,11 +2003,6 @@ public void Clear()
21352003 }
21362004
21372005
2138- public ISet < Cell > ActiveCells { get => m_ActiveCells ; set => m_ActiveCells = value ; }
2139-
2140-
2141- public ISet < Cell > WinnerCells { get => winnerCells ; set => winnerCells = value ; }
2142-
21432006 /// <summary>
21442007 /// Generates the list of predictive cells from parent cells of active segments.
21452008 /// </summary>
0 commit comments