コード例 #1
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
    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()
コード例 #2
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
 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 ()
コード例 #3
0
ファイル: example1.py プロジェクト: kelvict/spiral
    
    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)
コード例 #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)
コード例 #5
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
 def train (self, Inputs, Output):
     Feedforward.update (self, Inputs, self.Weights)
     self._calculateDeltas ()
コード例 #6
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
 def createNet (self):
     Feedforward.createNet (self)
コード例 #7
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
 def train(self, Inputs, Output):
     Feedforward.update(self, Inputs, self.Weights)
     self._calculateDeltas()
コード例 #8
0
ファイル: Backpropagation.py プロジェクト: kelvict/spiral
 def createNet(self):
     Feedforward.createNet(self)
コード例 #9
0
ファイル: example2.py プロジェクト: kelvict/spiral
# 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)