Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
 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 ()
Exemplo n.º 3
0
    
    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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
 def train (self, Inputs, Output):
     Feedforward.update (self, Inputs, self.Weights)
     self._calculateDeltas ()
Exemplo n.º 6
0
 def createNet (self):
     Feedforward.createNet (self)
Exemplo n.º 7
0
 def train(self, Inputs, Output):
     Feedforward.update(self, Inputs, self.Weights)
     self._calculateDeltas()
Exemplo n.º 8
0
 def createNet(self):
     Feedforward.createNet(self)
Exemplo n.º 9
0
# 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)