Esempio n. 1
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)
Esempio n. 2
0
 def train (self, Inputs, Output):
     Feedforward.update (self, Inputs, self.Weights)
     self._calculateDeltas ()
Esempio n. 3
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)
Esempio n. 4
0
 def train(self, Inputs, Output):
     Feedforward.update(self, Inputs, self.Weights)
     self._calculateDeltas()