def locationsTest():
  """Test with square and blocky A"""
  t = Thalamus()

  encoder = createLocationEncoder(t)

  trainThalamusLocations(t, encoder)

  output = np.zeros(encoder.getWidth(), dtype=defaultDtype)
  ff = np.zeros((32, 32))
  for x in range(10,20):
    ff[:] = 0
    ff[10:20, 10:20] = 1
    plotActivity(ff, "square_ff_input.jpg", title="Feed forward input")
    ffOutput = inferThalamus(t, encodeLocation(encoder, x, x, output), ff)
    plotActivity(ffOutput, "square_relay_output_" + str(x) + ".jpg",
                 title="Relay cell activity",
                 cmap="coolwarm")

  # Show attention with an A
  ff = np.zeros((32, 32))
  for x in range(10,20):
    ff[:] = 0
    ff[10, 10:20] = 1
    ff[15, 10:20] = 1
    ff[10:20, 10] = 1
    ff[10:20, 20] = 1
    plotActivity(ff, "A_ff_input.jpg", title="Feed forward input")
    ffOutput = inferThalamus(t, encodeLocation(encoder, x, x, output), ff)
    plotActivity(t.burstReadyCells, "relay_burstReady_" + str(x) + ".jpg",
                 title="Burst-ready cells (x,y)=({},{})".format(x, x),
                 )
    plotActivity(ffOutput, "A_relay_output_" + str(x) + ".jpg",
                 title="Relay cell activity",
                 cmap="coolwarm")
def locationsTest ( ) : t = Thalamus ( ) encoder = createLocationEncoder ( t ) trainThalamusLocations ( t , encoder ) output = np . zeros ( encoder . getWidth ( ) , dtype = defaultDtype ) ff = np . zeros ( ( 32 , 32 ) ) for x in range ( 10 , 20 ) : ff [ : ] = 0 ff [ 10 : 20 , 10 : 20 ] = 1 plotActivity ( ff , "square_ff_input.jpg" , title = "Feed forward input" ) ffOutput = inferThalamus ( t , encodeLocation ( encoder , x , x , output ) , ff ) plotActivity ( ffOutput , "square_relay_output_" + str ( x ) + ".jpg" , title = "Relay cell activity" , cmap = "coolwarm" ) ff = np . zeros ( ( 32 , 32 ) ) for x in range ( 10 , 20 ) : ff [ : ] = 0 ff [ 10 , 10 : 20 ] = 1 ff [ 15 , 10 : 20 ] = 1 ff [ 10 : 20 , 10 ] = 1 ff [ 10 : 20 , 20 ] = 1 plotActivity ( ff , "A_ff_input.jpg" , title = "Feed forward input" ) ffOutput = inferThalamus ( t , encodeLocation ( encoder , x , x , output ) , ff ) plotActivity ( t . burstReadyCells , "relay_burstReady_" + str ( x ) + ".jpg" , title = "Burst-ready cells (x,y)=({},{})" . format ( x , x ) , ) plotActivity ( ffOutput , "A_relay_output_" + str ( x ) + ".jpg" , title = "Relay cell activity" , cmap = "coolwarm" )
Test with square and blocky A