Example #1
0
 /**
  * Updates the minimum duty cycles defining normal activity for a column. A column with activity
  * duty cycle below this minimum threshold is boosted.
  *
  * @param c
  */
 public void updateMinDutyCycles(Connections c) {
   if (c.getGlobalInhibition() || c.getInhibitionRadius() > c.getNumInputs()) {
     updateMinDutyCyclesGlobal(c);
   } else {
     updateMinDutyCyclesLocal(c);
   }
 }
Example #2
0
  /**
   * Update the inhibition radius. The inhibition radius is a measure of the square (or hypersquare)
   * of columns that each a column is "connected to" on average. Since columns are are not connected
   * to each other directly, we determine this quantity by first figuring out how many *inputs* a
   * column is connected to, and then multiplying it by the total number of columns that exist for
   * each input. For multiple dimension the aforementioned calculations are averaged over all
   * dimensions of inputs and columns. This value is meaningless if global inhibition is enabled.
   *
   * @param c the {@link Connections} (spatial pooler memory)
   */
  public void updateInhibitionRadius(Connections c) {
    if (c.getGlobalInhibition()) {
      c.setInhibitionRadius(ArrayUtils.max(c.getColumnDimensions()));
      return;
    }

    TDoubleArrayList avgCollected = new TDoubleArrayList();
    int len = c.getNumColumns();
    for (int i = 0; i < len; i++) {
      avgCollected.add(avgConnectedSpanForColumnND(c, i));
    }
    double avgConnectedSpan = ArrayUtils.average(avgCollected.toArray());
    double diameter = avgConnectedSpan * avgColumnsPerInput(c);
    double radius = (diameter - 1) / 2.0d;
    radius = Math.max(1, radius);
    c.setInhibitionRadius((int) Math.round(radius));
  }
Example #3
0
  /**
   * Performs inhibition. This method calculates the necessary values needed to actually perform
   * inhibition and then delegates the task of picking the active columns to helper functions.
   *
   * @param c the {@link Connections} matrix
   * @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.
   * @return
   */
  public int[] inhibitColumns(Connections c, double[] overlaps) {
    overlaps = Arrays.copyOf(overlaps, overlaps.length);

    double density;
    double inhibitionArea;
    if ((density = c.getLocalAreaDensity()) <= 0) {
      inhibitionArea = Math.pow(2 * c.getInhibitionRadius() + 1, c.getColumnDimensions().length);
      inhibitionArea = Math.min(c.getNumColumns(), inhibitionArea);
      density = c.getNumActiveColumnsPerInhArea() / inhibitionArea;
      density = Math.min(density, 0.5);
    }

    // Add our fixed little bit of random noise to the scores to help break ties.
    // ArrayUtils.d_add(overlaps, c.getTieBreaker());

    if (c.getGlobalInhibition()
        || c.getInhibitionRadius() > ArrayUtils.max(c.getColumnDimensions())) {
      return inhibitColumnsGlobal(c, overlaps, density);
    }

    return inhibitColumnsLocal(c, overlaps, density);
  }