Beispiel #1
0
def main():
  x = 10
  y = 10
  steps = 10000
  world = np.array([i for i in xrange(625)])
  world.resize((25, 25))
  spInputSize = 21*21
  sp = SpatialPooler(
      inputDimensions=(spInputSize,),
      columnDimensions=(25,),
      potentialRadius=spInputSize,
      numActiveColumnsPerInhArea=1,
      synPermActiveInc=0.1,
      synPermInactiveDec=0.5,
      boostStrength=1.0,
  )
  csFields = generateCenterSurroundFields()
  output = np.zeros((25,), dtype=np.uint32)
  for _ in xrange(steps):
    active = getActive(world, x, y)
    assert len(active) == 25, "{}, {}: {}".format(x, y, active)
    activeInput = np.zeros((625,), dtype=np.uint32)
    for v in active:
      activeInput[v] = 1
    centerSurround = processCenterSurround(csFields, activeInput)
    print centerSurround

    sp.compute(centerSurround, True, output)
    x, y = getNewLocation(x, y, 25, 2, False)

  for i in xrange(25):
    permanence = np.zeros((spInputSize,))
    sp.getPermanence(i, permanence)
    plt.imshow(permanence.reshape((21, 21)), cmap="hot", interpolation="nearest")
    plt.show()
Beispiel #2
0
def main():
    x = 10
    y = 10
    steps = 10000
    history = []
    world = np.array([i for i in xrange(625)])
    world.resize((25, 25))
    sp = SpatialPooler(
        inputDimensions=(625, ),
        columnDimensions=(25, ),
        potentialRadius=625,
        numActiveColumnsPerInhArea=1,
    )
    output = np.zeros((25, ), dtype=np.uint32)
    for _ in xrange(steps):
        active = getActive(world, x, y)
        assert len(active) == 25, "{}, {}: {}".format(x, y, active)
        activeInput = np.zeros((625, ), dtype=np.uint32)
        for v in active:
            activeInput[v] = 1
        history.append(active)
        sp.compute(activeInput, True, output)
        x, y = getNewLocation(x, y, 25, 2, False)

    for i in xrange(25):
        permanence = np.zeros((625, ))
        sp.getPermanence(i, permanence)
        plt.imshow(permanence.reshape((25, 25)),
                   cmap="hot",
                   interpolation="nearest")
        plt.show()
def main():
    x = 10
    y = 10
    steps = 10000
    world = np.array([i for i in xrange(625)])
    world.resize((25, 25))
    spInputSize = 21 * 21
    sp = SpatialPooler(
        inputDimensions=(spInputSize, ),
        columnDimensions=(25, ),
        potentialRadius=spInputSize,
        numActiveColumnsPerInhArea=1,
        synPermActiveInc=0.1,
        synPermInactiveDec=0.5,
        boostStrength=1.0,
    )
    csFields = generateCenterSurroundFields()
    output = np.zeros((25, ), dtype=np.uint32)
    for _ in xrange(steps):
        active = getActive(world, x, y)
        assert len(active) == 25, "{}, {}: {}".format(x, y, active)
        activeInput = np.zeros((625, ), dtype=np.uint32)
        for v in active:
            activeInput[v] = 1
        centerSurround = processCenterSurround(csFields, activeInput)
        print centerSurround

        sp.compute(centerSurround, True, output)
        x, y = getNewLocation(x, y, 25, 2, False)

    for i in xrange(25):
        permanence = np.zeros((spInputSize, ))
        sp.getPermanence(i, permanence)
        plt.imshow(permanence.reshape((21, 21)),
                   cmap="hot",
                   interpolation="nearest")
        plt.show()