![]() |
NuPIC
0.2.7.dev0
Numenta Platform for Intelligent Computing
|
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... | |
The Segment class is a container for all of the segment variables and the synapses it owns.
def addSynapse | ( | self, | |
srcCellCol, | |||
srcCellIdx, | |||
perm | |||
) |
Add a new synapse.
srcCellCol | source cell column |
srcCellIdx | source cell index within the column |
perm | initial 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.
active | True if segment just provided a good prediction |
readOnly | If True, compute the updated duty cycle, but don't change the cached value. This is used by debugging print statements. |
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.
numToFree | number of synapses to free up |
inactiveSynapseIndices | list of the inactive synapse indices. |
def updateSynapses | ( | self, | |
synapses, | |||
delta | |||
) |
Update a set of synapses in the segment.
tp | The owner TP |
synapses | List of synapse indices to update |
delta | How much to add to each permanence |
|
static |
|
static |