Пример #1
0
  /**
   * Returns a randomly generated permanence value for a synapses that is to be initialized in a
   * non-connected state.
   *
   * @return a randomly generated permanence value
   */
  public static double initPermNonConnected(Connections c) {
    double p = c.getSynPermConnected() * c.getRandom().nextDouble();

    // Note from Python implementation on conditioning below:
    // Ensure we don't have too much unnecessary precision. A full 64 bits of
    // precision causes numerical stability issues across platforms and across
    // implementations
    p = ((int) (p * 100000)) / 100000.0d;
    return p;
  }
Пример #2
0
  /**
   * Maps a column to its input bits. This method encapsulates the topology of the region. It takes
   * the index of the column as an argument and determines what are the indices of the input vector
   * that are located within the column's potential pool. The return value is a list containing the
   * indices of the input bits. The current implementation of the base class only supports a 1
   * dimensional topology of columns with a 1 dimensional topology of inputs. To extend this class
   * to support 2-D topology you will need to override this method. Examples of the expected output
   * of this method: * If the potentialRadius is greater than or equal to the entire input space,
   * (global visibility), then this method returns an array filled with all the indices * If the
   * topology is one dimensional, and the potentialRadius is 5, this method will return an array
   * containing 5 consecutive values centered on the index of the column (wrapping around if
   * necessary). * If the topology is two dimensional (not implemented), and the potentialRadius is
   * 5, the method should return an array containing 25 '1's, where the exact indices are to be
   * determined by the mapping from 1-D index to 2-D position.
   *
   * @param c {@link Connections} the main memory model
   * @param columnIndex The index identifying a column in the permanence, potential and connectivity
   *     matrices.
   * @param wrapAround A boolean value indicating that boundaries should be ignored.
   * @return
   */
  public int[] mapPotential(Connections c, int columnIndex, boolean wrapAround) {
    int index = mapColumn(c, columnIndex);
    TIntArrayList indices =
        getNeighborsND(c, index, c.getInputMatrix(), c.getPotentialRadius(), wrapAround);
    indices.add(index);
    // TODO: See https://github.com/numenta/nupic.core/issues/128
    indices.sort();

    int[] retVal = new int[(int) Math.round(indices.size() * c.getPotentialPct())];
    return ArrayUtils.sample(indices, retVal, c.getRandom());
  }