public ResultNeuralLayer(ResultNeuron neuron) : base(new List <Neuron> { neuron }, new NeuralLayerOptions { IsFixed = true }) { _result = neuron; }
public NeuralNetwork Initialize(IReadOnlyCollection <FuzzyStatement> statements) { var resultNeuron = new ResultNeuron(); var conclusionNeurons = new List <Neuron>(); var activationNeurons = new List <Neuron>(); var statementNeurons = new List <Neuron>(); var ruleDictionary = new Dictionary <FuzzyRule, Neuron>(); var ruleNeurons = new List <KeyValuePair <FuzzyRule, Neuron> >(); // Строим 5, 4, 3 уровни нейросети foreach (var statement in statements) { var conclusionNeuron = new Neuron(); conclusionNeurons.Add(conclusionNeuron); resultNeuron.Dendrites.Add(new Dendrite(conclusionNeuron, 0.001d)); var activationNeuron = new Neuron(); activationNeurons.Add(activationNeuron); conclusionNeuron.Dendrites.Add(new Dendrite(activationNeuron, 0.005d)); } _layers.AddFirst(new ResultNeuralLayer(resultNeuron)); _layers.AddFirst(new ConclusionNeuralLayer(conclusionNeurons)); _layers.AddFirst(new ActivationNeuralLayer(activationNeurons)); // Строим 2, 1 уровни нейросети var activationLayer = _layers.First.Value; foreach (var statement in statements) { var statementNeuron = new Neuron(); statementNeurons.Add(statementNeuron); resultNeuron.PassthroughDendrites.Add(new Dendrite(statementNeuron, 0.0005d)); foreach (var neuron in activationLayer.Neurons) { neuron.Dendrites.Add(new Dendrite(statementNeuron, 0.00001d)); } foreach (var rule in statement.Rules) { if (!ruleDictionary.ContainsKey(rule)) { var neuron = new Neuron(); ruleDictionary.Add(rule, neuron); ruleNeurons.Add(new KeyValuePair <FuzzyRule, Neuron>(rule, neuron)); } statementNeuron.Dendrites.Add(new Dendrite(ruleDictionary[rule], 1d)); } } _layers.AddFirst(new StatementNeuralLayer(statementNeurons)); _layers.AddFirst(new RuleNeuralLayer(ruleNeurons)); return(this); }