Пример #1
0
        public Trainer(Network net, Sample[] cases,
                       CheckCorrect checkCorrect, Sample[] testCases = null)
        {
            this.net       = net;
            this.cases     = cases;
            this.caseCount = cases.Length;

            if (caseCount == 0)
            {
                throw new Exception("Don't have any samples to train with!");
            }
            var sampleSample = cases[0];

            if (net.InputSize != sampleSample.input.Length)
            {
                throw new Exception(string.Format(
                                        "Net input size: {0}, doesn't match sample input size: {1}.",
                                        net.InputSize, sampleSample.input.Length));
            }
            if (net.OutputSize != sampleSample.target.Length)
            {
                throw new Exception(string.Format(
                                        "Net output size: {0}, doesn't match sample target size: {1}.",
                                        net.OutputSize, sampleSample.target.Length));
            }

            this.checkCorrect = checkCorrect;
            this.testCases    = testCases ?? new Sample[0];
        }
Пример #2
0
        public Trainer(Network net, Sample[] cases, 
            CheckCorrect checkCorrect, Sample[] testCases = null)
        {
            this.net = net;
            this.cases = cases;
            this.caseCount = cases.Length;

            if (caseCount == 0)
                throw new Exception("Don't have any samples to train with!");
            var sampleSample = cases[0];
            if (net.InputSize != sampleSample.input.Length)
                throw new Exception(string.Format(
                    "Net input size: {0}, doesn't match sample input size: {1}.",
                    net.InputSize, sampleSample.input.Length));
            if (net.OutputSize != sampleSample.target.Length)
                throw new Exception(string.Format(
                    "Net output size: {0}, doesn't match sample target size: {1}.",
                    net.OutputSize, sampleSample.target.Length));

            this.checkCorrect = checkCorrect;
            this.testCases = testCases ?? new Sample[0];
        }