예제 #1
0
 /**
  * This method ensures that each column has enough connections to input bits to allow it to become
  * active. Since a column must have at least 'stimulusThreshold' overlaps in order to be
  * considered during the inhibition phase, columns without such minimal number of connections,
  * even if all the input bits they are connected to turn on, have no chance of obtaining the
  * minimum threshold. For such columns, the permanence values are increased until the minimum
  * number of connections are formed.
  *
  * <p>Note: This method services the "sparse" versions of corresponding methods
  *
  * @param c The {@link Connections} memory
  * @param perm permanence values
  */
 public void raisePermanenceToThresholdSparse(Connections c, double[] perm) {
   ArrayUtils.clip(perm, c.getSynPermMin(), c.getSynPermMax());
   while (true) {
     int numConnected = ArrayUtils.valueGreaterCount(c.getSynPermConnected(), perm);
     if (numConnected >= c.getStimulusThreshold()) return;
     ArrayUtils.raiseValuesBy(c.getSynPermBelowStimulusInc(), perm);
   }
 }
예제 #2
0
  /**
   * This method updates the permanence matrix with a column's new permanence values. The column is
   * identified by its index, which reflects the row in the matrix, and the permanence is given in
   * 'sparse' form, (i.e. an array whose members are associated with specific indexes). It is in
   * charge of implementing 'clipping' - ensuring that the permanence values are always between 0
   * and 1 - and 'trimming' - enforcing sparseness by zeroing out all permanence values below
   * 'synPermTrimThreshold'. Every method wishing to modify the permanence matrix should do so
   * through this method.
   *
   * @param c the {@link Connections} which is the memory model.
   * @param perm An array of permanence values for a column. The array is "sparse", i.e. it contains
   *     an entry for each input bit, even if the permanence value is 0.
   * @param column The column in the permanence, potential and connectivity matrices
   * @param raisePerm a boolean value indicating whether the permanence values
   */
  public void updatePermanencesForColumnSparse(
      Connections c, double[] perm, Column column, int[] maskPotential, boolean raisePerm) {
    if (raisePerm) {
      raisePermanenceToThresholdSparse(c, perm);
    }

    ArrayUtils.lessThanOrEqualXThanSetToY(perm, c.getSynPermTrimThreshold(), 0);
    ArrayUtils.clip(perm, c.getSynPermMin(), c.getSynPermMax());
    column.setProximalPermanencesSparse(c, perm, maskPotential);
  }
예제 #3
0
  /**
   * This method ensures that each column has enough connections to input bits to allow it to become
   * active. Since a column must have at least 'stimulusThreshold' overlaps in order to be
   * considered during the inhibition phase, columns without such minimal number of connections,
   * even if all the input bits they are connected to turn on, have no chance of obtaining the
   * minimum threshold. For such columns, the permanence values are increased until the minimum
   * number of connections are formed.
   *
   * @param c the {@link Connections} memory
   * @param perm the permanence values
   * @param maskPotential
   */
  public void raisePermanenceToThreshold(Connections c, double[] perm, int[] maskPotential) {
    if (maskPotential.length < c.getStimulusThreshold()) {
      throw new IllegalStateException(
          "This is likely due to a "
              + "value of stimulusThreshold that is too large relative "
              + "to the input size. [len(mask) < self._stimulusThreshold]");
    }

    ArrayUtils.clip(perm, c.getSynPermMin(), c.getSynPermMax());
    while (true) {
      int numConnected =
          ArrayUtils.valueGreaterCountAtIndex(c.getSynPermConnected(), perm, maskPotential);
      if (numConnected >= c.getStimulusThreshold()) return;
      ArrayUtils.raiseValuesBy(c.getSynPermBelowStimulusInc(), perm, maskPotential);
    }
  }