Exemple #1
0
        public void saveNetworkOnFile(string path)
        {
            // Delete the file if it exists.
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            FileStream fs        = File.Create(path);
            string     netConfig = "";

            netConfig += "Rho " + this.rho + "\r\n";
            netConfig += "RhoInc " + this.rhoIncrement + "\r\n";
            netConfig += "Alpha " + this.alpha + "\r\n";
            netConfig += "Beta " + this.beta + "\r\n";
            netConfig += "CC " + this.complementCoding + "\r\n";
            netConfig += "F1 " + this.ARTModule.F1.Count + "\r\n";
            netConfig += "MFCategoryCount " + this.mapField.getCategoryCount() + "\r\n";
            for (int catIndex = 0; catIndex < this.mapField.getCategoryCount(); catIndex++)
            {
                MapFieldCategory cat = (MapFieldCategory)this.mapField.categories[catIndex];
                netConfig += cat.getCode() + "\r\n";
                netConfig += cat.getName() + "\r\n";
            }
            netConfig += "ContextCount " + this.ARTModule.contextField.Count + "\r\n";
            ICollection contextKeys     = this.ARTModule.contextField.Keys;
            IEnumerator contextKeysEnum = contextKeys.GetEnumerator();

            while (contextKeysEnum.MoveNext())
            {
                int contextKey = Int32.Parse(contextKeysEnum.Current.ToString());
                netConfig += "Context " + contextKey + "\r\n";
                LayerF2 F2 = ((LayerF2)this.ARTModule.contextField[contextKey]);
                netConfig += "F2Count " + F2.Count + "\r\n";
                for (int f2Index = 0; f2Index < F2.Count; f2Index++)
                {
                    netConfig += "Prototype\r\n";
                    double [] prototype = ((F2Neuron)F2[f2Index]).getProtoTypeCluster();
                    for (int i = 0; i < prototype.Length; i++)
                    {
                        netConfig += prototype[i] + "\t";
                    }
                    netConfig += "\r\n";
                    netConfig += "tdConnWs\r\n";
                    SynapticConnection[] conns = ((F2Neuron)F2[f2Index]).getConnections();
                    for (int connIndex = 0; connIndex < conns.Length; connIndex++)
                    {
                        netConfig += ((SynapticConnection)conns[connIndex]).getWeight() + "\t";
                    }
                    netConfig += "\r\n";
                    netConfig += "CatCode\r\n";
                    //for (int f2Index = 0; f2Index < F2.Count; f2Index++)
                    {
                        MapFieldConnection mapFieldConn = ((F2Neuron)F2[f2Index]).getMapFieldConnection();
                        netConfig += mapFieldConn.getCategory().getCode() + "\r\n";
                    }
                }
            }
            AddText(fs, netConfig);
            fs.Close();
        }
Exemple #2
0
        //public int recall(int contextCode, double[] Pattern) // THIS METHOD ASSUMES THAT EACH F2 NODE HAS CONNECTIONS WITH ALL MAPFIELD NODES
        //{
        //    ARTModule.reSetRho(rho);
        //    int code = -1; // Don't Know
        //    LayerF2 contextNeurons = (LayerF2)ARTModule.contextField[contextCode];
        //    object [,]artCluster = ARTModule.getCluster(contextCode, Pattern);
        //    if ((int)artCluster[0, 1] == -1)
        //        code = -1;
        //    else
        //    {
        //        F2Neuron f2Neuron = (F2Neuron)contextNeurons[(int)artCluster[0, 1]];
        //        f2Neuron.getMapFieldConnections();
        //        ArrayList mapFieldConnections = f2Neuron.getMapFieldConnections();
        //        IEnumerator mapFieldConnEnum = mapFieldConnections.GetEnumerator();
        //        while (mapFieldConnEnum.MoveNext())
        //        {
        //            MapFieldConnection mapFieldConn = (MapFieldConnection)mapFieldConnEnum.Current;
        //            if (mapFieldConn.getWeight() == 1)
        //            {
        //                MapFieldCategory category = mapFieldConn.getCategory();
        //                code = category.getCode();
        //                //break;
        //            }
        //        }
        //    }
        //       // code = mapField.getAssociatedCategory(contextNeurons, (int)artCluster[0, 1]);
        //    return code;
        //}
        public int recall(int contextCode, double[] Pattern) //THIS METHOD ASSUMES THAT EACH F2 NODE IS CONNECTED WITH ONLY ONE MAPFIELD NODE
        {
            ARTModule.reSetRho(rho);
            int     code           = -1; // Don't Know
            LayerF2 contextNeurons = (LayerF2)ARTModule.contextField[contextCode];

            object[,] artCluster = ARTModule.getCluster(contextCode, Pattern);
            if ((int)artCluster[0, 1] == -1)
            {
                code = -1;
            }
            else
            {
                F2Neuron           f2Neuron = (F2Neuron)contextNeurons[(int)artCluster[0, 1]];
                MapFieldConnection mfConn   = f2Neuron.getMapFieldConnection();
                MapFieldCategory   category = mfConn.getCategory();
                code = category.getCode();
            }
            // code = mapField.getAssociatedCategory(contextNeurons, (int)artCluster[0, 1]);
            return(code);
        }