NuPIC  0.2.7.dev0
Numenta Platform for Intelligent Computing
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Static Public Attributes | List of all members
Segment Class Reference

The Segment class is a container for all of the segment variables and the synapses it owns. More...

Inherits object.

Public Member Functions

def dutyCycle
 Compute/update and return the positive activations duty cycle of this segment. More...
 
def debugPrint
 Print segment information for verbose messaging and debugging. More...
 
def freeNSynapses
 Free up some synapses in this segment. More...
 
def addSynapse
 Add a new synapse. More...
 
def updateSynapses
 Update a set of synapses in the segment. More...
 

Static Public Attributes

list dutyCycleTiers
 These are iteration count tiers used when computing segment duty cycle. More...
 
list dutyCycleAlphas
 This is the alpha used in each tier. More...
 

Detailed Description

The Segment class is a container for all of the segment variables and the synapses it owns.

Member Function Documentation

def addSynapse (   self,
  srcCellCol,
  srcCellIdx,
  perm 
)

Add a new synapse.

Parameters
srcCellColsource cell column
srcCellIdxsource cell index within the column
perminitial permanence
def debugPrint (   self)

Print segment information for verbose messaging and debugging.

This uses the following format:

ID:54413 True 0.64801 (24/36) 101 [9,1]0.75 [10,1]0.75 [11,1]0.75

where: 54413 - is the unique segment id True - is sequence segment 0.64801 - moving average duty cycle (24/36) - (numPositiveActivations / numTotalActivations) 101 - age, number of iterations since last activated [9,1]0.75 - synapse from column 9, cell #1, strength 0.75 [10,1]0.75 - synapse from column 10, cell #1, strength 0.75 [11,1]0.75 - synapse from column 11, cell #1, strength 0.75

def dutyCycle (   self,
  active = False,
  readOnly = False 
)

Compute/update and return the positive activations duty cycle of this segment.

This is a measure of how often this segment is providing good predictions.

Parameters
activeTrue if segment just provided a good prediction
readOnlyIf True, compute the updated duty cycle, but don't change the cached value. This is used by debugging print statements.
Returns
The duty cycle, a measure of how often this segment is providing good predictions.

NOTE: This method relies on different schemes to compute the duty cycle based on how much history we have. In order to support this tiered approach IT MUST BE CALLED ON EVERY SEGMENT AT EACH DUTY CYCLE TIER (dutyCycleTiers).

When we don't have a lot of history yet (first tier), we simply return number of positive activations / total number of iterations

After a certain number of iterations have accumulated, it converts into a moving average calculation, which is updated only when requested since it can be a bit expensive to compute on every iteration (it uses the pow() function).

The duty cycle is computed as follows:

dc[t] = (1-alpha) * dc[t-1] + alpha * value[t]

If the value[t] has been 0 for a number of steps in a row, you can apply all of the updates at once using:

dc[t] = (1-alpha)^(t-lastT) * dc[lastT]

We use the alphas and tiers as defined in dutyCycleAlphas and dutyCycleTiers.

def freeNSynapses (   self,
  numToFree,
  inactiveSynapseIndices,
  verbosity = 0 
)

Free up some synapses in this segment.

We always free up inactive synapses (lowest permanence freed up first) before we start to free up active ones.

Parameters
numToFreenumber of synapses to free up
inactiveSynapseIndiceslist of the inactive synapse indices.
def updateSynapses (   self,
  synapses,
  delta 
)

Update a set of synapses in the segment.

Parameters
tpThe owner TP
synapsesList of synapse indices to update
deltaHow much to add to each permanence
Returns
True if synapse reached 0

Member Data Documentation

list dutyCycleAlphas
static
Initial value:
1 = [None, 0.0032, 0.0010, 0.00032,
2  0.00010, 0.000032, 0.00001, 0.0000032,
3  0.0000010]

This is the alpha used in each tier.

dutyCycleAlphas[n] is used when iterationIdx > dutyCycleTiers[n].

list dutyCycleTiers
static
Initial value:
1 = [0, 100, 320, 1000,
2  3200, 10000, 32000, 100000,
3  320000]

These are iteration count tiers used when computing segment duty cycle.


The documentation for this class was generated from the following file: