Exemple #1
0
  /**
   * This method updates the permanence matrix with a column's new permanence values. The column is
   * identified by its index, which reflects the row in the matrix, and the permanence is given in
   * 'sparse' form, (i.e. an array whose members are associated with specific indexes). It is in
   * charge of implementing 'clipping' - ensuring that the permanence values are always between 0
   * and 1 - and 'trimming' - enforcing sparseness by zeroing out all permanence values below
   * 'synPermTrimThreshold'. Every method wishing to modify the permanence matrix should do so
   * through this method.
   *
   * @param c the {@link Connections} which is the memory model.
   * @param perm An array of permanence values for a column. The array is "sparse", i.e. it contains
   *     an entry for each input bit, even if the permanence value is 0.
   * @param column The column in the permanence, potential and connectivity matrices
   * @param raisePerm a boolean value indicating whether the permanence values
   */
  public void updatePermanencesForColumnSparse(
      Connections c, double[] perm, Column column, int[] maskPotential, boolean raisePerm) {
    if (raisePerm) {
      raisePermanenceToThresholdSparse(c, perm);
    }

    ArrayUtils.lessThanOrEqualXThanSetToY(perm, c.getSynPermTrimThreshold(), 0);
    ArrayUtils.clip(perm, c.getSynPermMin(), c.getSynPermMax());
    column.setProximalPermanencesSparse(c, perm, maskPotential);
  }
Exemple #2
0
  /**
   * Initializes the permanences of a column. The method returns a 1-D array the size of the input,
   * where each entry in the array represents the initial permanence value between the input bit at
   * the particular index in the array, and the column represented by the 'index' parameter.
   *
   * @param c the {@link Connections} which is the memory model
   * @param potentialPool An array specifying the potential pool of the column. Permanence values
   *     will only be generated for input bits corresponding to indices for which the mask value is
   *     1. WARNING: potentialPool is sparse, not an array of "1's"
   * @param index the index of the column being initialized
   * @param connectedPct A value between 0 or 1 specifying the percent of the input bits that will
   *     start off in a connected state.
   * @return
   */
  public double[] initPermanence(
      Connections c, int[] potentialPool, int index, double connectedPct) {
    double[] perm = new double[c.getNumInputs()];
    for (int idx : potentialPool) {
      if (c.random.nextDouble() <= connectedPct) {
        perm[idx] = initPermConnected(c);
      } else {
        perm[idx] = initPermNonConnected(c);
      }

      perm[idx] = perm[idx] < c.getSynPermTrimThreshold() ? 0 : perm[idx];
    }
    c.getColumn(index).setProximalPermanences(c, perm);
    return perm;
  }