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

Class implementing the Temporal Memory algorithm. More...

Inherits object.

Public Member Functions

def __init__
 
def compute
 Feeds input record through TM, performing inference and learning. More...
 
def computeFn
 'Functional' version of compute. More...
 
def reset
 Indicates the start of a new sequence. More...
 
def activateCorrectlyPredictiveCells
 Phase 1: Activate the correctly predictive cells. More...
 
def burstColumns
 Phase 2: Burst unpredicted columns. More...
 
def learnOnSegments
 Phase 3: Perform learning by adapting segments. More...
 
def computePredictiveCells
 Phase 4: Compute predictive cells due to lateral input on distal dendrites. More...
 
def bestMatchingCell
 Gets the cell with the best matching segment (see TM.bestMatchingSegment) that has the largest number of active synapses of all best matching segments. More...
 
def bestMatchingSegment
 Gets the segment on a cell with the largest number of activate synapses, including all synapses with non-zero permanences. More...
 
def leastUsedCell
 Gets the cell with the smallest number of segments. More...
 
def adaptSegment
 Updates synapses on segment. More...
 
def pickCellsToLearnOn
 Pick cells to form distal connections to. More...
 
def columnForCell
 Returns the index of the column that a cell belongs to. More...
 
def cellsForColumn
 Returns the indices of cells that belong to a column. More...
 
def numberOfColumns
 Returns the number of columns in this layer. More...
 
def numberOfCells
 Returns the number of cells in this layer. More...
 
def mapCellsToColumns
 Maps cells to the columns they belong to. More...
 
def write
 Writes serialized data to proto object. More...
 
def read
 Reads deserialized data from proto object. More...
 
def __eq__
 Equality operator for TemporalMemory instances. More...
 
def __ne__
 Non-equality operator for TemporalMemory instances. More...
 

Static Public Member Functions

def activeSynapsesForSegment
 Returns the synapses on a segment that are active due to lateral input from active cells. More...
 

Detailed Description

Class implementing the Temporal Memory algorithm.

Constructor & Destructor Documentation

def __init__ (   self,
  columnDimensions = (2048,,
  cellsPerColumn = 32,
  activationThreshold = 13,
  initialPermanence = 0.21,
  connectedPermanence = 0.50,
  minThreshold = 10,
  maxNewSynapseCount = 20,
  permanenceIncrement = 0.10,
  permanenceDecrement = 0.10,
  predictedSegmentDecrement = 0.0,
  seed = 42 
)
Parameters
columnDimensions(list) Dimensions of the column space
cellsPerColumn(int) Number of cells per column
activationThreshold(int) If the number of active connected synapses on a segment is at least this threshold, the segment is said to be active.
initialPermanence(float) Initial permanence of a new synapse.
connectedPermanence(float) If the permanence value for a synapse is greater than this value, it is said to be connected.
minThreshold(int) If the number of synapses active on a segment is at least this threshold, it is selected as the best matching cell in a bursting column.
maxNewSynapseCount(int) The maximum number of synapses added to a segment during learning.
permanenceIncrement(float) Amount by which permanences of synapses are incremented during learning.
permanenceDecrement(float) Amount by which permanences of synapses are decremented during learning.
predictedSegmentDecrement(float) Amount by which active permanences of synapses of previously predicted but inactive segments are decremented.
seed(int) Seed for the random number generator.

Member Function Documentation

def __eq__ (   self,
  other 
)

Equality operator for TemporalMemory instances.

 Checks if two instances are functionally identical
 (might have different internal state).
Parameters
other(TemporalMemory) TemporalMemory instance to compare to
def __ne__ (   self,
  other 
)

Non-equality operator for TemporalMemory instances.

 Checks if two instances are not functionally identical
 (might have different internal state).
Parameters
other(TemporalMemory) TemporalMemory instance to compare to
def activateCorrectlyPredictiveCells (   self,
  prevPredictiveCells,
  prevMatchingCells,
  activeColumns 
)

Phase 1: Activate the correctly predictive cells.

 Pseudocode:

   - for each prev predictive cell
     - if in active column
       - mark it as active
       - mark it as winner cell
       - mark column as predicted
     - if not in active column
       - mark it as an predicted but inactive cell
Parameters
prevPredictiveCells(set) Indices of predictive cells in t-1
activeColumns(set) Indices of active columns in t
Returns
(tuple) Contains: activeCells (set), winnerCells (set), predictedColumns (set), predictedInactiveCells (set)
def activeSynapsesForSegment (   segment,
  activeCells,
  connections 
)
static

Returns the synapses on a segment that are active due to lateral input from active cells.

Parameters
segment(int) Segment index
activeCells(set) Indices of active cells
connections(Connections) Connectivity of layer
Returns
(set) Indices of active synapses on segment
def adaptSegment (   self,
  segment,
  activeSynapses,
  connections,
  permanenceIncrement,
  permanenceDecrement 
)

Updates synapses on segment.

 Strengthens active synapses; weakens inactive synapses.
Parameters
segment(int) Segment index
activeSynapses(set) Indices of active synapses
connections(Connections) Connectivity of layer
permanenceIncrement(float) Amount to increment active synapses
permanenceDecrement(float) Amount to decrement inactive synapses
def bestMatchingCell (   self,
  cells,
  activeCells,
  connections 
)

Gets the cell with the best matching segment (see TM.bestMatchingSegment) that has the largest number of active synapses of all best matching segments.

 If none were found, pick the least used cell (see `TM.leastUsedCell`).
Parameters
cells(set) Indices of cells
activeCells(set) Indices of active cells
connections(Connections) Connectivity of layer
Returns
(tuple) Contains: cell (int), bestSegment (int)
def bestMatchingSegment (   self,
  cell,
  activeCells,
  connections 
)

Gets the segment on a cell with the largest number of activate synapses, including all synapses with non-zero permanences.

Parameters
cell(int) Cell index
activeCells(set) Indices of active cells
connections(Connections) Connectivity of layer
Returns
(tuple) Contains: segment (int), connectedActiveSynapses (set)
def burstColumns (   self,
  activeColumns,
  predictedColumns,
  prevActiveCells,
  prevWinnerCells,
  connections 
)

Phase 2: Burst unpredicted columns.

 Pseudocode:

   - for each unpredicted active column
     - mark all cells as active
     - mark the best matching cell as winner cell
       - (learning)
         - if it has no matching segment
           - (optimization) if there are prev winner cells
             - add a segment to it
         - mark the segment as learning
Parameters
activeColumns(set) Indices of active columns in t
predictedColumns(set) Indices of predicted columns in t
prevActiveCells(set) Indices of active cells in t-1
prevWinnerCells(set) Indices of winner cells in t-1
connections(Connections) Connectivity of layer
Returns
(tuple) Contains: activeCells (set), winnerCells (set), learningSegments (set)
def cellsForColumn (   self,
  column 
)

Returns the indices of cells that belong to a column.

Parameters
column(int) Column index
Returns
(set) Cell indices
def columnForCell (   self,
  cell 
)

Returns the index of the column that a cell belongs to.

Parameters
cell(int) Cell index
Returns
(int) Column index
def compute (   self,
  activeColumns,
  learn = True 
)

Feeds input record through TM, performing inference and learning.

 Updates member variables with new state.
Parameters
activeColumns(set) Indices of active columns in t
def computeFn (   self,
  activeColumns,
  prevPredictiveCells,
  prevActiveSegments,
  prevActiveCells,
  prevWinnerCells,
  prevMatchingSegments,
  prevMatchingCells,
  connections,
  learn = True 
)

'Functional' version of compute.

 Returns new state.
Parameters
activeColumns(set) Indices of active columns in t
prevPredictiveCells(set) Indices of predictive cells in t-1
prevActiveSegments(set) Indices of active segments in t-1
prevActiveCells(set) Indices of active cells in t-1
prevWinnerCells(set) Indices of winner cells in t-1
prevMatchingSegments(set) Indices of matching segments in t-1
prevMatchingCells(set) Indices of matching cells in t-1
connections(Connections) Connectivity of layer
learn(bool) Whether or not learning is enabled
Returns
(tuple) Contains: activeCells (set), winnerCells (set), activeSegments (set), predictiveCells (set), 'matchingSegments'(set), 'matchingCells' (set)
def computePredictiveCells (   self,
  activeCells,
  connections 
)

Phase 4: Compute predictive cells due to lateral input on distal dendrites.

 Pseudocode:

   - for each distal dendrite segment with activity >= activationThreshold
     - mark the segment as active
     - mark the cell as predictive

   - if predictedSegmentDecrement > 0
     - for each distal dendrite segment with unconnected
       activity >=  minThreshold
       - mark the segment as matching
       - mark the cell as matching

 Forward propagates activity from active cells to the synapses that touch
 them, to determine which synapses are active.
Parameters
activeCells(set) Indices of active cells in t
connections(Connections) Connectivity of layer
Returns
(tuple) Contains: activeSegments (set), predictiveCells (set), matchingSegments (set), matchingCells (set)
def learnOnSegments (   self,
  prevActiveSegments,
  learningSegments,
  prevActiveCells,
  winnerCells,
  prevWinnerCells,
  connections,
  predictedInactiveCells,
  prevMatchingSegments 
)

Phase 3: Perform learning by adapting segments.

 Pseudocode:

   - (learning) for each prev active or learning segment
     - if learning segment or from winner cell
       - strengthen active synapses
       - weaken inactive synapses
     - if learning segment
       - add some synapses to the segment
         - subsample from prev winner cells

   - if predictedSegmentDecrement > 0
     - for each previously matching segment
       - if cell is a predicted inactive cell
         - weaken active synapses but don't touch inactive synapses
Parameters
prevActiveSegments(set) Indices of active segments in t-1
learningSegments(set) Indices of learning segments in t
prevActiveCells(set) Indices of active cells in t-1
winnerCells(set) Indices of winner cells in t
prevWinnerCells(set) Indices of winner cells in t-1
connections(Connections) Connectivity of layer
predictedInactiveCells(set) Indices of predicted inactive cells
prevMatchingSegments(set) Indices of segments with
def leastUsedCell (   self,
  cells,
  connections 
)

Gets the cell with the smallest number of segments.

 Break ties randomly.
Parameters
cells(set) Indices of cells
connections(Connections) Connectivity of layer
Returns
(int) Cell index
def mapCellsToColumns (   self,
  cells 
)

Maps cells to the columns they belong to.

Parameters
cells(set) Cells
Returns
(dict) Mapping from columns to their cells in cells
def numberOfCells (   self)

Returns the number of cells in this layer.

Returns
(int) Number of cells
def numberOfColumns (   self)

Returns the number of columns in this layer.

Returns
(int) Number of columns
def pickCellsToLearnOn (   self,
  n,
  segment,
  winnerCells,
  connections 
)

Pick cells to form distal connections to.

 TODO: Respect topology and learningRadius
Parameters
n(int) Number of cells to pick
segment(int) Segment index
winnerCells(set) Indices of winner cells in t
connections(Connections) Connectivity of layer
Returns
(set) Indices of cells picked
def read (   cls,
  proto 
)

Reads deserialized data from proto object.

Parameters
proto(DynamicStructBuilder) Proto object
Returns
(TemporalMemory) TemporalMemory instance
def reset (   self)

Indicates the start of a new sequence.

Resets sequence state of the TM.

def write (   self,
  proto 
)

Writes serialized data to proto object.

Parameters
proto(DynamicStructBuilder) Proto object

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