def __init__(self, Inputs, Outputs, AddBias=True, Layers=None, NeuronsPerLayer=None, Name="", LearningRate=1.0): Feedforward.__init__(self, Inputs, Outputs, Layers=Layers, NeuronsPerLayer=NeuronsPerLayer, AddBias=True, StepActivation=None, Name=Name) # Learning rate self.LearningRate = LearningRate # Deltas self.Deltas = list() # Weights self.Weights = list()
def __init__ (self, Inputs, Outputs, AddBias=True, Layers=None, NeuronsPerLayer=None, Name="", LearningRate=1.0): Feedforward.__init__ (self, Inputs, Outputs, Layers=Layers, NeuronsPerLayer=NeuronsPerLayer, AddBias=True, StepActivation=None, Name=Name) # Learning rate self.LearningRate = LearningRate # Deltas self.Deltas = list () # Weights self.Weights = list ()
This is the same as the "example1.py" in the "neurons" folder. """ # batteries import sys sys.path.append("../../src/") # spiral framework from spiral.helper import colored from spiral.nn import globals from spiral.nn.impl import Feedforward if __name__ == "__main__": globals.runInDebug = True settings = {"Inputs": 3, "Outputs": 1, "Layers": 2, "NeuronsPerLayer": 2} nn = Feedforward(**settings) nn.createNet() nn.createDefaultSynapses() inputs = [1.0, 2.0, 3.0] weights = [0.3, 0.4, -0.1, -0.8, -0.25, 0.25, 1.0, 0.8, 0.7, 0.1, 0.1, 0.2] nn.update(inputs, weights) print colored("Neural Network output: %r", fg="yellow") % nn.output(0)
import sys sys.path.append("../../src/") # spiral framework from spiral.helper import colored from spiral.nn import globals from spiral.nn.impl import Feedforward if __name__ == "__main__": globals.runInDebug = False settings = { "Inputs": 3, "Outputs": 1, "Layers": 2, "NeuronsPerLayer": 2, "AddBias": True } nn = Feedforward(**settings) nn.createNet() nn.createDefaultSynapses() inputs = [1.0, 2.0, 3.0] weights= [ 0.3, 0.4, -0.1, -0.8, -0.25, 0.25, \ 1.0, 0.8, 0.7, 0.1, \ 0.1, 0.2, 1.0, 0.3, 0.24, 0.324, 0.12 ] nn.update(inputs, weights) print "Neural Network epoch completed in: %r seconds" % nn.timeUpdate() print colored("Neural Network output: %r", fg="yellow") % nn.output(0)
def train (self, Inputs, Output): Feedforward.update (self, Inputs, self.Weights) self._calculateDeltas ()
def createNet (self): Feedforward.createNet (self)
def train(self, Inputs, Output): Feedforward.update(self, Inputs, self.Weights) self._calculateDeltas()
def createNet(self): Feedforward.createNet(self)
# spiral framework from spiral.helper import colored from spiral.nn import globals from spiral.nn.impl import Feedforward if __name__ == "__main__": globals.runInDebug = False settings = { "Inputs" : 3, "Outputs": 1, "Layers" : 2, "NeuronsPerLayer": 2, "AddBias": True } nn = Feedforward (**settings) nn.createNet () nn.createDefaultSynapses () inputs = [ 1.0, 2.0, 3.0 ] weights= [ 0.3, 0.4, -0.1, -0.8, -0.25, 0.25, \ 1.0, 0.8, 0.7, 0.1, \ 0.1, 0.2, 1.0, 0.3, 0.24, 0.324, 0.12 ] nn.update (inputs, weights) print "Neural Network epoch completed in: %r seconds" % nn.timeUpdate () print colored ("Neural Network output: %r", fg="yellow") % nn.output (0)