public MapFieldConnection(MapFieldCategory category, ContextAwareFuzzyART.NET.F2Neuron f2Neuron, int weight) { this.category = category; this.f2Neuron = f2Neuron; this.f2Neuron.addMapFieldConnection(this); this.weight = weight; }
public int recall(int contextCode, double[] Pattern) { 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 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 = this.mapField.getCategory(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 += "MFConns \r\n"; //for (int f2Index = 0; f2Index < F2.Count; f2Index++) { ArrayList mapFieldConns = ((F2Neuron)F2[f2Index]).getMapFieldConnections(); for (int mapFieldConnIndex = 0; mapFieldConnIndex < mapFieldConns.Count; mapFieldConnIndex++) { netConfig += ((MapFieldConnection)mapFieldConns[mapFieldConnIndex]).getWeight() + "\t"; } netConfig += "\r\n"; } } } AddText(fs, netConfig); fs.Close(); }