def connectTo(self, otherLayer): for i in range(otherLayer.getLayerSize()): neuron = otherLayer[i] BiasNeuron = Neuron(i, self.Id) BiasNeuron.createSynapse(otherLayer.Id, neuron) self.neurons.append(BiasNeuron) self.numberOfWeights += 1 self.emit("bias-layer-connected")
def connectTo (self, otherLayer): for i in range (otherLayer.getLayerSize ()): neuron = otherLayer [i] BiasNeuron = Neuron (i, self.Id) BiasNeuron.createSynapse (otherLayer.Id, neuron) self.neurons.append (BiasNeuron) self.numberOfWeights += 1 self.emit ("bias-layer-connected")
from spiral.helper import colored if __name__ == "__main__": globals.runInDebug = True n1 = Neuron (Id=1, LayerId=0, Name="Input") n1.setAutoNotify (True) n2 = Neuron (Id=2, LayerId=1) n3 = Neuron (Id=3, LayerId=1) n4 = Neuron (Id=4, LayerId=2, Name="Output") # Create the synapses n1.createSynapse (1, n2) n1.createSynapse (1, n3) n2.createSynapse (2, n4) n3.createSynapse (2, n4) print "*" * 40 # Put the weights n1.putWeights ((0.5, 0.25)) n2.putWeights ((-.75,)) n3.putWeights ((1.0,)) # Insert the inputs n1.putInput (1.0)
globals.runInDebug = False n1 = Neuron(Id=1, LayerId=0) n2 = Neuron(Id=2, LayerId=0) n3 = Neuron(Id=3, LayerId=0) n4 = Neuron(Id=4, LayerId=1) n5 = Neuron(Id=5, LayerId=1) n6 = Neuron(Id=6, LayerId=2) n7 = Neuron(Id=7, LayerId=2) n8 = Neuron(Id=8, LayerId=3) # Create the synapses for input layer n1.createSynapse(1, n4) n1.createSynapse(1, n5) n2.createSynapse(1, n4) n2.createSynapse(1, n5) n3.createSynapse(1, n4) n3.createSynapse(1, n5) # Create the synapses for the first hidden layer n4.createSynapse(2, n6) n4.createSynapse(2, n7) n5.createSynapse(2, n6) n5.createSynapse(2, n7) # Create the synapses for the second hidden layer n6.createSynapse(3, n8) n7.createSynapse(3, n8) # Put the weights
from spiral.nn import globals from spiral.nn.generic import Neuron from spiral.helper import colored if __name__ == "__main__": globals.runInDebug = True n1 = Neuron(Id=1, LayerId=0, Name="Input") n1.setAutoNotify(True) n2 = Neuron(Id=2, LayerId=1) n3 = Neuron(Id=3, LayerId=1) n4 = Neuron(Id=4, LayerId=2, Name="Output") # Create the synapses n1.createSynapse(1, n2) n1.createSynapse(1, n3) n2.createSynapse(2, n4) n3.createSynapse(2, n4) print "*" * 40 # Put the weights n1.putWeights((0.5, 0.25)) n2.putWeights((-.75, )) n3.putWeights((1.0, )) # Insert the inputs n1.putInput(1.0) print colored("Output value: %r", fg="yellow") % n4.getValue()
import sys sys.path.append ("../../src/") # spiral framework from spiral.nn import globals from spiral.nn.generic import Neuron from spiral.helper import colored if __name__ == "__main__": globals.runInDebug = False n1 = Neuron (Id=1, LayerId=0, Name="Input") n2 = Neuron (Id=2, LayerId=1) n3 = Neuron (Id=3, LayerId=2, Name="Output") # Create the synapses n1.createSynapse (1, n2) n1.createSynapse (1, n3) n2.createSynapse (2, n3) # Put the weights n1.putWeights ((0.5, 3.0)) n2.putWeights ((-.75,)) # Insert the inputs n1.putInput (1.0) print colored ("Output value: %r", fg="yellow") % n3.getValue ()
""" # batteries import sys sys.path.append("../../src/") # spiral framework from spiral.nn import globals from spiral.nn.generic import Neuron from spiral.helper import colored if __name__ == "__main__": globals.runInDebug = False n1 = Neuron(Id=1, LayerId=0, Name="Input") n2 = Neuron(Id=2, LayerId=1) n3 = Neuron(Id=3, LayerId=2, Name="Output") # Create the synapses n1.createSynapse(1, n2) n1.createSynapse(1, n3) n2.createSynapse(2, n3) # Put the weights n1.putWeights((0.5, 3.0)) n2.putWeights((-.75, )) # Insert the inputs n1.putInput(1.0) print colored("Output value: %r", fg="yellow") % n3.getValue()