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

📄 newnetworkcontroller.java

📁 利用Java实现的神经网络工具箱
💻 JAVA
字号:
/* * $RCSfile: NewNetworkController.java,v $ * $Revision: 1.9 $ * $Date: 2005/04/25 01:26:31 $ * * NeuralNetworkToolkit * Copyright (C) 2004 Universidade de Brasília * * This file is part of NeuralNetworkToolkit. * * NeuralNetworkToolkit is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * NeuralNetworkToolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NeuralNetworkToolkit; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 - USA. */package neuralnetworktoolkit.gui.newnetwork;import java.util.ResourceBundle;import java.util.Vector;import javax.swing.JOptionPane;import neuralnetworktoolkit.architectures.ArchitectureParameters;import neuralnetworktoolkit.architectures.mlp.MLPParameters;import neuralnetworktoolkit.gui.navigation.*;import neuralnetworktoolkit.gui.options.OptionsDialog;import neuralnetworktoolkit.gui.options.OptionsDialogException;import neuralnetworktoolkit.methods.TrainingParameters;import neuralnetworktoolkit.normalization.NormalizationParameters;/** * */public class NewNetworkController {	private NewNetworkFrame newNetworkFrame;		private NavigationController navController;		private String architecture;	private String trainingMethod;	private ArchitectureParameters parameters;	private TrainingParameters trainingParameters;	private NormalizationParameters normalizationParameters;	private int inputSize;		private ResourceBundle resource;		/**	 * 	 * @param navController	 * @param displayData	 * @param dataHeader	 */	public NewNetworkController(NavigationController navController,			Vector displayData, Vector dataHeader) {		this.navController = navController;		newNetworkFrame = new NewNetworkFrame(this, displayData, dataHeader);		resource = ResourceBundle				.getBundle("neuralnetworktoolkit.gui.newnetwork.resources.NewNetworkControllerResource");				inputSize = dataHeader.size() - 1;		this.architecture = "";		this.trainingMethod = "";		normalizationParameters = new NormalizationParameters();		normalizationParameters.configureDefault();		this.architecture = newNetworkFrame.getArchitecture();		try {			parameters = (ArchitectureParameters) Class.forName(					"neuralnetworktoolkit.architectures.mlp." + architecture					+ "Parameters").newInstance();			parameters.setInputSize(inputSize);			parameters.configureDefault();						this.trainingMethod = newNetworkFrame.getMethod();			trainingParameters = (TrainingParameters) Class.forName(					"neuralnetworktoolkit.methods." + trainingMethod							+ "Parameters").newInstance();			trainingParameters.setMethod(trainingMethod);			trainingParameters.configureDefault();					} catch (InstantiationException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					} catch (IllegalAccessException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					} catch (ClassNotFoundException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					}	} //NewNetworkController()		/**	 * 	 * @param networkName	 * @param outputIndex	 */	public void createNetwork(String networkName, int[] outputIndex) {		String methodName;		String architecture;		String trainingMethod;				architecture = this.newNetworkFrame.getArchitecture();		trainingMethod = this.newNetworkFrame.getMethod();				try {			if (!this.architecture.equals(architecture)) {				this.architecture = architecture;				parameters = (ArchitectureParameters) Class.forName(						"neuralnetworktoolkit.architectures.mlp."								+ architecture + "Parameters").newInstance();				parameters.configureDefault();			}			methodName = trainingMethod;			if (!this.trainingMethod.equals(trainingMethod)) {				this.trainingMethod = trainingMethod;				trainingParameters = (TrainingParameters) Class.forName(						"neuralnetworktoolkit.methods." + methodName								+ "Parameters").newInstance();				trainingParameters.setMethod(methodName);				trainingParameters.configureDefault();			}			navController.createNetwork(networkName, outputIndex, parameters,					trainingParameters, normalizationParameters);		} catch (InstantiationException e) {			JOptionPane.showMessageDialog(newNetworkFrame, resource					.getString("loadClass")					+ e.getMessage(), resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);		} catch (IllegalAccessException e) {			JOptionPane.showMessageDialog(newNetworkFrame, resource					.getString("loadClass")					+ e.getMessage(), resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);		} catch (ClassNotFoundException e) {			JOptionPane.showMessageDialog(newNetworkFrame, resource					.getString("loadClass")					+ e.getMessage(), resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);		}			} //createNetwork()		/**	 * 	 * @param architecture	 * @param trainingMethod	 */	public void options(String architecture, String trainingMethod) {		OptionsDialog dialog;		String method;				try {			if (!this.architecture.equals(architecture)) {				this.architecture = architecture;				parameters = (ArchitectureParameters) Class.forName(						"neuralnetworktoolkit.architectures.mlp." + architecture						+ "Parameters").newInstance();				parameters.configureDefault();			}			method = trainingMethod;			if (!this.trainingMethod.equals(trainingMethod)) {				this.trainingMethod = trainingMethod;				trainingParameters = (TrainingParameters) Class.forName(						"neuralnetworktoolkit.methods." + method								+ "Parameters").newInstance();				trainingParameters.setMethod(method);				trainingParameters.configureDefault();			}			dialog = new OptionsDialog(this.architecture, method, newNetworkFrame.getMethodName(),					parameters,					trainingParameters,					normalizationParameters);			dialog.showDialog(newNetworkFrame);						if (architecture.equals("MLP")) {				MLPParameters mlp = (MLPParameters) parameters;				if (mlp.getNeurons().length <= 2) {					JOptionPane.showMessageDialog(newNetworkFrame, resource							.getString("internalLayersError"), resource							.getString("nntk"), JOptionPane.ERROR_MESSAGE);					options(architecture, trainingMethod);				}			}					} catch (InstantiationException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					} catch (IllegalAccessException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					} catch (ClassNotFoundException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					resource.getString("loadClass") + e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					} catch (OptionsDialogException e) {			JOptionPane.showMessageDialog(					newNetworkFrame,					e.getMessage(),					resource.getString("nntk"),					JOptionPane.ERROR_MESSAGE);					}			} //options()		/**	 * @return Returns the newNetworkFrame.	 */	public NewNetworkFrame getNewNetworkFrame() {		return newNetworkFrame;			} //getNewNetworkFrame()	} //NewNetworkController

⌨️ 快捷键说明

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