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

📄 teachersynapse.java

📁 一个纯java写的神经网络源代码
💻 JAVA
字号:
package org.joone.engine.learning;import org.joone.log.*;import org.joone.engine.*;import org.joone.io.*;import org.joone.net.NetCheck;import java.io.IOException;import java.util.TreeSet;/** * Final element of a neural network; it permits to calculate * both the error of the last training cycle and the vector * containing the error pattern to apply to the net to * calculate the backprop algorithm. */public class TeacherSynapse extends AbstractTeacherSynapse {        /**     * Logger     **/    protected static final ILogger log = LoggerFactory.getLogger(TeacherSynapse.class);        /** The error being calculated for the current epoch. */    protected transient double GlobalError = 0;        private static final long serialVersionUID = -1301682557631180066L;        public TeacherSynapse() {        super();    }        protected double calculateError(double aDesired, double anOutput, int anIndex) {        double myError = aDesired - anOutput;                // myError = Dn - Yn        // myError^2 = (Dn - yn)^2        // GlobalError += SUM[ SUM[ 1/2 (Dn - yn)^2]]        // GlobalError += SUM[ 1/2 SUM[(Dn - yn)^2]]                GlobalError += (myError * myError) / 2;        return myError;    }        protected double calculateGlobalError() {        double myError = GlobalError / getMonitor().getNumOfPatterns();        if(getMonitor().isUseRMSE()) {            myError = Math.sqrt(myError);        }        GlobalError = 0;        return myError;    }            public void fwdPut(Pattern pattern) {        super.fwdPut(pattern);                if (pattern.getCount() == -1) {            // reset error            GlobalError = 0;        }    }    }

⌨️ 快捷键说明

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