Ejemplo n.º 1
0
  /**
   * Updates the duty cycles for each column. The OVERLAP duty cycle is a moving average of the
   * number of inputs which overlapped with each column. The ACTIVITY duty cycles is a moving
   * average of the frequency of activation for each column.
   *
   * @param c the {@link Connections} (spatial pooler memory)
   * @param overlaps an array containing the overlap score for each column. The overlap score for a
   *     column is defined as the number of synapses in a "connected state" (connected synapses)
   *     that are connected to input bits which are turned on.
   * @param activeColumns An array containing the indices of the active columns, the sparse set of
   *     columns which survived inhibition
   */
  public void updateDutyCycles(Connections c, int[] overlaps, int[] activeColumns) {
    double[] overlapArray = new double[c.getNumColumns()];
    double[] activeArray = new double[c.getNumColumns()];
    ArrayUtils.greaterThanXThanSetToYInB(overlaps, overlapArray, 0, 1);
    if (activeColumns.length > 0) {
      ArrayUtils.setIndexesTo(activeArray, activeColumns, 1);
    }

    int period = c.getDutyCyclePeriod();
    if (period > c.getIterationNum()) {
      period = c.getIterationNum();
    }

    c.setOverlapDutyCycles(
        updateDutyCyclesHelper(c, c.getOverlapDutyCycles(), overlapArray, period));

    c.setActiveDutyCycles(updateDutyCyclesHelper(c, c.getActiveDutyCycles(), activeArray, period));
  }
Ejemplo n.º 2
0
 /**
  * Returns true if enough rounds have passed to warrant updates of duty cycles
  *
  * @param c the {@link Connections} memory encapsulation
  * @return
  */
 public boolean isUpdateRound(Connections c) {
   return c.getIterationNum() % c.getUpdatePeriod() == 0;
 }