Example #1
0
        public bool Step()
        {
            foreach (HTMColumn col in _columns)
            {
                foreach (HTMCell cell in col.Cells)
                {
                    cell.Step();
                }
            }

            // Retrieve the region's input cell.
            Cells2D <HTMCell> inputCells = (Cells2D <HTMCell>)_inputAgent.GetOutput();

            // TO DO: avoid the copy
            for (int x = 0; x < inputCells.Width; x++)
            {
                for (int y = 0; y < inputCells.Height; y++)
                {
                    _inputCells[x, y].SetActive(inputCells[x, y].GetActive(0));
                }
            }

            StepSpatialPooling();
            StepTemporalPooling();
            return(true);
        }
Example #2
0
 public Cellls2dViewer(Cells2D<HTMCell> inputs)
 {
     InitializeComponent();
     _inputs = inputs;
     pictureBox.Width = cellWidth * _inputs.Width;
     pictureBox.Height = cellHeight * _inputs.Height;
     Graphics g = pictureBox.CreateGraphics();
     g.Clear(Color.Gray);
 }
Example #3
0
 public bool Initialize()
 {
     if (_binaryData.Data == null || _binaryData.Data.Count == 0)
     {
         _director.Log("No data uploaded.");
         return(false);
     }
     _outputCells            = new Cells2D <HTMCell>(_width, 1);
     filePathTextBox.Enabled = false;
     pathButton.Enabled      = false;
     return(true);
 }
Example #4
0
 public bool Initialize()
 {
     if (_binaryData.Data == null || _binaryData.Data.Count == 0)
     {
         _director.Log("No data uploaded.");
         return false;
     }
     _outputCells = new Cells2D<HTMCell>(_width, 1);
     filePathTextBox.Enabled = false;
     pathButton.Enabled = false;
     return true;
 }
Example #5
0
        // 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);
        }
Example #6
0
        public bool Initialize()
        {
            _currentImage = null;
            _previousImage = null;
            _outputWidth = int.Parse(outputSizeComboBox.Text.Substring(0, 3));
            _outputHeight = int.Parse(outputSizeComboBox.Text.Substring(6, 3));
            _blankImage = new Image<Gray, byte>(_outputWidth, _outputHeight);
            _outputCells = new Cells2D<HTMCell>(_outputWidth, _outputHeight);

            //
            outputSizeComboBox.Enabled = false;
            detectMotionCheckBox.Enabled = true;
            return true;
        }
Example #7
0
        // 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);
        }