Inheritance: ISpatialCell
Example #1
0
 public HTMSegment(HTMCell cell, int activationThreshold)
 {
     _cell = cell;
     _activationThreshold = activationThreshold;
     _synapses            = new List <HTMSynapse>();
     _isSequence          = false;
 }
Example #2
0
 public HTMCellViewer(HTMCell cell)
 {
     InitializeComponent();
     _cell     = cell;
     this.Text = "Cell " + _cell.Column.PosX + "," + _cell.Column.PosY + " index in column: " + _cell.IndexInColumn;
     UpdateView();
 }
Example #3
0
 public HTMSegment(HTMCell cell, int activationThreshold)
 {
     _cell = cell;
     _activationThreshold = activationThreshold;
     _synapses = new List<HTMSynapse>();
     _isSequence = false;
 }
Example #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            _g.Clear(_backgroundColor);

            if (_region == null)
            {
                return;
            }

            int x1, y1, x2, y2;
            int width  = _bitmap.Width;
            int height = _bitmap.Height;

            _colSize = Math.Max(Math.Min(width / _region.Width, height / _region.Height) - 2, 2);

            foreach (HTMColumn col in _region.Columns)
            {
                x1 = (int)(col.X * (width - _colSize - 1));
                x2 = (int)(col.X * (width - _colSize - 1)) + _colSize;
                y1 = (int)(col.Y * (height - _colSize - 1));
                y2 = (int)(col.Y * (height - _colSize - 1)) + _colSize;

                HTMCell cell = col.Cells[_indexInColumn];
                if (cell.GetPredicting(0))
                {
                    //_g.FillEllipse(_predictiveCellBrush, x1, y1, x2 - x1, y2 - y1);
                    //_g.DrawEllipse(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);

                    _g.FillRectangle(_predictiveCellBrush, x1, y1, x2 - x1, y2 - y1);
                    _g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);
                }
                else if (cell.GetLearning(0))
                {
                    //_g.FillEllipse(_learningCellBrush, x1, y1, x2 - x1, y2 - y1);
                    //_g.DrawEllipse(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);

                    _g.FillRectangle(_learningCellBrush, x1, y1, x2 - x1, y2 - y1);
                    _g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);
                }
                else if (cell.GetActive(0))
                {
                    //    _g.DrawEllipse(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);

                    _g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 2), x1, y1, x2 - x1, y2 - y1);
                }
                else
                {
                    //_g.DrawEllipse(new Pen(new SolidBrush(Color.Black)), x1, y1, x2 - x1, y2 - y1);

                    _g.DrawRectangle(new Pen(new SolidBrush(Color.Black)), x1, y1, x2 - x1, y2 - y1);
                }
            }
            _g1.DrawImageUnscaled(_bitmap, 0, layerLabel.Height + layerLabel.Top);

            // TO DO : move in other method!
            foreach (HTMCellViewer cellViewer in _cellViewers)
            {
                cellViewer.UpdateView();
            }
        }
Example #5
0
 public HTMCellViewer(HTMCell cell)
 {
     InitializeComponent();
     _cell = cell;
     this.Text = "Cell " + _cell.Column.PosX + "," + _cell.Column.PosY + " index in column: " + _cell.IndexInColumn;
     UpdateView();
 }
Example #6
0
        // For the given column, return the cell with the best matching segment.
        // If no cell has a matching segment, then return the cell with the fewest number of segments.
        public CellSegmentInfo GetBestMatchingCell(bool sequence, int t)
        {
            HTMCell    bestCell  = null;
            HTMSegment bestSeg   = null;
            int        bestCount = 0;
            HTMSegment seg;
            int        synapseCount;

            foreach (HTMCell cell in _cells)
            {
                seg = cell.GetBestMatchingSegment(t, sequence);
                // TO DO . to study in depth. the previsous function is aggressive in finding the segment but
                // nevertheless exclude segment with activation under minThreshold, this could bring
                // to add step by step similar segments?
                if (seg != null)
                {
                    synapseCount = seg.GetActiveSynapses(t, false, false).Count;
                    if (synapseCount > bestCount)
                    {
                        bestCell  = cell;
                        bestSeg   = seg;
                        bestCount = synapseCount;
                    }
                }
            }

            if (bestCell == null)
            {
                int fewestSegmentCount = int.MaxValue;
                foreach (HTMCell cell in _cells)
                {
                    if (cell.DistalSegments.Count < fewestSegmentCount)
                    {
                        fewestSegmentCount = cell.DistalSegments.Count;
                        bestCell           = cell;
                        //if (cell.DistalSegments.Count > 0)
                        //    bestSeg = cell.DistalSegments[0]; // choose the first segment
                    }
                }
            }

            CellSegmentInfo cellSegmentInfo = new CellSegmentInfo();

            cellSegmentInfo.Cell    = bestCell;
            cellSegmentInfo.Segment = bestSeg;
            return(cellSegmentInfo);
        }
Example #7
0
 public HTMSynapse(HTMCell inputCell, double permanence = _initialPermanence)
 {
     _inputCell  = inputCell;
     _permanence = permanence;
 }
Example #8
0
 public HTMSynapse(HTMCell inputCell, double permanence = _initialPermanence)
 {
     _inputCell = inputCell;
     _permanence = permanence;
 }