Example #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);
  }
Example #2
0
  /**
   * Step two of pooler initialization kept separate from initialization of static members so that
   * they may be set at a different point in the initialization (as sometimes needed by tests).
   *
   * <p>This step prepares the proximal dendritic synapse pools with their initial permanence values
   * and connected inputs.
   *
   * @param c the {@link Connections} memory
   */
  public void connectAndConfigureInputs(Connections c) {
    // Initialize the set of permanence values for each column. Ensure that
    // each column is connected to enough input bits to allow it to be
    // activated.
    int numColumns = c.getNumColumns();
    for (int i = 0; i < numColumns; i++) {
      int[] potential = mapPotential(c, i, true);
      Column column = c.getColumn(i);
      c.getPotentialPools().set(i, column.createPotentialPool(c, potential));
      double[] perm = initPermanence(c, potential, i, c.getInitConnectedPct());
      updatePermanencesForColumn(c, perm, column, potential, true);
    }

    // The inhibition radius determines the size of a column's local
    // neighborhood.  A cortical column must overcome the overlap score of
    // columns in its neighborhood in order to become active. This radius is
    // updated every learning round. It grows and shrinks with the average
    // number of connected synapses per column.
    updateInhibitionRadius(c);
  }
Example #3
0
  @Test
  public void testObjectGroup() {
    Column c0 = new Column(9, 0);
    Column c1 = new Column(9, 1);

    // Illustrates the Cell's actual index = colIndex * cellsPerColumn + indexOfCellWithinCol
    assertEquals(7, c0.getCell(7).getIndex());
    assertEquals(12, c1.getCell(3).getIndex());
    assertEquals(16, c1.getCell(7).getIndex());

    DistalDendrite dd0 = new DistalDendrite(c0.getCell(7), 0, 0, 0);
    DistalDendrite dd1 = new DistalDendrite(c1.getCell(3 /* Col 1's Cells start at 9 */), 1, 0, 1);
    DistalDendrite dd2 = new DistalDendrite(c1.getCell(7 /* Col 1's Cells start at 9 */), 2, 0, 2);

    List<DistalDendrite> l = Arrays.asList(new DistalDendrite[] {dd0, dd1, dd2});

    @SuppressWarnings("unchecked")
    List<Pair<DistalDendrite, Column>> expected =
        Arrays.asList(
            new Pair[] {
              new Pair<DistalDendrite, Column>(dd0, c0),
              new Pair<DistalDendrite, Column>(dd1, c1),
              new Pair<DistalDendrite, Column>(dd2, c1)
            });

    GroupBy<DistalDendrite, Column> grouper = GroupBy.of(l, i -> i.getParentCell().getColumn());

    int i = 0;
    for (Pair<DistalDendrite, Column> p : grouper) {
      assertEquals(expected.get(i++), p);
    }
  }