Myro with Neural Networks

From IPRE Wiki
Jump to: navigation, search

Some notes on doing neural networks with myro.conx. I might have the sensors backwards.

Neural Networks

>>> from myro import *
>>> from myro.conx import *
>>> net = Network(2, 3, 2) # 2 inputs, 3 hidden, 2 outputs
>>> for i in range(100):
       net.backprop(input=[0, 0], output=[1, 0]) # if no sensors, go forward
       net.backprop(input=[1, 0], output=[0, 1]) # if sensor on left, go right
       net.backprop(input=[0, 1], output=[0, -1]) # if sensor on right, go left
      net.backprop(input=[1, 1], output=[-1, 0]) # if both sensors, backup
>>> sensors = getIR()
>>> move(*net.propagate(input=sensors))