⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demogng.java

📁 关于自组织神经网络的一种新结构程序,并包含了其它几种神经网络的程序比较
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		((CardLayout)cards.getLayout()).show(cards, ALGO_1);		compute.epsilon = epsilonHCL_Af[0];		nodes_lbl.setText("     Nodes:");		compute.e_i = epsiloniHCL_Af[0];		compute.e_f = epsilonfHCL_Af[0];		compute.t_max = tmaxHCL_Af[0];		// Gernerate some nodes		for (i = 0; i < compute.maxNodes; i++)		  compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for Neural Gas (NG)      else if (algorithm.equals(ALGO_ABBREV_2)) {		compute.algo = 2;		algo_choice.select(NG_C);		algo_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_2);		compute.stepSize = stepSize_Ai[3];		stepSize_choice.select(3);		stepSize_choice.show();		nodes_lbl.setText("     Nodes:");		compute.l_i = lambdaiNG_Af[0];		compute.l_f = lambdafNG_Af[0];		compute.e_i = epsiloniNG_Af[0];		compute.e_f = epsilonfNG_Af[0];		compute.t_max = tmaxNG_Af[0];		// Gernerate some nodes		for (i = 0; i < compute.maxNodes; i++)		  compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for Neural Gas with Competitive Hebian Learning (NGwCHL)      else if (algorithm.equals(ALGO_ABBREV_3)) {		compute.algo = 3;		algo_choice.select(NGwCHL_C);		algo_choice.show();		compute.stepSize = stepSize_Ai[3];		stepSize_choice.select(3);		stepSize_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_3);		nodes_lbl.setText("     Nodes:");		compute.l_i = lambdaiCHL_Af[0];		compute.l_f = lambdafCHL_Af[0];		compute.e_i = epsiloniCHL_Af[0];		compute.e_f = epsilonfCHL_Af[0];		compute.t_max = tmaxCHL_Af[0];		compute.delEdge_i = edgeiCHL_Ai[0];		compute.delEdge_f = edgefCHL_Ai[0];		// Gernerate some nodes		for (i = 0; i < compute.maxNodes; i++)		  compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for Competitive Hebian Learning (CHL)      else if (algorithm.equals(ALGO_ABBREV_4)) {		compute.algo = 4;		algo_choice.select(CHL_C);		algo_choice.show();		compute.stepSize = stepSize_Ai[0];		stepSize_choice.select(0);		stepSize_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_4);		nodes_lbl.setText("     Nodes:");		// Gernerate some nodes		for (i = 0; i < compute.maxNodes; i++)		  compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for LBG (LBG)      else if (algorithm.equals(ALGO_ABBREV_5) ||			   algorithm.equals(ALGO_ABBREV_5_U)) {		if (algorithm.equals(ALGO_ABBREV_5_U)) {		  compute.LBG_U_B = true;		  LBG_U_cb.setState(compute.LBG_U_B);		}		compute.algo = 5;		algo_choice.select(LBG_C);		algo_choice.show();		compute.stepSize = stepSize_Ai[1];		stepSize_choice.select(1);		stepSize_choice.show();		compute.maxNodes = nodes_Ai[5];		nodes_choice.select(5);		nodes_choice.show();		compute.numDiscreteSignals = discreteNumSignalsLBG_Ai[0];		discreteNumSignalsLBG_choice.select(0);		discreteNumSignalsLBG_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_5);		nodes_lbl.setText("     Nodes:");		compute.errorBestLBG_U = Float.MAX_VALUE;		        }      // Init for Growing Grid (GG)      else if (algorithm.equals(ALGO_ABBREV_6)) {		compute.algo = 6;		algo_choice.select(GG_C);		algo_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_6);		compute.stepSize = stepSize_Ai[0];		compute.l_i = lambdagGG_Af[0];		compute.l_f = lambdafGG_Af[0];		compute.e_i = epsiloniGG_Af[0];		compute.e_f = epsilonfGG_Af[0];		compute.sigma = sigmaGG_Af[0];		// Gernerate some nodes		compute.initGrid(2, 2,					   new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for Self-Organizing Map (SOM)      else if (algorithm.equals(ALGO_ABBREV_7)) {		compute.algo = 7;		algo_choice.select(SOM_C);		algo_choice.show();		((CardLayout)cards.getLayout()).show(cards, ALGO_7);		compute.stepSize = stepSize_Ai[0];		compute.e_i = epsiloniSOM_Af[0];		compute.e_f = epsilonfSOM_Af[0];		compute.sigma_i = sigmaiSOM_Af[0];		compute.sigma_f = sigmafSOM_Af[0];		compute.t_max = tmaxSOM_Af[0];		nodes_lbl.disable();		nodes_choice.disable();		// Gernerate some nodes		compute.initGrid(sizeSOM_Ai[0][0], sizeSOM_Ai[0][1],					   new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }      // Init for Growing Neural Gas (GNG) and GNG-U      else {		if (algorithm.equals(ALGO_ABBREV_0_U)) {		  compute.utilityGNGB = true;		  utilityGNG_cb.setState(compute.utilityGNGB);		}		compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));		if (compute.maxNodes != 1)		  compute.addNode(new Dimension(compute.INIT_WIDTH, compute.INIT_HEIGHT));      }    }	compute.errorGraph = new GraphGNG(this);	compute.errorGraph.graph.startNewTrace();  }  public void start() {    compute.start();  }  public void stop() {    compute.stop();  }  public void destroy() {	compute.destroy();  }  public void graphClose() {	compute.errorGraphB = false;	errorGraph_cb.setState(false);	compute.graphClose();  }  public boolean action(Event evt, Object arg) {	int i;    Dimension d = compute.size();    // A Checkbox event?    if (arg instanceof Boolean) {      // Get the label of the changed checkbox      String cb = ((Checkbox)evt.target).getLabel();      if (cb.equals(SIGNALS)) {		compute.signalsB = ((Boolean)arg).booleanValue();      } else if (cb.equals(NO_NEW_NODES)) {		compute.noNodesB = ((Boolean)arg).booleanValue();      } else if (cb.equals(UTILITY_GNG)) {		compute.utilityGNGB = ((Boolean)arg).booleanValue();      } else if (cb.equals(LBG_U)) {		compute.LBG_U_B = ((Boolean)arg).booleanValue();      } else if (cb.equals(SOUND)) {		compute.soundB = ((Boolean)arg).booleanValue();      } else if (cb.equals(WHITE)) {		compute.whiteB = ((Boolean)arg).booleanValue();      } else if (cb.equals(RNDINIT)) {		compute.rndInitB = ((Boolean)arg).booleanValue();      } else if (cb.equals(NODES)) {		compute.nodesB = ((Boolean)arg).booleanValue();      } else if (cb.equals(EDGES)) {		compute.edgesB = ((Boolean)arg).booleanValue();      } else if (cb.equals(ERRORGRAPH)) {		compute.errorGraphB = ((Boolean)arg).booleanValue();      } else if (cb.equals(VORONOI)) {		compute.voronoiB = ((Boolean)arg).booleanValue();		compute.nodesMovedB = true;      } else if (cb.equals(DELAUNAY)) {		compute.delaunayB = ((Boolean)arg).booleanValue();		compute.nodesMovedB = true;      } else if (cb.equals(TEACH)) {		compute.teachB = ((Boolean)arg).booleanValue();      } else if (cb.equals(VARIABLE)) {		compute.variableB = ((Boolean)arg).booleanValue();		if (compute.variableB) {		  epsilonHCL_lbl.disable();		  epsilonHCL_choice.disable();		  epsiloniHCL_lbl.enable();		  epsilonfHCL_lbl.enable();		  tmaxHCL_lbl.enable();		  		  epsiloniHCL_choice.enable();		  epsilonfHCL_choice.enable();		  tmaxHCL_choice.enable();		} else {		  epsilonHCL_lbl.enable();		  epsilonHCL_choice.enable();		  epsiloniHCL_lbl.disable();		  epsilonfHCL_lbl.disable();		  tmaxHCL_lbl.disable();		  		  epsiloniHCL_choice.disable();		  epsilonfHCL_choice.disable();		  tmaxHCL_choice.disable();		}      }      return true;    }    // A Button event?    else if (evt.target instanceof Button) {      // Start      if (BUTTON_0.equals(arg)) {		start_b.disable();		stop_b.enable();		restart_b.disable();		compute.stopB = false;		compute.readyLBG_B = false;      }      // Stop      else if (BUTTON_1.equals(arg)) {		start_b.enable();		stop_b.disable();		restart_b.enable();		compute.stopB = true;      }      // Reset      else if (BUTTON_3.equals(arg)) {		// Reset values		compute.numRun = 0;		compute.nnodes = 0;		compute.nedges = 0;		compute.noNodesB = noNodes_cb.getState();		compute.utilityGNGB = utilityGNG_cb.getState();		compute.nodesMovedB = true;        // Set specific algorithm parameters        if (compute.algo == 0) {		  compute.addNode(d);		  if (compute.maxNodes != 1)			compute.addNode(d);        } else if (compute.algo == 5) {		  // Initialize discrete signals		  // compute.initDiscreteSignals(compute.distribution);		  compute.readyLBG_B = false;		  compute.errorBestLBG_U = Float.MAX_VALUE;		  		  compute.LBG_U_B = LBG_U_cb.getState();		  // Gernerate some nodes		  int z = (int) (compute.numDiscreteSignals * Math.random());		  for (i = 0; i < compute.maxNodes; i++)			compute.addNode(compute.discreteSignalsX[(z+i)%compute.numDiscreteSignals],							compute.discreteSignalsY[(z+i)%compute.numDiscreteSignals]);        } else if (compute.algo == 6) {		  // Set default values		  compute.fineTuningB = false;		  if (compute.maxNodes < 4) {			compute.maxNodes = nodes_Ai[0];			nodes_choice.select(0);			nodes_choice.show();		  }		  // Gernerate some nodes		  compute.initGrid(2, 2, d);        } else if (compute.algo == 7) {		  // Set default values		  // Gernerate some nodes		  compute.initGrid(sizeSOM_Ai[sizeSOM_index][0],						   sizeSOM_Ai[sizeSOM_index][1], d);		} else {          // Gernerate some nodes          for (i = 0; i < compute.maxNodes; i++)            compute.addNode(d);        }      }      return true;    }    // A Choice event?    else if (evt.target instanceof Choice) {      // algorithm      if (algo_choice.equals(evt.target)) {		// Reset values		compute.numRun = 0;		compute.nnodes = 0;		compute.nedges = 0;		compute.noNodesB = noNodes_cb.getState();		compute.utilityGNGB = utilityGNG_cb.getState();		compute.nodesMovedB = true;		nodes_lbl.enable();		nodes_choice.enable();        ((CardLayout)cards.getLayout()).show(cards,(String)arg);        // Set specific algorithm parameters		if (arg.equals(ALGO_0)) {		  compute.algo = 0;		  // Set default values		  compute.addNode(d);		  if (compute.maxNodes != 1)			compute.addNode(d);		  nodes_lbl.setText("max. Nodes:");          compute.epsilonGNG = epsilonGNG1_Af[0];		  epsilonGNG1_choice.select(0);		  epsilonGNG1_choice.show();          compute.epsilonGNG2 = epsilonGNG2_Af[0];		  epsilonGNG2_choice.select(0);		  epsilonGNG2_choice.show();          compute.alphaGNG = alphaGNG_Af[0];		  alphaGNG_choice.select(0);		  alphaGNG_choice.show();          compute.forgetFactor = 1.0f - betaGNG_Af[0];          compute.forgetFactorUtility = 1.0f - betaGNG_Af[0];		  betaGNG_choice.select(0);		  betaGNG_choice.show();          compute.utilityGNG = utilityGNG_Af[0];		  utilityGNG_choice.select(0);		  utilityGNG_choice.show();          compute.MAX_EDGE_AGE = delEdgeGNG_Ai[0];		  delEdgeGNG_choice.select(0);		  delEdgeGNG_choice.show();          compute.NUM_NEW_NODE = newNodeGNG_Ai[0];		  newNodeGNG_choice.select(0);		  newNodeGNG_choice.show();		} else if (arg.equals(ALGO_1)) {		  compute.algo = 1;		  // Set default values		  nodes_lbl.setText("Nodes:");          compute.epsilon = epsilonHCL_Af[0];		  epsilonHCL_choice.select(0);		  epsilonHCL_choice.show();		  compute.e_i = epsiloniHCL_Af[0];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -