//Constructor /// <summary> /// Creates initialized instance /// </summary> /// <param name="sourceNeuron">Source neuron</param> /// <param name="targetNeuron">Target neuron</param> /// <param name="weight">Synapse initial weight</param> public BaseSynapse(INeuron sourceNeuron, INeuron targetNeuron, double weight ) { //Neurons to be connected SourceNeuron = sourceNeuron; TargetNeuron = targetNeuron; //Euclidean distance Distance = EuclideanDistance.Compute(SourceNeuron.Placement.ReservoirCoordinates, TargetNeuron.Placement.ReservoirCoordinates); //Weight sign rules if (SourceNeuron.Role == NeuronCommon.NeuronRole.Input) { if (TargetNeuron.TypeOfActivation == ActivationType.Analog) { //No change of the weight sign Weight = weight; } else { //Target is spiking neuron //Weight must be always positive Weight = Math.Abs(weight); } } else { //Weight sign is dependent on source neuron role Weight = Math.Abs(weight) * (SourceNeuron.Role == NeuronCommon.NeuronRole.Excitatory ? 1d : -1d); } //Efficacy statistics EfficacyStat = new BasicStat(false); return; }
public double Run(double[] input, double[] output) { double[] networkOutput = network.Compute(input); ILayer layer = network.Layers[0]; double error = 0.0; for (int j = 0; j < layer.Neurons.Length; j++) { double e = output[j] - networkOutput[j]; if (Math.Abs(e) > 0.000001) { INeuron perceptron = layer.Neurons[j]; for (int i = 0; i < perceptron.Weights.Length; i++) { perceptron.Weights[i] += LearningRate * e * input[i]; } perceptron.Threshold += LearningRate * e; error += Math.Abs(e); } } return(error); }
public void AddOutputNeuron(INeuron output) { var synapse = new Synapse(output, this); Outputs.Add(synapse); output.Inputs.Add(synapse); }
/// <summary> /// Синапс /// </summary> /// <param name="outNeuron">Нейрон, посылающий сигнал</param> /// <param name="inNeuron">Нейрон, принимающий сигнал</param> /// <param name="lowBound">Минимальное принимаемое значение</param> /// <param name="highBound">Максимальное принимаемое значение</param> protected BaseSynapse(INeuron outNeuron, INeuron inNeuron, double lowBound, double highBound) { this.outNeuron = outNeuron; this.inNeuron = inNeuron; this.lowBound = lowBound; this.highBound = highBound; }
/// <summary> /// 构造函数 /// </summary> /// <param name="inputLayerCount"></param> /// <param name="hiddenLayerNumber"></param> /// <param name="outputLayerCount"></param> public BP(int inputLayerCount, int hiddenLayerNumber, int outputLayerCount) { this.Input_Layer_Count = inputLayerCount; this.Hidden_Layer_Count = hiddenLayerNumber; this.Output_Layer_Count = outputLayerCount; FirstNeuronVector = new INeuron[hiddenLayerNumber]; SecondNeuronVector = new INeuron[outputLayerCount]; Input_Layer_Vector = new Vector(Input_Layer_Count); Hidden_Layer_Vector = new Vector(Hidden_Layer_Count); Output_Layer_Vector = new Vector(Output_Layer_Count); Template_Vector = new Vector(Output_Layer_Count); Hidden_Offset_Vector = new Vector(Hidden_Layer_Count); Hidden_Offset_Chang_Vector = new Vector(Hidden_Layer_Count); Output_Offset_Vector = new Vector(Output_Layer_Count); Output_Offset_Change_Vector = new Vector(Output_Layer_Count); Input_Hiddene_Coefficient_Matrix = new Matrix(Hidden_Layer_Count, Input_Layer_Count); Hidden_Output_Coefficient_Matrix = new Matrix(Output_Layer_Count, Hidden_Layer_Count); Input_Hidden_Coefficient_Change_Matrix = new Matrix(Hidden_Layer_Count, Input_Layer_Count); Hidden_Output_Coefficient_Change_Matrix = new Matrix(Output_Layer_Count, Hidden_Layer_Count); Hidden_Output_Coefficient_Delta_Matrix = new Matrix(Output_Layer_Count, Hidden_Layer_Count); Miu = Constants.Miu; Delta = 0.0; InitialMatrix(); }
/// <summary> /// Connect two neurons. /// This neuron is the output neuron of the connection. /// </summary> /// <param name="inputNeuron">Neuron that will be input neuron of the newly created connection. /// </param> public void AddInputNeuron(INeuron inputNeuron, double weight) { var synapse = new Synapse(inputNeuron, this, weight); Inputs.Add(synapse); inputNeuron.Outputs.Add(synapse); }
public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager) { this.neuron = neuron; this.mophology = mophology; this.imager = imager; neuron.Updated += OnUpdated; neuron.Hillock.Spike += OnSpike; IsPushing = true; var transforms = new Transform3DGroup(); Rotate = new RotateTransform3D(new QuaternionRotation3D()); Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z); Scale = new ScaleTransform3D(); transforms.Children.Add(Rotate); transforms.Children.Add(Translate); transforms.Children.Add(Scale); Mophology.Transform = transforms; var binding = new Binding() { Source = neuron, Path = new PropertyPath("Position"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(this, Cell.PositionProperty, binding); }
public void outSignalMotor(INeuron outNeuron) { foreach (ISubZone sz in downSubZones) { sz.inSignalMotor(outNeuron); } }
public void outSignalForecast(INeuron outNeuron) { foreach (ISubZone sz in downSubZones) { sz.inSignalForecast(outNeuron); } }
public ISynapse CreateSynapse(INeuron source, INeuron target) { var synapse = new Synapse(source, target); AddSynapse(synapse); return(synapse); }
public void ConnectAxon(INeuron input, INeuron output, int neuronsCount) { var axon = new Synapse(input, output, XavierWeight(neuronsCount)); (output.Inputs as SynapseCollection <ISynapse>).Add(axon); (input.Outputs as SynapseCollection <ISynapse>).Add(axon); }
public void AddOutputNeuron(INeuron outputNeuron, double weight) { var connection = new Connection(weight, this, outputNeuron); Outputs.Add(connection); outputNeuron.Inputs.Add(connection); }
//Constructor /// <summary> /// Creates an initialized instance. /// </summary> /// <param name="presynapticNeuron">The presynaptic neuron.</param> /// <param name="dynamicsCfg">The configuration of the dynamics.</param> public NonlinearEfficacy(INeuron presynapticNeuron, NonlinearDynamicsSettings dynamicsCfg) { _presynapticNeuronOutputData = presynapticNeuron.OutputData; _dynamicsCfg = (NonlinearDynamicsSettings)dynamicsCfg.DeepClone(); Reset(); return; }
public void AddInputNeuron(INeuron inputNeuron, double weight) { var connection = new Connection(weight, inputNeuron, this); Inputs.Add(connection); inputNeuron.Outputs.Add(connection); }
public void AddInputNeuron(INeuron inputNeuron) { var synapse = new Synapse(inputNeuron, this); Inputs.Add(synapse); inputNeuron.Outputs.Add(synapse); }
public void AddOutputNeuron(INeuron outputNeuron) { var synapse = new Synapse(this, outputNeuron); Outputs.Add(synapse); outputNeuron.Inputs.Add(synapse); }
private void btnSave_Click(object sender, EventArgs e) { using (StreamWriter writer = new StreamWriter(inputWeightsFile)) { INeuron[] inputNeuron = neural.InputNeurons; for (int i = 0; i < inputNeuron.Length; i++) { INeuron neuron = inputNeuron[i]; double[] weights = neuron.Weights; for (int j = 0; j < weights.Length; j++) { writer.WriteLine(weights[j]); } } } using (StreamWriter writer = new StreamWriter(hiddenWeightsFile)) { HNeuron[] hiddenNeuron = neural.HiddenNeurons; for (int i = 0; i < hiddenNeuron.Length; i++) { HNeuron neuron = hiddenNeuron[i]; double[] weights = neuron.Weights; for (int j = 0; j < weights.Length; j++) { writer.WriteLine(weights[j]); } } } MessageBox.Show("Weights Saved!"); }
public Synapse(INeuron from, INeuron to, double weight) { this.from = from; this.to = to; this.Weight = weight; PreviousWeight = 0; }
//Constructor /// <summary> /// Creates an initialized instance /// </summary> /// <param name="sourceNeuron">Source neuron</param> /// <param name="dynamicsCfg">Dynamics configuration</param> public LinearEfficacy(INeuron sourceNeuron, LinearDynamicsSettings dynamicsCfg) { _sourceNeuronOutputData = sourceNeuron.OutputData; _dynamicsCfg = (LinearDynamicsSettings)dynamicsCfg.DeepClone(); Reset(); return; }
public Synapse(INeuron fromNeuron, INeuron toNeuron) { _fromNeuron = fromNeuron; _toNeuron = toNeuron; Weight = new Random().NextDouble(); PreviousWeight = 0; }
public WeightSynapse(INeuron presynapticneuron, double weight) { this.id = Guid.NewGuid(); this.presynapticneuron = presynapticneuron; this.weight = weight; type = SynapseType.WeightSynapse; }
public InputSynapse(INeuron toNeuron, double output) { this._toNeuron = toNeuron; this.Output = output; this.Weight = 1; this.PreviousWeight = 1; }
private static int RightAnswer(List <INeuron> neu, int?maximumId = null) { int result = -1; if (maximumId != null) { List <INeuron> newNeu = new List <INeuron>(neu); for (int i = 0; i < newNeu.Count; i++) { for (int j = i; j < newNeu.Count; j++) { if (newNeu[i].Result < newNeu[j].Result) { INeuron temp = newNeu[i]; newNeu[i] = newNeu[j]; newNeu[j] = temp; } } } INeuron maxRes = neu[maximumId.Value]; int id = newNeu.FindIndex((neur) => neur == maxRes); result = neu.FindIndex((neur) => neur == newNeu[id == neu.Count ? id : id + 1]); } else { double max = neu.Max(neur => neur.Result); result = neu.FindIndex(neur => neur.Result == max); } return(result); }
public InputSynapse(INeuron toNeuron, double output) { _toNeuron = toNeuron; Output = output; Weight = 1; PreviousWeight = 1; }
private void ConnectNeuronToLayer(INeuron nn, int layer) { for (int j = 1; j < neurons[layer + 1].Length; j++) { neurons[layer + 1][j].Connect(nn); } }
internal (int xStart, int xEnd, int yStart, int yEnd) GetRadiusIndexes(INeuron bmu, double currentRadius) { var xStart = (int)(bmu.X - currentRadius - 1); xStart = (xStart < 0) ? 0 : xStart; var xEnd = (int)(xStart + (currentRadius * 2) + 1); if (xEnd > _width) { xEnd = _width; } var yStart = (int)(bmu.Y - currentRadius - 1); yStart = (yStart < 0) ? 0 : yStart; var yEnd = (int)(yStart + (currentRadius * 2) + 1); if (yEnd > _height) { yEnd = _height; } return(xStart, xEnd, yStart, yEnd); }
public void Process(IBitInput input, IBitOutput output) { if (input.Length != InputCount) { throw new Exception("Invalid input bit count"); } if (output.Length != OutputCount) { throw new Exception("Invalid output bit count"); } int outputCount = OutputCount; for (int bitPos = 0; bitPos < outputCount; bitPos++) { INeuron neuron = neurons[bitPos]; output[bitPos] = neuron.Process(input); } //Parallel.For(0, outputCount, bitPos => //{ // INeuron neuron = neurons[bitPos]; // output[bitPos] = neuron.Process(input); //}); }
public NeuralConnection(INeuron source, INeuron destination) { Source = source; Destination = destination; //source.AddNeuralOutput(this); //destination.AddNeuralInput(this); }
public Synapse(INeuron fromNeuron, INeuron toNeuron, double weight) { _fromNeuron = fromNeuron; _toNeuron = toNeuron; Weight = weight; PreviousWeight = 0; }
public Synapse(INeuron source, INeuron target) { Weight = 1; Value = 0; Source = source; Target = target; }
private void ExtraBiasCheck(INeuron neuron) { if (IsBias(neuron) && HasBias()) { throw new MoreThanOneBiasException(); } }
private void SelfCheck(INeuron neuron) { if (this == neuron) { throw new CannotConnectToSelfException(); } }
private void AlreadyConnectedCheck(INeuron neuron) { if (neurons.Contains(neuron)) { throw new AlreadyConnectedException(); } }
private INeuron[] CreateNeurons(int neuronsCount, int inputCount, int outputCount, double bias, double excess, IActivation activation) { var neurons = new INeuron[neuronsCount]; for (var i = 0; i < _inputCount; i++) { neurons[i] = new InputNeuron { B = bias, }; } for (var i = _inputCount; i < neuronsCount - _outputCount; i++) { neurons[i] = new HiddenNeuron { Activation = activation, L = 0.5 + 0.25 * 1, B = bias, }; } for (var i = neuronsCount - _outputCount; i < neuronsCount; i++) { neurons[i] = new OutputNeuron { Activation = activation, L = 0.5 + 0.25 * 3, B = bias, }; } return(neurons); }
public void AddInputNeuron(INeuron n) { NeuronInput inp = new NeuronInput(); inp.n = n; inp.w = randomWeight(); inp.bias = 0; inputs.Add(inp); }
protected static INeuron[] GetNeurons(int neuronsCount, AbstractNeuronsFactory neuronsFactory) { var neurons = new INeuron[neuronsCount]; for (int i = 0; i < neuronsCount; i++) { neurons[i] = neuronsFactory.Get(); } return neurons; }
public ICell Develop(INeuron neuron) { if (neuron == null) { return null; } var cell = new Cell(neuron, DevelopMophology(neuron)); return cell; }
/// <summary> /// Creates a new Kohonen Synapse connecting the given neurons /// </summary> /// <param name="sourceNeuron"> /// The source neuron /// </param> /// <param name="targetNeuron"> /// The target neuron /// </param> /// <param name="parent"> /// Parent connector containing this synapse /// </param> /// <exception cref="System.ArgumentNullException"> /// If any of the arguments is <c>null</c> /// </exception> public KohonenSynapse(INeuron sourceNeuron, PositionNeuron targetNeuron, KohonenConnector parent) { Helper.ValidateNotNull(sourceNeuron, "sourceNeuron"); Helper.ValidateNotNull(targetNeuron, "targetNeuron"); Helper.ValidateNotNull(parent, "parent"); this.weight = 1d; sourceNeuron.TargetSynapses.Add(this); targetNeuron.SourceSynapses.Add(this); this.sourceNeuron = sourceNeuron; this.targetNeuron = targetNeuron; this.parent = parent; }
public static IConnectedNeuron Get(INeuron[] inputNeurons) { var connections = inputNeurons.Select(x => new Connection(x, /*_random.NextDouble()*/0)).ToArray(); return new ConnectedNeuron(ActivationFunctions.Linear,connections); }
public Connection(INeuron source) { Source = source; }
public Cell(INeuron neuron, Tuple<ModelVisual3D, Imaging> mophology_imager) : this(neuron, mophology_imager.Item1, mophology_imager.Item2) { }
public SpikeWeightSynapse(INeuron presynapticneuron, double weight, double axondelay) : base(presynapticneuron, weight) { this.axondelay = axondelay; }
public SummarizeSynapse(INeuron sourceNeuron, INeuron targetNeuron, int weight = int.MinValue) : base(sourceNeuron, targetNeuron, weight) { }
public void InjectTo(INeuron neuron) { neuron.InjectedFrom(this); }
public ThresholdSigmoid(INeuron hostneuron, double threshold) : base(hostneuron, threshold) { type = HillockType.Sigmoid; }
public void Connect(INeuron neuron, double weight) { throw new CannotConnectToBiasException(); }
/// <summary> /// Create a connection. /// </summary> /// <param name="weight">The weight.</param> /// <param name="parent">The parent/source neuron.</param> public Connection(double weight, INeuron parent) { Weight = weight; Parent = parent; }
public InputLayer(INeuron[] neurons) { Neurons = neurons; }
public int IndexOf(INeuron item) { return m_neurons.IndexOf(item); }
/// <summary> /// Синапс, не меняющий своего веса /// </summary> /// <param name="outNeuron">Нейрон, посылающий сигнал</param> /// <param name="inNeuron">Нейрон, принимающий сигнал</param> /// <param name="weight">Вес синапса</param> /// <param name="lowBound">Минимальное принимаемое значение</param> /// <param name="highBound">Максимальное принимаемое значение</param> public ClampedSynapse(INeuron outNeuron, INeuron inNeuron, double weight) : this(outNeuron, inNeuron, weight, double.NegativeInfinity, double.PositiveInfinity) { }
public NeruonContainerShell(Point3D position, Quaternion orientation, INeuron[] neurons) { this.Position = position; this.Orientation = orientation; this.Radius = 1d; this.Neruons_Readonly = Enumerable.Empty<INeuron>(); this.Neruons_Writeonly = Enumerable.Empty<INeuron>(); this.Neruons_ReadWrite = neurons; this.Neruons_All = neurons; }
public ConnectedNeuronsFactory(INeuron[] inputNeurons) { _inputNeurons = inputNeurons; }
public void ProjectTo(INeuron neuron, INetwork network) { }
/// <summary> /// Синапс Хэбба /// </summary> /// <param name="outNeuron">Нейрон, посылающий сигнал</param> /// <param name="inNeuron">Нейрон, принимающий сигнал</param> /// <param name="weight">Вес синапса</param> /// <param name="learningRate">Скорость изменения веса</param> public HebbianSynapse(INeuron outNeuron, INeuron inNeuron, double weight, double learningRate) : this(outNeuron, inNeuron, weight, learningRate, double.NegativeInfinity, double.PositiveInfinity) { }
public NeuralLink(INeuronContainer fromContainer, INeuronContainer toContainer, INeuron from, INeuron to, double weight, double[] brainChemicalModifiers) { this.FromContainer = fromContainer; this.ToContainer = toContainer; this.From = from; this.To = to; this.Weight = weight; this.BrainChemicalModifiers = brainChemicalModifiers; }
public NeuronBackPointer(INeuron neuron, INeuronContainer container, NeuralLink[] links) { this.Neuron = neuron; this.Container = container; this.Links = links; }
public void Insert(int index, INeuron item) { m_neurons.Insert(index, item); }
/// <summary> /// Синапс Хэбба /// </summary> /// <param name="outNeuron">Нейрон, посылающий сигнал</param> /// <param name="inNeuron">Нейрон, принимающий сигнал</param> /// <param name="weight">Вес синапса</param> /// <param name="learningRate">Скорость изменения веса</param> /// <param name="lowBound">Минимальное принимаемое значение</param> /// <param name="highBound">Максимальное принимаемое значение</param> public HebbianSynapse(INeuron outNeuron, INeuron inNeuron, double weight, double learningRate, double lowBound, double highBound) : base(outNeuron, inNeuron, lowBound, highBound) { this.weight = weight; this.learningRate=learningRate; }
/// <summary> /// Синапс, не меняющий своего веса /// </summary> /// <param name="outNeuron">Нейрон, посылающий сигнал</param> /// <param name="inNeuron">Нейрон, принимающий сигнал</param> /// <param name="weight">Вес синапса</param> /// <param name="lowBound">Минимальное принимаемое значение</param> /// <param name="highBound">Максимальное принимаемое значение</param> public ClampedSynapse(INeuron outNeuron, INeuron inNeuron, double weight, double lowBound, double highBound) : base(outNeuron, inNeuron, lowBound, highBound) { this.weight = weight; }
public SpikeWeightSynapse(INeuron presynapticneuron, double weight) : this(presynapticneuron, weight, 0.1) { }