コード例 #1
0
ファイル: HTMCell.cs プロジェクト: avogab/dooHTM
 // Constructor for a cell belonging to a column.
 public HTMCell(HTMColumn column, int indexInColumn)
     : this()
 {
     _x = column.X;
     _y = column.Y;
     _column = column;
     _indexInColumn = indexInColumn;
 }
コード例 #2
0
 // Constructor for a cell belonging to a column.
 public HTMCell(HTMColumn column, int indexInColumn)
     : this()
 {
     _x             = column.X;
     _y             = column.Y;
     _column        = column;
     _indexInColumn = indexInColumn;
 }
コード例 #3
0
ファイル: HTMRegionAgent.cs プロジェクト: avogab/dooHTM
        // param inputCells: input data matrix
        // param regionWidth: number of columns in the region
        // param regionHeight: number of rows in the region
        // param cellsPerColumn: Number of (temporal context) cells to use for each column.
        // param minOverlap: the minimum number of inputs that must be active for a column to be considered during the inhibition step.
        // param desiredLocalActivity number of columns that will be winners after the inhibition step.
        // param segmentActivationThreshold: the minimum number of synapse that must be active to activate a segment.
        // param minSegmentActivityForLearning: minimum segment activity for learning.
        // param proximalSegmentCoverage: the percentage of input matrix that belongs to each column (of course each column overlap with the other).
        public HTMRegionAgent(IDirector director, int regionWidth, int regionHeight, int cellsPerColumn,
                              int minOverlap, int desiredLocalActivity, int segmentActivationThreshold, int minSegmentActivityForLearning, double proximalSegmentCoverage)
        {
            _director                      = director;
            _width                         = regionWidth;
            _height                        = regionHeight;
            _cellsPerColumn                = cellsPerColumn;
            _minOverlap                    = minOverlap;
            _desiredLocalActivity          = desiredLocalActivity;
            _segmentActivationThreshold    = segmentActivationThreshold;
            _minSegmentActivityForLearning = minSegmentActivityForLearning;
            _proximalSegmentCoverage       = proximalSegmentCoverage;
            _doSpatialLearning             = true;
            _doTemporalLearning            = true;

            _random        = new RandomEx(0);
            _activeColumns = new List <HTMColumn>(_width * _height);

            // Create the columns
            _columns = new HTMColumn[_width, _height];
            double x;
            double y;

            for (int cx = 0; cx < _width; cx++)
            {
                for (int cy = 0; cy < _height; cy++)
                {
                    if (_width > 1)
                    {
                        x = (double)cx / (_width - 1);
                    }
                    else
                    {
                        x = 0.5;
                    }
                    if (_height > 1)
                    {
                        y = (double)cy / (_height - 1);
                    }
                    else
                    {
                        y = 0.5;
                    }
                    _columns[cx, cy] = new HTMColumn(this, cx, cy, x, y);
                }
            }

            // Create the output matrix.
            _outputCells = new Cells2D <HTMCell>(_width, _height);
        }
コード例 #4
0
ファイル: HTMRegionAgent.cs プロジェクト: avogab/dooHTM
        public HTMColumn GetMostActiveColumn()
        {
            HTMColumn mostActive = null;
            double    maxOverlap = double.MinValue;

            // TO DO: at the moment gets the last (in the array) most active
            foreach (HTMColumn col in _activeColumns)
            {
                if (col.Overlap > maxOverlap)
                {
                    maxOverlap = col.Overlap;
                    mostActive = col;
                }
            }
            return(mostActive);
        }
コード例 #5
0
ファイル: HTMRegionAgent.cs プロジェクト: avogab/dooHTM
        // param inputCells: input data matrix
        // param regionWidth: number of columns in the region
        // param regionHeight: number of rows in the region
        // param cellsPerColumn: Number of (temporal context) cells to use for each column.
        // param minOverlap: the minimum number of inputs that must be active for a column to be considered during the inhibition step.
        // param desiredLocalActivity number of columns that will be winners after the inhibition step.
        // param segmentActivationThreshold: the minimum number of synapse that must be active to activate a segment.
        // param minSegmentActivityForLearning: minimum segment activity for learning.
        // param proximalSegmentCoverage: the percentage of input matrix that belongs to each column (of course each column overlap with the other).
        public HTMRegionAgent(IDirector director, int regionWidth, int regionHeight, int cellsPerColumn,
            int minOverlap, int desiredLocalActivity, int segmentActivationThreshold, int minSegmentActivityForLearning, double proximalSegmentCoverage)
        {
            _director = director;
            _width = regionWidth;
            _height = regionHeight;
            _cellsPerColumn = cellsPerColumn;
            _minOverlap = minOverlap;
            _desiredLocalActivity = desiredLocalActivity;
            _segmentActivationThreshold = segmentActivationThreshold;
            _minSegmentActivityForLearning = minSegmentActivityForLearning;
            _proximalSegmentCoverage = proximalSegmentCoverage;
            _doSpatialLearning = true;
            _doTemporalLearning = true;

            _random = new RandomEx(0);
            _activeColumns = new List<HTMColumn>(_width * _height);

            // Create the columns
            _columns = new HTMColumn[_width, _height];
            double x;
            double y;
            for (int cx = 0; cx < _width; cx++)
            {
                for (int cy = 0; cy < _height; cy++)
                {
                    if (_width > 1)
                        x = (double)cx / (_width - 1);
                    else
                        x = 0.5;
                    if (_height > 1)
                        y = (double)cy / (_height - 1);
                    else
                        y = 0.5;
                    _columns[cx, cy] = new HTMColumn(this, cx, cy, x, y);
                }
            }

            // Create the output matrix.
            _outputCells = new Cells2D<HTMCell>(_width, _height);
        }
コード例 #6
0
ファイル: HTMRegionAgent.cs プロジェクト: avogab/dooHTM
        // Return all the columns within inhibitionRadius of the input column.
        // <avogab>
        // Use a +50% incremented inhibitionRadius to give more chance to reconsider far cells.
        // </avogab>
        internal List <HTMColumn> Neighbors(HTMColumn column)
        {
            int iradX = (int)(_inhibitionRadius * _width * 1.5);
            int iradY = (int)(_inhibitionRadius * _height * 1.5);
            int x0    = Math.Max(0, Math.Min(column.PosX - 1, column.PosX - iradX));
            int y0    = Math.Max(0, Math.Min(column.PosY - 1, column.PosY - iradY));
            int x1    = Math.Min(_width - 1, Math.Max(column.PosX + 1, column.PosX + iradX));
            int y1    = Math.Min(_height - 1, Math.Max(column.PosY + 1, column.PosY + iradY));

            List <HTMColumn> cols = new List <HTMColumn>((x1 - x0 + 1) * (y1 - y0 + 1));

            // TO DO : filter the column within a circle and not a rectangle!
            for (int x = x0; x <= x1; x++)
            {
                for (int y = y0; y <= y1; y++)
                {
                    cols.Add(_columns[x, y]);
                }
            }
            return(cols);
        }
コード例 #7
0
ファイル: HTMRegionAgent.cs プロジェクト: avogab/dooHTM
        // Return all the columns within inhibitionRadius of the input column.
        // <avogab>
        // Use a +50% incremented inhibitionRadius to give more chance to reconsider far cells.
        // </avogab>
        internal List<HTMColumn> Neighbors(HTMColumn column)
        {
            int iradX = (int)(_inhibitionRadius * _width * 1.5);
            int iradY = (int)(_inhibitionRadius * _height * 1.5);
            int x0 = Math.Max(0, Math.Min(column.PosX - 1, column.PosX - iradX));
            int y0 = Math.Max(0, Math.Min(column.PosY - 1, column.PosY - iradY));
            int x1 = Math.Min(_width - 1, Math.Max(column.PosX + 1, column.PosX + iradX));
            int y1 = Math.Min(_height - 1, Math.Max(column.PosY + 1, column.PosY + iradY));

            List<HTMColumn> cols = new List<HTMColumn>( (x1 - x0 + 1) * (y1 - y0 + 1) );
            // TO DO : filter the column within a circle and not a rectangle!
            for (int x = x0; x <= x1; x++)
                for (int y = y0; y <= y1; y++)
                    cols.Add(_columns[x, y]);
            return cols;
        }