/// <summary>
        /// Initializes a new instance of the DistalSynapse class and
        /// sets its input source and initial permanance values.
        /// </summary>
        /// <param name="inputSrc">An object providing source of the input to this synapse
        /// (a Column's Cell).</param>
        /// <param name="permanence">Initial permanence value.</param>
        public void Initialize(SynapseParams synapseParams, Cell inputSrc, float permanence)
        {
            base.Initialize(synapseParams);

            this.InputSource = inputSrc;
            this.Permanence  = permanence;
        }
        /// <summary>
        /// This version of Initialize() is used when loading data from disk.
        /// </summary>
        public new void Initialize(SynapseParams synapseParams)
        {
            base.Initialize(synapseParams);

            this.InputSource = null;
            this.Permanence  = 0.0f;
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new synapse for this segment attached to the specified input source.
        /// </summary>
        /// <param name="inputSource">The input source of the synapse to create.</param>
        /// <param name="initPerm">The initial permanence of the synapse.</param>
        /// <returns>Newly created synapse.</returns>
        public DistalSynapse CreateDistalSynapse(SynapseParams synapseParams, Cell inputSource, float initPerm)
        {
            var newSyn = new DistalSynapse();

            newSyn.Initialize(synapseParams, inputSource, initPerm);
            this.Synapses.Add(newSyn);
            return(newSyn);
        }
Esempio n. 4
0
        /// <summary>
        /// Create a new proximal synapse for this segment attached to the specified
        /// input cell.
        /// </summary>
        /// <param name="inputSource">The input source of the synapse to create.</param>
        /// <param name="initPerm">The initial permanence of the synapse.</param>
        /// <returns>Newly created synapse.</returns>
        public ProximalSynapse CreateProximalSynapse(SynapseParams synapseParams, DataSpace inputSource, ref DataPoint inputPoint, float permanence, float distanceToInput)
        {
            var newSyn = new ProximalSynapse();

            newSyn.Initialize(synapseParams, inputSource, ref inputPoint, permanence, distanceToInput);
            this.Synapses.Add(newSyn);
            return(newSyn);
        }
Esempio n. 5
0
 /// <summary>
 /// Create numSynapses new synapses attached to the specified
 /// set of learning cells.
 /// </summary>
 /// <param name="synapseCells">Set of available learning cells to form synapses to.</param>
 /// <param name="added">Set will be populated with synapses that were successfully added.</param>
 public void CreateSynapsesToLearningCells(ref List <Cell> synapseCells, SynapseParams synapseParams)
 {
     // Assume that cells were previously checked to prevent adding
     // synapses to the same cell more than once per segment.
     foreach (Cell cell in synapseCells)
     {
         this.CreateDistalSynapse(synapseParams, cell, synapseParams.InitialPermanence);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the Region class.
        /// </summary>
        /// <remarks>
        /// Prior to receiving any inputs, the region is initialized by computing a list of
        /// initial potential synapses for each column. This consists of a random set of
        /// inputs selected from the input space. Each input is represented by a synapse
        /// and assigned a random permanence value. The random permanence values are chosen
        /// with two criteria. First, the values are chosen to be in a small range around
        /// connectedPerm (the minimum permanence value at which a synapse is considered
        /// "connected"). This enables potential synapses to become connected (or
        /// disconnected) after a small number of training iterations. Second, each column
        /// has a natural center over the input region, and the permanence values have a bias
        /// towards this center (they have higher values near the center).
        ///
        /// In addition to this it was added a concept of Input Radius, which is an
        /// additional parameter to control how far away synapse connections can be made
        /// instead of allowing connections anywhere.  The reason for this is that in the
        /// case of video images I wanted to experiment with forcing each Column to only
        /// learn on a small section of the total input to more effectively learn lines or
        /// corners in a small section without being 'distracted' by learning larger patterns
        /// in the overall input space (which hopefully higher hierarchical Regions would
        /// handle more successfully).  Passing in -1 for input radius will mean no
        /// restriction which will more closely follow the Numenta doc if desired.
        /// </remarks>
        /// <param name="colGridSize">Point structure that represents the
        ///     region size in columns (ColumnSizeX * ColumnSizeY).
        /// </param>
        /// <param name="pctInputPerCol">The percent of input bits each column has potential
        ///     synapses for (PctInputCol).
        /// </param>
        /// <param name="pctMinOverlap">The minimum percent of column's proximal synapses
        ///     that must be active for a column to be even be considered during spatial
        ///     pooling.
        /// </param>
        /// <param name="predictionRadius">Furthest number of columns away to allow
        ///     distal synapses from each column/cell.
        /// </param>
        /// <param name="pctLocalActivity">Approximate percent of Columns within inhibition
        ///     radius to be winners after spatial inhibition.
        /// </param>
        /// <param name="maxBoost">The maximum allowed Boost value. Setting a max Boost value prevents
        ///     competition for activation from continuing indefinitely, and so
        ///     facilitates stabilization of representations.
        /// </param>
        /// <param name="boostPeriod">The time period in which Boosting may occur (-1 for no limit).
        /// </param>
        /// <param name="cellsPerCol">The number of context learning cells per column.
        /// </param>
        /// <param name="segActiveThreshold">The minimum number of synapses that must be
        ///     active for a segment to fire.
        /// </param>
        /// <param name="newSynapseCount">The number of new distal synapses added if
        ///     no matching ones found during learning.
        /// </param>
        /// <param name="hardcodedSpatial">If set to true, this Region must have exactly one
        ///     input, with the same dimensions as this Region. What is active in
        ///     that input will directly dictate what columns are activated in this
        ///     Region, with the spatial pooling and inhibition steps skipped.
        /// </param>
        /// <param name="spatialLearning">If true, spatial learning takes place as normal.
        /// </param>
        /// <param name="temporalLearning">If true, temporal learning takes place as normal.
        /// </param>
        /// <param name="outputColumnActivity">If true, there will be one value in this Region's
        ///     output representing activity of each column as a whole.
        /// </param>
        /// <param name="outputCellActivity">If true, there will be one value in this Region's
        ///     output representaing activity of each cell in each column.
        /// </param>
        public Region(string id, Point colGridSize, int hypercolumnDiameter, SynapseParams proximalSynapseParams, SynapseParams distalSynapseParams, float pctInputPerCol, float pctMinOverlap, int predictionRadius, InhibitionType inhibitionType, int inhibitionRadius, float pctLocalActivity, float boostRate, float maxBoost, int spatialLearningStartTime, int spatialLearningEndTime, int temporalLearningStartTime, int temporalLearningEndTime, int boostingStartTime, int boostingEndTime, int cellsPerCol, int segActiveThreshold, int newSynapseCount, int minMinOverlapToReuseSegment, int maxMinOverlapToReuseSegment, bool hardcodedSpatial, bool outputColumnActivity, bool outputCellActivity) : base(id)
        {
            this.SizeX = colGridSize.X;
            this.SizeY = colGridSize.Y;
            this.HypercolumnDiameter   = hypercolumnDiameter;
            this.ProximalSynapseParams = proximalSynapseParams;
            this.DistalSynapseParams   = distalSynapseParams;
            this.PredictionRadius      = predictionRadius;
            this._inhibitionType       = inhibitionType;
            this.InhibitionRadius      = inhibitionRadius;
            this.BoostRate             = boostRate;
            this.MaxBoost = maxBoost;
            this.SpatialLearningStartTime  = spatialLearningStartTime;
            this.SpatialLearningEndTime    = spatialLearningEndTime;
            this.TemporalLearningStartTime = temporalLearningStartTime;
            this.TemporalLearningEndTime   = temporalLearningEndTime;
            this.BoostingStartTime         = boostingStartTime;
            this.BoostingEndTime           = boostingEndTime;
            this.CellsPerCol                 = cellsPerCol;
            this.SegActiveThreshold          = segActiveThreshold;
            this.NewSynapsesCount            = newSynapseCount;
            this.MinMinOverlapToReuseSegment = minMinOverlapToReuseSegment;
            this.MaxMinOverlapToReuseSegment = maxMinOverlapToReuseSegment;
            this.PctLocalActivity            = pctLocalActivity;
            this.PctInputPerColumn           = pctInputPerCol;
            this.PctMinOverlap               = pctMinOverlap;
            this.HardcodedSpatial            = hardcodedSpatial;
            this.OutputColumnActivity        = outputColumnActivity;
            this.OutputCellActivity          = outputCellActivity;

            // The number of output values per column of this Region. If OutputCellActivity is true,
            // then this number will include the number of cells. If OutputColumnActivity is true, then
            // this number will include one value representing the activity of the column as a whole.
            this.SizeZ = (this.OutputColumnActivity
                              ? 1
                              : 0) + (this.OutputCellActivity
                                          ? this.CellsPerCol
                                          : 0);

            // Create the columns based on the size of the input data to connect to.
            var _random = new Random();

            this.Columns = new Column[this.SizeX * this.SizeY];
            for (int cy = 0; cy < this.SizeY; cy++)
            {
                for (int cx = 0; cx < this.SizeX; cx++)
                {
                    // Determine the current column's minOverlapToReuseSegment, a random value within this Region's range.
                    int minOverlapToReuseSegment = _random.Next() % (this.MaxMinOverlapToReuseSegment - this.MinMinOverlapToReuseSegment + 1) + this.MinMinOverlapToReuseSegment;

                    // Create a column with sourceCoords and GridCoords
                    this.Columns[(cy * this.SizeX) + cx] = new Column(this, new Point(cx, cy), minOverlapToReuseSegment);
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Create new synapse connections to the segment to be updated using
 /// the set of learning cells in this update info.
 /// </summary>
 public void CreateSynapsesToLearningCells(SynapseParams synapseParams)
 {
     this.Segment.CreateSynapsesToLearningCells(ref this.CellsThatWillLearn, synapseParams);
 }
Esempio n. 8
0
 public void Initialize(SynapseParams synapseParams)
 {
     this.SynapseParams = synapseParams;
     this.Permanence = 0.0f;
 }