Ejemplo n.º 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);
   }
 }
Ejemplo n.º 2
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);
    }
  }
Ejemplo n.º 3
0
  /**
   * This method increases the permanence values of synapses of columns whose activity level has
   * been too low. Such columns are identified by having an overlap duty cycle that drops too much
   * below those of their peers. The permanence values for such columns are increased.
   *
   * @param c
   */
  public void bumpUpWeakColumns(final Connections c) {
    int[] weakColumns =
        ArrayUtils.where(
            c.getMemory().get1DIndexes(),
            new Condition.Adapter<Integer>() {
              @Override
              public boolean eval(int i) {
                return c.getOverlapDutyCycles()[i] < c.getMinOverlapDutyCycles()[i];
              }
            });

    for (int i = 0; i < weakColumns.length; i++) {
      Pool pool = c.getPotentialPools().get(weakColumns[i]);
      double[] perm = pool.getSparsePermanences();
      ArrayUtils.raiseValuesBy(c.getSynPermBelowStimulusInc(), perm);
      int[] indexes = pool.getSparsePotential();
      Column col = c.getColumn(weakColumns[i]);
      updatePermanencesForColumnSparse(c, perm, col, indexes, true);
    }
  }