def setupEOgmaNeo(): global _system, _hierarchy, _inputImage, _inputValue print("Initializing EOgmaNeo::ComputeSystem") _system = eogmaneo.ComputeSystem(4) print("Initializing EOgmaNeo::Hierarchy") lds = eogmaneo.StdVecLayerDesc() numLayers = 6 layerSize = 36 for l in range(0, numLayers): ld = eogmaneo.LayerDesc() ld._width = layerSize ld._height = layerSize ld._forwardRadius = 9 ld._backwardRadius = 9 ld._ticksPerUpdate = 2 ld._temporalHorizon = 2 ld._alpha = 0.1 ld._beta = 0.1 ld._gamma = 0.01 lds.push_back(ld) #layerSize = 16 _hierarchy = eogmaneo.Hierarchy() _hierarchy.create([(hiddenWidth, hiddenHeight), (steerChunkSize, steerChunkSize)], [lineChunkSize, steerChunkSize], [False, True], lds, 41) _inputValue = eogmaneo.StdVeci(1 * 1)
camera.resolution = (camWidth, camHeight) camera.framerate = 24 #camera.start_preview() time.sleep(2) ###################### ser = serial.Serial( '/dev/serial/by-id/usb-Arduino_Srl_Arduino_Uno_556393038343514082D0-if00', 115200) esystem = eogmaneo.ComputeSystem(4) ld = 6 * [eogmaneo.LayerDesc()] for l in range(0, len(ld)): ld[l]._width = 36 ld[l]._height = 36 ld[l]._chunkSize = 6 if l == 0: ld[l]._forwardRadius = 9 ld[l]._backwardRadius = 9 else: ld[l]._forwardRadius = 9 ld[l]._backwardRadius = 9 ld[l]._ticksPerUpdate = 2 ld[l]._temporalHorizon = 2
# After training an ImageEncoder will output unique sparse chunked representations # that can be input into an EOgmaNeo hierarchy. Consequently it can take predicted # sparse chunked representations output from the hierarchy and reconstruct an # image it has learned. preEncoder = eogmaneo.ImageEncoder() preEncoder.create(IMAGE_WIDTH, IMAGE_HEIGHT, HIDDEN_WIDTH, HIDDEN_HEIGHT, CHUNK_SIZE, int(16), 123) # Make sure EOgmaNeo uses all CPU cores available cs = eogmaneo.ComputeSystem(multiprocessing.cpu_count()) # Construct parameter descriptions for all hierarchy encoder-decoder layers lds = [] for i in range(NUM_LAYERS): ld = eogmaneo.LayerDesc() ld._width = HIDDEN_WIDTH ld._height = HIDDEN_HEIGHT ld._chunkSize = CHUNK_SIZE ld._radius = RADIUS ld._ticksPerUpdate = 2 ld._temporalHorizon = 2 ld._alpha = 0.1 ld._beta = 0.1 # Disable reinforcement learning ld._gamma = 0.0 lds.append(ld)
time.sleep(2) ###################### ser = serial.Serial( '/dev/serial/by-id/usb-Arduino_Srl_Arduino_Uno_556393038343514082D0-if00', 115200) s = eogmaneo.ComputeSystem(4) #lr = eogmaneo.LocalRegressor() #lr.load("localregSave.txt") ld = 2 * [eogmaneo.LayerDesc()] for l in range(0, len(ld)): ld[l]._width = 18 ld[l]._height = 18 ld[l]._chunkWidth = ld[l]._chunkHeight = 6 if l == 0: ld[l]._forwardRadius = 6 ld[l]._backwardRadius = 6 else: ld[l]._forwardRadius = 6 ld[l]._backwardRadius = 6 ld[l]._ticksPerUpdate = 2 ld[l]._temporalHorizon = 2
time.sleep(2) ###################### ser = serial.Serial( '/dev/serial/by-id/usb-Arduino_Srl_Arduino_Uno_556393038343514082D0-if00', 115200) s = eogmaneo.ComputeSystem(4) #lr = eogmaneo.LocalRegressor() #lr.load("localregSave.txt") ld = 4 * [eogmaneo.LayerDesc()] for l in range(0, len(ld)): ld[l]._width = 36 ld[l]._height = 36 ld[l]._chunkSize = 6 if l == 0: ld[l]._forwardRadius = 9 ld[l]._backwardRadius = 9 else: ld[l]._forwardRadius = 9 ld[l]._backwardRadius = 9 ld[l]._ticksPerUpdate = 2 ld[l]._temporalHorizon = 2