コード例 #1
0
ファイル: SpatialPooler.java プロジェクト: mandarx/htm.java
  /**
   * Initializes the specified {@link Connections} object which contains the memory and structural
   * anatomy this spatial pooler uses to implement its algorithms.
   *
   * @param c a {@link Connections} object
   */
  public void init(Connections c) {
    if (c.getNumActiveColumnsPerInhArea() == 0
        && (c.getLocalAreaDensity() == 0 || c.getLocalAreaDensity() > 0.5)) {
      throw new InvalidSPParamValueException("Inhibition parameters are invalid");
    }

    c.doSpatialPoolerPostInit();
    initMatrices(c);
    connectAndConfigureInputs(c);
  }
コード例 #2
0
ファイル: SpatialPooler.java プロジェクト: mandarx/htm.java
  /**
   * 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);
  }