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

📄 janetproject.java

📁 JaNet: Java Neural Network Toolkit resume: A well documented toolkit for designing and training, a
💻 JAVA
字号:
////////////////////////////////////////////////////////////////////////////////////  //  //  Copyright (C) 1996 L.  Patocchi & W.Gander////  This program 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.////  This program 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//  this program; if not, write to the Free Software  Foundation, Inc., 675 Mass//  Ave, Cambridge, MA 02139, USA.////  Contacts://  //    Project Supervisor//      W.Hett       hew@info.isbiel.ch//  //    Authors//      W.Gander     gandw@info.isbiel.ch//      L.Patocchi   patol@info.isbiel.ch////  Documentation can be found at:////      http://www.isbiel.ch/Projects/janet/index.html////////////////////////////////////////////////////////////////////////////////////////// File : jaNetProject.java//package jaNet;import java.io.*;import java.util.*;public class jaNetProject{	private static final String		version = "1.0beta1";	public  String	pathName;	public  String	fileName;	public  String	description		= "jaNet project";	private Vector	NNModules;		private boolean	needSave = false;	public jaNetProject(String pathname, String filename){		pathName	= pathname;		fileName	= filename;		NNModules	= new Vector();		needSave 	= true;	}	public void setLocation(String pathname, String filename){		pathName	= pathname;		fileName	= filename;	}			public void load() throws IOException{		try{			File rawfile = new File(pathName, fileName);			RandomAccessFile file = new RandomAccessFile(rawfile,"r");			read(file);			file.close();		}			catch(IOException ioe){			throw new IOException("Project: Error in load,"+ioe);		}		catch(SecurityException se){			throw new IOException("Project: Error in load,"+se);		}		catch(IllegalArgumentException ignore){}		needSave = false;				// Start all modules		ModuleEntry me = null;		NNeMo		tempNNeMo = null;		for(int i=0; i<NNModules.size(); i++){			me = ((ModuleEntry)NNModules.elementAt(i));			String className = me.classType.ModuleClassName;			try{				// try to load and create a new instance of a class which the name is specified in fnclassname string.				tempNNeMo = (NNeMo) Class.forName(className).newInstance();			}catch (InstantiationException instex){				throw new IOException("Error in instantiation "+className+".class ("+instex+").");			}catch (IllegalAccessException illaccex){				throw new IOException("Error in accessing "+className+".class ("+illaccex+").");			}catch (ClassNotFoundException classnotfound){				throw new IOException("Error, "+className+".class not found ("+classnotfound+").");			}			me.current = tempNNeMo;			tempNNeMo.NNeMoInit(me);		}	}	public void save() throws IOException{		for(int i=0; i< NNModules.size(); i++){			ModuleEntry me = ((ModuleEntry)NNModules.elementAt(i));			// if need save then save it			if(me.current.NNeMoNeedSave()) me.current.NNeMoSave();		}		try{			File rawfile = new File(pathName, fileName);			RandomAccessFile file = new RandomAccessFile(rawfile,"rw");			write(file);			file.close();		}			catch(IOException ioe){			throw new IOException("Project: Error in load,"+ioe);		}		catch(SecurityException se){			throw new IOException("Project: Error in load,"+se);		}		catch(IllegalArgumentException ignore){}				needSave = false;	}		public boolean needSave(){		return true; // always needSave;	}		public void close(){		for(int i=0; i< NNModules.size(); i++){			ModuleEntry me = ((ModuleEntry)NNModules.elementAt(i));			me.current.NNeMoClose();		}	}		public void saveAll() throws IOException{		save();	}	public synchronized void addNewModuleEntry(ModuleEntry me){		NNModules.addElement(me);		needSave = true;	}	public synchronized ModuleEntry getModuleEntry(int index){		return (ModuleEntry)NNModules.elementAt(index);	}	public synchronized void delModuleEntry(int index){		NNModules.removeElementAt(index);		needSave = true;	}	public synchronized void setModuleEntry(ModuleEntry me, int index){		NNModules.setElementAt(me, index);		needSave = true;	}	public synchronized int	getModuleCount(){		return NNModules.size();	}	public void write(RandomAccessFile raf) throws IOException {		raf.writeUTF(""+getClass().getName()+version);		raf.writeUTF(description);			raf.writeUTF(pathName);		raf.writeUTF(fileName);		int validModules = 0;		// counts writable elements		for(int i=0; i< NNModules.size(); i++)			if(((ModuleEntry)NNModules.elementAt(i)).canBeSaved())validModules++;		raf.writeInt(validModules);		// write writable elements		for(int i=0; i< NNModules.size(); i++){			if(((ModuleEntry)NNModules.elementAt(i)).canBeSaved())				((ModuleEntry)NNModules.elementAt(i)).write(raf);		}	}	public void read(RandomAccessFile raf) throws IOException {		if(raf.readUTF().compareTo(getClass().getName()+version) != 0){			throw new IOException("Project: Error in read, unknown version.");		}		String dummy;				description = raf.readUTF();		dummy = raf.readUTF();		dummy = raf.readUTF();		int n = raf.readInt();		for(int i=0; i< n; i++){			NNModules.addElement(new ModuleEntry(raf));		}	}}

⌨️ 快捷键说明

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