/// <summary>
        /// Главный метод нейросети - обучение на картинках 28x28 pixels
        /// </summary>
        public void Learn(DataNumberDTO_28x28_Set[] dataSet)
        {
            // Поэтапная тренировка по каждой картинке
            for (var i = 0; i < dataSet.Length; i++)
            {
                var rightAnswer = dataSet[i].Number;

                var neural3NetworkHelper = new Neural3NetworkHelper(Neural3NetworkCreator);

                // Трансформирование RGB - компонент в входной сигнал для нейронов входного слоя
                var RGBComponents         = dataSet[i].RGBComponents;
                var signalsFromInputLayer = neural3NetworkHelper.TransformWhiteBlackPixelsToSignals(RGBComponents);

                var inputLayer            = Neural3NetworkCreator.InputLayer;
                var hiddenLayer           = Neural3NetworkCreator.HiddenLayer;
                var outputLayer           = Neural3NetworkCreator.OutputLayer;
                var inputHiddenRelations  = neural3NetworkHelper.GetInputHiddenRelations();
                var hiddenOutputRelations = neural3NetworkHelper.GetHiddenOutputRelations();

                // Вычисление комбинированного и сглаженного сигнала, пропущенного через сигмоиду,
                // данный сигнал прошел через все узлы и вышел из output layer
                var signalsFromHiddenLayer = neural3NetworkHelper.CalcSignalsFromLayer(signalsFromInputLayer, inputLayer, hiddenLayer, inputHiddenRelations, _funcActivation);
                var signalsFromOutputLayer = neural3NetworkHelper.CalcSignalsFromLayer(signalsFromHiddenLayer, hiddenLayer, outputLayer, hiddenOutputRelations, _funcActivation);

                var neural3NetworkWeightsUpdater = new Neural3NetworkWeightsUpdater(this, signalsFromInputLayer, signalsFromHiddenLayer, signalsFromOutputLayer);

                // Обновление весов на нужных ребрах, в зависимости от ошибки и правильного ответа
                var errorsHiddenLayer = neural3NetworkWeightsUpdater.UpdateWeights(hiddenOutputRelations, signalsFromHiddenLayer, signalsFromOutputLayer, rightAnswer);
                neural3NetworkWeightsUpdater.UpdateWeights(errorsHiddenLayer, inputHiddenRelations, signalsFromInputLayer, signalsFromHiddenLayer);
            }
        }
 public RightAnswerForm(int resultNumber, Neural3NetworkWeightsUpdater neural3NetworkWeightsUpdater, Neural3NetworkHelper neural3NetworkHelper)
 {
     InitializeComponent();
     _resultNumN.Value             = resultNumber;
     _neural3NetworkWeightsUpdater = neural3NetworkWeightsUpdater;
     _neural3NetworkHelper         = neural3NetworkHelper;
 }
示例#3
0
        /// <summary>
        /// Проверка нейросети.
        /// Нейросеть должна предсказать, что это за цифра, отрисованная в редакторе.
        /// </summary>
        private void _checkNNBtn_Click(object sender, EventArgs e)
        {
            var id     = int.MaxValue;
            int number = int.MaxValue;

            var neural3NetworkChecker = new Neural3NetworkChecker(_neural3NetworkCreator);

            var colors = GetRGBComponents28x28FromEditor();
            var dataNumberDTO_28x28_Set = new DataNumberDTO_28x28_Set(id, number, colors);

            var signalsFromInputLayer  = new double[0];
            var signalsFromHiddenLayer = new double[0];
            var signalsFromOutputLayer = new double[0];
            var result = neural3NetworkChecker.Check(dataNumberDTO_28x28_Set, out signalsFromInputLayer, out signalsFromHiddenLayer, out signalsFromOutputLayer);

            var neural3NetworkWeightsUpdater = new Neural3NetworkWeightsUpdater(_neural3NetworkTeacher, signalsFromInputLayer, signalsFromHiddenLayer, signalsFromOutputLayer);

            var neural3NetworkHelper = new Neural3NetworkHelper(_neural3NetworkCreator);

            var rightAnswerForm = new RightAnswerForm(result.NeuronNumber, neural3NetworkWeightsUpdater, neural3NetworkHelper);

            rightAnswerForm.Show();
        }
        /// <summary>
        /// Главный метод нейросети - обучение на картинках 28x28 pixels
        /// </summary>
        public OutputSignalDTO Check(DataNumberDTO_28x28_Set imageDataSet, out double[] signalsFromInputLayer, out double[] signalsFromHiddenLayer, out double[] signalsFromOutputLayer)
        {
            var rightAnswer = imageDataSet.Number;

            var neural3NetworkHelper = new Neural3NetworkHelper(_neural3NetworkCreator);

            // Трансформирование RGB - компонент в входной сигнал для нейронов входного слоя
            var RGBComponents = imageDataSet.RGBComponents;

            signalsFromInputLayer = neural3NetworkHelper.TransformWhiteBlackPixelsToSignals(RGBComponents);

            var inputLayer            = _neural3NetworkCreator.InputLayer;
            var hiddenLayer           = _neural3NetworkCreator.HiddenLayer;
            var outputLayer           = _neural3NetworkCreator.OutputLayer;
            var inputHiddenRelations  = neural3NetworkHelper.GetInputHiddenRelations();
            var hiddenOutputRelations = neural3NetworkHelper.GetHiddenOutputRelations();

            // Вычисление комбинированного и сглаженного сигнала, пропущенного через сигмоиду,
            // данный сигнал прошел через все узлы и вышел из output layer
            signalsFromHiddenLayer = neural3NetworkHelper.CalcSignalsFromLayer(signalsFromInputLayer, inputLayer, hiddenLayer, inputHiddenRelations, _funcActivation);
            signalsFromOutputLayer = neural3NetworkHelper.CalcSignalsFromLayer(signalsFromHiddenLayer, hiddenLayer, outputLayer, hiddenOutputRelations, _funcActivation);

            return(neural3NetworkHelper.GetOutputSignalDTO(signalsFromOutputLayer));
        }