Пример #1
0
        public void ReturnZeroErrorOnPatternsSameAsOutput()
        {
            var patternA = new LearningPattern
                {
                    Input = new List<IFuzzyNumber>
                        {
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(-1, 0, 1), 3),
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(-1, 0, 1), 3),
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(-1, 0, 1), 3),
                        },
                    Output = new List<IFuzzyNumber>(),
                };

            var patternB = new LearningPattern
            {
                Input = new List<IFuzzyNumber>
                        {
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(0, 1, 2), 3),
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(0, 1, 2), 3),
                            new DiscreteFuzzyNumber(new TriangularFuzzyFunction(0, 1, 2), 3),
                        },
                Output = new List<IFuzzyNumber>()
            };

            var bp = new BackPropagation(new List<ILearningPattern> { patternA, patternB });
            var net = new SimpleFuzzyNet(3, new[] {2}, () => DiscreteFuzzyNumber.GenerateLittleNumber(levelsCount: 3),
                                         levelsCount: 3);

            patternA.Output = net.Propagate(patternA.Input);
            patternB.Output = net.Propagate(patternB.Input);

            bp.StepPerformed += (state) => Assert.That(state.CycleError, Is.EqualTo(0.0));
            bp.LearnNet(net);
        }
Пример #2
0
        private string PackLine(LearningPattern pattern)
        {
            /*var sb = new StringBuilder();
            foreach(var input in pattern.)
            int inputOutputSeparator = line.IndexOf(_inputOutputSeparator);
            string inputsPart = line.Substring(0, inputOutputSeparator);
            string outputsPart = line.Substring(inputOutputSeparator + 1, line.Length - inputOutputSeparator - 1);

            if (inputsPart == "" || outputsPart == "")
                return null;

            const char numbersSeparator = _numbersSeparator;
            var inputsNumbers = inputsPart.Split(numbersSeparator);
            var inputs = inputsNumbers.Select(_parser.Parse).ToList();
            var outputsNumbers = outputsPart.Split(numbersSeparator);
            var outputs = outputsNumbers.Select(_parser.Parse).ToList();

            return new LearningPattern(inputs, outputs);*/
            return "";
        }