Beispiel #1
0
  /**
   * Update the boost factors for all columns. The boost factors are used to increase the overlap of
   * inactive columns to improve their chances of becoming active. and hence encourage participation
   * of more columns in the learning process. This is a line defined as: y = mx + b boost =
   * (1-maxBoost)/minDuty * dutyCycle + maxFiringBoost. Intuitively this means that columns that
   * have been active enough have a boost factor of 1, meaning their overlap is not boosted. Columns
   * whose active duty cycle drops too much below that of their neighbors are boosted depending on
   * how infrequently they have been active. The more infrequent, the more they are boosted. The
   * exact boost factor is linearly interpolated between the points (dutyCycle:0,
   * boost:maxFiringBoost) and (dutyCycle:minDuty, boost:1.0).
   *
   * <p>boostFactor ^ maxBoost _ | |\ | \ 1 _ | \ _ _ _ _ _ _ _ | +-------------------->
   * activeDutyCycle | minActiveDutyCycle
   */
  public void updateBoostFactors(Connections c) {
    double[] activeDutyCycles = c.getActiveDutyCycles();
    double[] minActiveDutyCycles = c.getMinActiveDutyCycles();

    // Indexes of values > 0
    int[] mask = ArrayUtils.where(minActiveDutyCycles, ArrayUtils.GREATER_THAN_0);

    double[] boostInterim;
    if (mask.length < 1) {
      boostInterim = c.getBoostFactors();
    } else {
      double[] numerator = new double[c.getNumColumns()];
      Arrays.fill(numerator, 1 - c.getMaxBoost());
      boostInterim = ArrayUtils.divide(numerator, minActiveDutyCycles, 0, 0);
      boostInterim = ArrayUtils.multiply(boostInterim, activeDutyCycles, 0, 0);
      boostInterim = ArrayUtils.d_add(boostInterim, c.getMaxBoost());
    }

    ArrayUtils.setIndexesTo(
        boostInterim,
        ArrayUtils.where(
            activeDutyCycles,
            new Condition.Adapter<Object>() {
              int i = 0;

              @Override
              public boolean eval(double d) {
                return d > minActiveDutyCycles[i++];
              }
            }),
        1.0d);

    c.setBoostFactors(boostInterim);
  }
Beispiel #2
0
 /**
  * Updates the minimum duty cycles in a global fashion. Sets the minimum duty cycles for the
  * overlap and activation of all columns to be a percent of the maximum in the region, specified
  * by {@link Connections#getMinOverlapDutyCycles()} and minPctActiveDutyCycle respectively.
  * Functionality it is equivalent to {@link #updateMinDutyCyclesLocal(Connections)}, but this
  * function exploits the globalness of the computation to perform it in a straightforward, and
  * more efficient manner.
  *
  * @param c
  */
 public void updateMinDutyCyclesGlobal(Connections c) {
   Arrays.fill(
       c.getMinOverlapDutyCycles(),
       c.getMinPctOverlapDutyCycles() * ArrayUtils.max(c.getOverlapDutyCycles()));
   Arrays.fill(
       c.getMinActiveDutyCycles(),
       c.getMinPctActiveDutyCycles() * ArrayUtils.max(c.getActiveDutyCycles()));
 }
Beispiel #3
0
 /**
  * Updates the minimum duty cycles. The minimum duty cycles are determined locally. Each column's
  * minimum duty cycles are set to be a percent of the maximum duty cycles in the column's
  * neighborhood. Unlike {@link #updateMinDutyCyclesGlobal(Connections)}, here the values can be
  * quite different for different columns.
  *
  * @param c
  */
 public void updateMinDutyCyclesLocal(Connections c) {
   int len = c.getNumColumns();
   for (int i = 0; i < len; i++) {
     int[] maskNeighbors =
         getNeighborsND(c, i, c.getMemory(), c.getInhibitionRadius(), true).toArray();
     c.getMinOverlapDutyCycles()[i] =
         ArrayUtils.max(ArrayUtils.sub(c.getOverlapDutyCycles(), maskNeighbors))
             * c.getMinPctOverlapDutyCycles();
     c.getMinActiveDutyCycles()[i] =
         ArrayUtils.max(ArrayUtils.sub(c.getActiveDutyCycles(), maskNeighbors))
             * c.getMinPctActiveDutyCycles();
   }
 }