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

📄 testxml.java

📁 一个纯java写的神经网络源代码
💻 JAVA
字号:
/* * TestXML.java * * Created on 28 aprile 2004, 22.17 */package org.joone.samples.engine.xml;import org.joone.net.*;import org.joone.engine.*;import org.joone.io.*;import java.io.*;import com.thoughtworks.xstream.XStream;import com.thoughtworks.xstream.io.xml.DomDriver;/** * * @author  paolo */public class TestXML implements NeuralNetListener, NeuralValidationListener {    NeuralNet result;    /** Creates a new instance of TestXML */    public TestXML() {    }        /**     * @param args the command line arguments     */    public static void main(String[] args) {        new TestXML().elaborate();    }        private void elaborate() {        try {            XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library//            result = (NeuralNet)xstream.fromXML(new FileReader("/home/paolo/SourceForge/ValidationSample.xml"));            result = (NeuralNet)xstream.fromXML(new FileReader("/home/paolo/SourceForge/xor.xml"));            System.out.println("Unmarshaling Done");                        result.getMonitor().addNeuralNetListener(this);            result.getMonitor().setTotCicles(3000);            result.randomize(0.2);            result.start();            result.getMonitor().Go();                    } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); }    }        public void cicleTerminated(NeuralNetEvent e) {    }        public void errorChanged(NeuralNetEvent e) {        Monitor mon = (Monitor)e.getSource();        if ((mon.getCurrentCicle() % 200) == 0) {            System.out.println("RMSE at epoch "+(mon.getTotCicles()-mon.getCurrentCicle())+": "+mon.getGlobalError());            if (mon.getValidationPatterns() > 0) {                NeuralNet newNet = result.cloneNet();                newNet.removeAllListeners();                NeuralNetValidator val = new NeuralNetValidator(newNet);                val.addValidationListener(this);                val.start();            }        }    }        public void netStarted(NeuralNetEvent e) {        System.out.println("Running...");    }        public void netStopped(NeuralNetEvent e) {        System.out.println("Finished");    }        public void netStoppedError(NeuralNetEvent e, String error) {    }            public void netValidated(NeuralValidationEvent e) {        // Shows the RMSE at the end of the cycle        NeuralNet NN = (NeuralNet)e.getSource();        System.out.println("\tValidation error="+NN.getMonitor().getGlobalError());    }    }

⌨️ 快捷键说明

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