Example #1
0
        /// <summary>
        /// Glowna procedura uczenia
        /// </summary>
        /// <param name="docs">dane uczace</param>
        /// <returns></returns>
        public override bool Learn(Object obj)
        {
            if (obj == null)
            {
                throw new NullReferenceException("docList puste");
            }
            if (!(obj is DocumentList))
            {
                throw new ArgumentException("Argument nie jest typu: DocumentList !");
            }

            double num1 = 0, num2 = 0;

            DocumentList docList = obj as DocumentList;

            docList.ToString();

            this.learningData = docList;
            documentList      = docList.GetAllDataRandomized();
            PreSelect();
            if (documentList == null || documentList.Count == 0)
            {
                throw new NullReferenceException("DocumentList pusty");
            }
            List <double[]> desiredOutputData = PrepareOutputData(documentList);

            CoverSpaceByNeuronCells(docList.GetMinValues().ToArray(), docList.GetMaxValues().ToArray(), this.neuronOutputLayer);
            do
            {
                double num3 = 0, num4 = 0;
                OutputLayerLearning(desiredOutputData);
                do
                {
                    HiddenLayerLearning();
                    PrintNeuronsInfo();
                    num4 = num3;
                    num3 = LearnCheck();
                    //if (bWorker != null && bWorker.CancellationPending)dodaƂem tomek
                    //    return false;
                } while (num3 > num4);
                foreach (RadialNeuron n in neuronHiddenLayer)
                {
                    n.BackToPrevWeights();
                }
                num2 = num1;
                num1 = LearnCheck();
            } while (num1 > num2);
            //MessageBox.Show("Koniec nauki");
            foreach (LinearNeuron n in neuronOutputLayer)
            {
                n.BackToPrevWeights();
            }
            return(true);
        }