예제 #1
0
  def __init__(self, name):
    """
    Initializes a new instance of this class.
    """

    Node.__init__(self, name, NodeType.sensor)

    #region Instance fields

    self.bits = []
    """An array of the bit objects that compose the current output of this node."""

    self.dataSource = None
    """Data source which provides records to fed into a region."""

    self.dataSourceType = DataSourceType.file
    """Type of the data source (File or Database)"""

    self.fileName = ''
    """The input file name to be handled. Returns the input file name only if it is in the project directory, full path otherwise."""

    self.databaseConnectionString = ""
    """Connection string of the database."""

    self.databaseTable = ''
    """Target table of the database."""

    self.encoder = None
    """Multi-encoder which concatenate sub-encodings to convert raw data to htm input and vice-versa."""

    self.encodings = []
    """List of sub-encodings that handles the input from database"""

    self.predictionsMethod = PredictionsMethod.reconstruction
    """Method used to get predicted values and their probabilities."""

    self.enableClassificationLearning = True
    """Switch for classification learning"""

    self.enableClassificationInference = True
    """Switch for classification inference"""

    #endregion

    #region Statistics properties

    self.statsPrecisionRate = 0.
예제 #2
0
    def __init__(self, name):
        """
    Initializes a new instance of this class.
    """

        Node.__init__(self, name, NodeType.sensor)

        #region Instance fields

        self.bits = []
        """An array of the bit objects that compose the current output of this node."""

        self.dataSource = None
        """Data source which provides records to fed into a region."""

        self.dataSourceType = DataSourceType.file
        """Type of the data source (File or Database)"""

        self.fileName = ''
        """The input file name to be handled. Returns the input file name only if it is in the project directory, full path otherwise."""

        self.databaseConnectionString = ""
        """Connection string of the database."""

        self.databaseTable = ''
        """Target table of the database."""

        self.encoder = None
        """Multi-encoder which concatenate sub-encodings to convert raw data to htm input and vice-versa."""

        self.encodings = []
        """List of sub-encodings that handles the input from database"""

        self.predictionsMethod = PredictionsMethod.reconstruction
        """Method used to get predicted values and their probabilities."""

        self.enableClassificationLearning = True
        """Switch for classification learning"""

        self.enableClassificationInference = True
        """Switch for classification inference"""

        #endregion

        #region Statistics properties

        self.statsPrecisionRate = 0.
예제 #3
0
    def __init__(self, name):
        """
        Initializes a new instance of this class.
        """

        Node.__init__(self, name, NodeType.SENSOR)

        # An array of the bit objects that compose the current output of this node.
        self.bits = []

        # Data source which provides records to fed into a region.
        self.data_source = None

        # Type of the data source (File or Database).
        self.data_source_type = DataSourceType.FILE

        # The input file name to be handled. Returns the input file name only if it is in the project directory, full path otherwise.
        self.file_name = ''

        # Connection string of the database.
        self.database_connection_string = ""

        # Target table of the database.
        self.database_table = ''

        # Multi-encoder which concatenate sub-encodings to convert raw data to htm input and vice-versa.
        self.encoder = None

        # List of sub-encodings that handles the input from database.
        self.encodings = []

        # Method used to get predicted values and their probabilities.
        self.predictions_method = PredictionsMethod.RECONSTRUCTION

        # Switch for classification learning.
        self.enable_classification_learning = True

        # Switch for classification inference.
        self.enable_classification_inference = True

        # Statistics
        self.stats_precision_rate = 0.0
예제 #4
0
  def __init__(self, name):
    """
    Initializes a new instance of this class.
    """

    Node.__init__(self, name, NodeType.region)

    #region Instance fields

    self.columns = []
    """List of columns that compose this region"""

    self._inputMap = []
    """An array representing the input map for this region."""

    #region Spatial Parameters

    self.enableSpatialLearning = True
    """Switch for spatial learning"""

    self.potentialRadius = 0
    """This parameter determines the extent of the input that each column can potentially be connected to. This can be thought of as the input bits that are visible to each column, or a 'receptiveField' of the field of vision. A large enough value will result in 'global coverage', meaning that each column can potentially be connected to every input bit. This parameter defines a square (or hyper square) area: a column will have a max square potential pool with sides of length 2 * potentialRadius + 1."""

    self.potentialPct = 0.5
    """The percent of the inputs, within a column's potential radius, that a column can be connected to. If set to 1, the column will be connected to every input within its potential radius. This parameter is used to give each column a unique potential pool when a large potentialRadius causes overlap between the columns. At initialization time we choose ((2*potentialRadius + 1)^(# inputDimensions) * potentialPct) input bits to comprise the column's potential pool."""

    self.globalInhibition = False
    """If true, then during inhibition phase the winning columns are selected as the most active columns from the region as a whole. Otherwise, the winning columns are selected with respect to their local neighborhoods. Using global inhibition boosts performance x60."""

    self.localAreaDensity = -1.0
    """The desired density of active columns within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected potential pools of all columns). The inhibition logic will insure that at most N columns remain ON within a local inhibition area, where N = localAreaDensity * (total number of columns in inhibition area)."""

    self.numActiveColumnsPerInhArea = int(0.02 * (self.width * self.height))
    """An alternate way to control the density of the active columns. If numActiveColumnsPerInhArea is specified then localAreaDensity must be less than 0, and vice versa. When using numActiveColumnsPerInhArea, the inhibition logic will insure that at most 'numActiveColumnsPerInhArea' columns remain ON within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected receptive fields of all columns). When using this method, as columns learn and grow their effective receptive fields, the inhibitionRadius will grow, and hence the net density of the active columns will *decrease*. This is in contrast to the localAreaDensity method, which keeps the density of active columns the same regardless of the size of their receptive fields."""

    self.stimulusThreshold = 0
    """This is a number specifying the minimum number of synapses that must be on in order for a columns to turn ON. The purpose of this is to prevent noise input from activating columns. Specified as a percent of a fully grown synapse."""

    self.proximalSynConnectedPerm = 0.10
    """The default connected threshold. Any synapse whose permanence value is above the connected threshold is a "connected synapse", meaning it can contribute to the cell's firing."""

    self.proximalSynPermIncrement = 0.1
    """The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown synapse."""

    self.proximalSynPermDecrement = 0.01
    """The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown synapse."""

    self.minPctOverlapDutyCycle = 0.001
    """A number between 0 and 1.0, used to set a floor on how often a column should have at least stimulusThreshold active inputs. Periodically, each column looks at the overlap duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to:
      minPctDutyCycleBeforeInh * max(other columns' duty cycles).
    On each iteration, any column whose overlap duty cycle falls below this computed value will get all of its permanence values boosted up by synPermActiveInc. Raising all permanences in response to a sub-par duty cycle before inhibition allows a cell to search for new inputs when either its previously learned inputs are no longer ever active, or when the vast majority of them have been "hijacked" by other columns."""

    self.minPctActiveDutyCycle = 0.001
    """A number between 0 and 1.0, used to set a floor on how often a column should be activate. Periodically, each column looks at the activity duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to:
      minPctDutyCycleAfterInh * max(other columns' duty cycles).
    On each iteration, any column whose duty cycle after inhibition falls below this computed value will get its internal boost factor increased."""

    self.dutyCyclePeriod = 1000
    """The period used to calculate duty cycles. Higher values make it take longer to respond to changes in boost or synPerConnectedCell. Shorter values make it more unstable and likely to oscillate."""

    self.maxBoost = 10.0
    """The maximum overlap boost factor. Each column's overlap gets multiplied by a boost factor before it gets considered for inhibition. The actual boost factor for a column is number between 1.0 and maxBoost. A boost factor of 1.0 is used if the duty cycle is >= minOverlapDutyCycle, maxBoost is used if the duty cycle is 0, and any duty cycle in between is linearly extrapolated from these 2 endpoints."""

    self.spSeed = -1
    """Seed for generate random values"""

    #endregion

    #region Temporal Parameters

    self.enableTemporalLearning = True
    """Switch for temporal learning"""

    self.numCellsPerColumn = 10
    """Number of cells per column. More cells, more contextual information"""

    self.distalSynInitialPerm = 0.11
    """The initial permanence of an distal synapse."""

    self.distalSynConnectedPerm = 0.50
    """The default connected threshold. Any synapse whose permanence value is above the connected threshold is a "connected synapse", meaning it can contribute to the cell's firing."""

    self.distalSynPermIncrement = 0.10
    """The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown synapse."""

    self.distalSynPermDecrement = 0.10
    """The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown synapse."""

    self.minThreshold = 8
    """If the number of synapses active on a segment is at least this threshold, it is selected as the best matching cell in a bursing column."""

    self.activationThreshold = 12
    """If the number of active connected synapses on a segment is at least this threshold, the segment is said to be active."""

    self.maxNumNewSynapses = 15
    """The maximum number of synapses added to a segment during learning."""

    self.tpSeed = 42
    """Seed for generate random values"""

    #endregion

    self.spatialPooler = None
    """Spatial Pooler instance"""

    self.temporalPooler = None
    """Temporal Pooler instance"""

    #endregion

    #region Statistics properties

    self.statsPrecisionRate = 0.
예제 #5
0
  def __init__(self, name):
    """
    Initializes a new instance of this class.
    """

    Node.__init__(self, name, NodeType.region)

    #region Instance fields

    self.columns = []
    """List of columns that compose this region"""

    self._inputMap = []
    """An array representing the input map for this region."""

    #region Spatial Parameters

    self.enableSpatialLearning = True
    """Switch for spatial learning"""

    self.potentialRadius = 0
    """This parameter determines the extent of the input that each column can potentially be connected to. This can be thought of as the input bits that are visible to each column, or a 'receptiveField' of the field of vision. A large enough value will result in 'global coverage', meaning that each column can potentially be connected to every input bit. This parameter defines a square (or hyper square) area: a column will have a max square potential pool with sides of length 2 * potentialRadius + 1."""

    self.potentialPct = 0.5
    """The percent of the inputs, within a column's potential radius, that a column can be connected to. If set to 1, the column will be connected to every input within its potential radius. This parameter is used to give each column a unique potential pool when a large potentialRadius causes overlap between the columns. At initialization time we choose ((2*potentialRadius + 1)^(# inputDimensions) * potentialPct) input bits to comprise the column's potential pool."""

    self.globalInhibition = False
    """If true, then during inhibition phase the winning columns are selected as the most active columns from the region as a whole. Otherwise, the winning columns are selected with respect to their local neighborhoods. Using global inhibition boosts performance x60."""

    self.localAreaDensity = -1.0
    """The desired density of active columns within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected potential pools of all columns). The inhibition logic will insure that at most N columns remain ON within a local inhibition area, where N = localAreaDensity * (total number of columns in inhibition area)."""

    self.numActiveColumnsPerInhArea = int(0.02 * (self.width * self.height))
    """An alternate way to control the density of the active columns. If numActiveColumnsPerInhArea is specified then localAreaDensity must be less than 0, and vice versa. When using numActiveColumnsPerInhArea, the inhibition logic will insure that at most 'numActiveColumnsPerInhArea' columns remain ON within a local inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn determined from the average size of the connected receptive fields of all columns). When using this method, as columns learn and grow their effective receptive fields, the inhibitionRadius will grow, and hence the net density of the active columns will *decrease*. This is in contrast to the localAreaDensity method, which keeps the density of active columns the same regardless of the size of their receptive fields."""

    self.stimulusThreshold = 0
    """This is a number specifying the minimum number of synapses that must be on in order for a columns to turn ON. The purpose of this is to prevent noise input from activating columns. Specified as a percent of a fully grown synapse."""

    self.proximalSynConnectedPerm = 0.10
    """The default connected threshold. Any synapse whose permanence value is above the connected threshold is a "connected synapse", meaning it can contribute to the cell's firing."""

    self.proximalSynPermIncrement = 0.1
    """The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown synapse."""

    self.proximalSynPermDecrement = 0.01
    """The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown synapse."""

    self.minPctOverlapDutyCycle = 0.001
    """A number between 0 and 1.0, used to set a floor on how often a column should have at least stimulusThreshold active inputs. Periodically, each column looks at the overlap duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to:
      minPctDutyCycleBeforeInh * max(other columns' duty cycles).
    On each iteration, any column whose overlap duty cycle falls below this computed value will get all of its permanence values boosted up by synPermActiveInc. Raising all permanences in response to a sub-par duty cycle before inhibition allows a cell to search for new inputs when either its previously learned inputs are no longer ever active, or when the vast majority of them have been "hijacked" by other columns."""

    self.minPctActiveDutyCycle = 0.001
    """A number between 0 and 1.0, used to set a floor on how often a column should be activate. Periodically, each column looks at the activity duty cycle of all other columns within its inhibition radius and sets its own internal minimal acceptable duty cycle to:
      minPctDutyCycleAfterInh * max(other columns' duty cycles).
    On each iteration, any column whose duty cycle after inhibition falls below this computed value will get its internal boost factor increased."""

    self.dutyCyclePeriod = 1000
    """The period used to calculate duty cycles. Higher values make it take longer to respond to changes in boost or synPerConnectedCell. Shorter values make it more unstable and likely to oscillate."""

    self.maxBoost = 10.0
    """The maximum overlap boost factor. Each column's overlap gets multiplied by a boost factor before it gets considered for inhibition. The actual boost factor for a column is number between 1.0 and maxBoost. A boost factor of 1.0 is used if the duty cycle is >= minOverlapDutyCycle, maxBoost is used if the duty cycle is 0, and any duty cycle in between is linearly extrapolated from these 2 endpoints."""

    self.spSeed = -1
    """Seed for generate random values"""

    #endregion

    #region Temporal Parameters

    self.enableTemporalLearning = True
    """Switch for temporal learning"""

    self.numCellsPerColumn = 10
    """Number of cells per column. More cells, more contextual information"""

    self.distalSynInitialPerm = 0.11
    """The initial permanence of an distal synapse."""

    self.distalSynConnectedPerm = 0.50
    """The default connected threshold. Any synapse whose permanence value is above the connected threshold is a "connected synapse", meaning it can contribute to the cell's firing."""

    self.distalSynPermIncrement = 0.10
    """The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown synapse."""

    self.distalSynPermDecrement = 0.10
    """The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown synapse."""

    self.minThreshold = 8
    """If the number of synapses active on a segment is at least this threshold, it is selected as the best matching cell in a bursing column."""

    self.activationThreshold = 12
    """If the number of active connected synapses on a segment is at least this threshold, the segment is said to be active."""

    self.maxNumNewSynapses = 15
    """The maximum number of synapses added to a segment during learning."""

    self.tpSeed = 42
    """Seed for generate random values"""

    #endregion

    self.spatialPooler = None
    """Spatial Pooler instance"""

    self.temporalPooler = None
    """Temporal Pooler instance"""

    #endregion

    #region Statistics properties

    self.statsPrecisionRate = 0.
예제 #6
0
    def __init__(self, name):
        """
        Initializes a new instance of this class.
        """

        Node.__init__(self, name, NodeType.REGION)

        # List of columns that compose this region.
        self.columns = []

        # An array representing the input map for this region.
        self.input_map = []

        # Switch for spatial learning.
        self.enable_spatial_learning = True

        # This parameter determines the extent of the input that each column can potentially be connected to. This
        # can be thought of as the input bits that are visible to each column, or a 'receptiveField' of the field of
        # vision. A large enough value will result in 'global coverage', meaning that each column can potentially be
        # connected to every input bit. This parameter defines a square (or hyper square) area: a column will have a
        # max square potential pool with sides of length 2 * potential_radius + 1.
        self.potential_radius = 0

        # The percent of the inputs, within a column's potential radius, that a column can be connected to. If set
        # to 1, the column will be connected to every input within its potential radius. This parameter is used to
        # give each column a unique potential pool when a large potential_radius causes overlap between the columns.
        # At initialization time we choose ((2*potential_radius + 1)^(# inputDimensions) * potential_pct) input bits to
        # comprise the column's potential pool.
        self.potential_pct = 0.5

        # If true, then during inhibition phase the winning columns are selected as the most active columns from the
        # region as a whole. Otherwise, the winning columns are selected with respect to their local neighborhoods.
        # Using global inhibition boosts performance x60.
        self.global_inhibition = False

        # The desired density of active columns within a local inhibition area (the size of which is set by the
        # internally calculated inhibitionRadius, which is in turn determined from the average size of the connected
        # potential pools of all columns). The inhibition logic will insure that at most N columns remain ON within a
        # local inhibition area, where N = local_area_density * (total number of columns in inhibition area).
        self.local_area_density = -1.0

        # An alternate way to control the density of the active columns. If num_active_columns_per_inh_area is specified
        # then local_area_density must be less than 0, and vice versa. When using num_active_columns_per_inh_area, the
        # inhibition logic will insure that at most 'num_active_columns_per_inh_area' columns remain ON within a local
        # inhibition area (the size of which is set by the internally calculated inhibitionRadius, which is in turn
        # determined from the average size of the connected receptive fields of all columns). When using this method,
        # as columns learn and grow their effective receptive fields, the inhibitionRadius will grow, and hence the net
        # density of the active columns will *decrease*. This is in contrast to the local_area_density method, which
        # keeps the density of active columns the same regardless of the size of their receptive fields.
        self.num_active_columns_per_inh_area = int(0.02 *
                                                   (self.width * self.height))

        # This is a number specifying the minimum number of synapses that must be on in order for a columns to turn ON.
        # The purpose of this is to prevent noise input from activating columns. Specified as a percent of a fully grown
        # synapse.
        self.stimulus_threshold = 0

        self.proximal_syn_connected_perm = 0.10
        # The default connected threshold. Any synapse whose permanence value is above the connected threshold is a
        # "connected synapse", meaning it can contribute to the cell's firing.

        self.proximal_syn_perm_increment = 0.1
        # The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown
        # synapse.

        self.proximal_syn_perm_decrement = 0.01
        # The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown
        # synapse.

        # A number between 0 and 1.0, used to set a floor on how often a column should have at least stimulus_threshold
        # active inputs. Periodically, each column looks at the overlap duty cycle of all other columns within its
        # inhibition radius and sets its own internal minimal acceptable duty cycle to:
        #     min_pct_duty_cycle_before_inh * max(other columns' duty cycles).
        # On each iteration, any column whose overlap duty cycle falls below this computed value will get all of its
        # permanence values boosted up by synPermActiveInc. Raising all permanences in response to a sub-par duty cycle
        # before inhibition allows a cell to search for new inputs when either its previously learned inputs are no
        # longer ever active, or when the vast majority of them have been "hijacked" by other columns.
        self.min_pct_overlap_duty_cycle = 0.001

        # A number between 0 and 1.0, used to set a floor on how often a column should be activate. Periodically, each
        # column looks at the activity duty cycle of all other columns within its inhibition radius and sets its own
        # internal minimal acceptable duty cycle to:
        #     min_pct_duty_cycle_after_inh * max(other columns' duty cycles).
        # On each iteration, any column whose duty cycle after inhibition falls below this computed value will get its
        # internal boost factor increased.
        self.min_pct_active_duty_cycle = 0.001

        # The period used to calculate duty cycles. Higher values make it take longer to respond to changes in boost or
        # synPerConnectedCell. Shorter values make it more unstable and likely to oscillate.
        self.duty_cycle_period = 1000

        # The maximum overlap boost factor. Each column's overlap gets multiplied by a boost factor before it gets
        # considered for inhibition. The actual boost factor for a column is number between 1.0 and max_boost. A boost
        # factor of 1.0 is used if the duty cycle is >= minOverlapDutyCycle, max_boost is used if the duty cycle is 0,
        # and any duty cycle in between is linearly extrapolated from these 2 endpoints.
        self.max_boost = 10.0

        # Seed for generate random values.
        self.sp_seed = -1

        # Switch for temporal learning.
        self.enable_temporal_learning = True

        # Number of cells per column. More cells, more contextual information.
        self.cells_per_column = 10

        # The initial permanence of an distal synapse.
        self.distal_syn_initial_perm = 0.11

        # The default connected threshold. Any synapse whose permanence value is above the connected threshold is a
        # "connected synapse", meaning it can contribute to the cell's firing.
        self.distal_syn_connected_perm = 0.50

        # The amount by which an active synapse is incremented in each round. Specified as a percent of a fully grown
        # synapse.
        self.distal_syn_perm_increment = 0.10

        # The amount by which an inactive synapse is decremented in each round. Specified as a percent of a fully grown
        # synapse.
        self.distal_syn_perm_decrement = 0.10

        # If the number of synapses active on a segment is at least this threshold, it is selected as the best matching
        # cell in a bursing column.
        self.min_threshold = 8

        # If the number of active connected synapses on a segment is at least this threshold, the segment is said to be active.
        self.activation_threshold = 12

        # The maximum number of synapses added to a segment during learning.
        self.max_new_synapses = 15

        # Seed for generate random values.
        self.tp_seed = 42

        # Spatial Pooler instance.
        self.spatial_pooler = None

        # Temporal Pooler instance.
        self.temporal_pooler = None

        # Statistics
        self.stats_precision_rate = 0.0