亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? backpropagation.java

?? 用java實現的神經網絡bp的核心算法
?? JAVA
字號:
/*
 * BackPropagation.java
 *
 * Created on 2007年11月15日, 上午4:01
 *
 */

package neuralNetwork;
import myUtil.*;
import java.util.*;
import java.io.*;
/**
 * Class for back propagation computing.
 * @author yuhui_bear
 */
public class BackPropagation {
    /**
     * instance of network.
     */
    public NeuralNetwork network;
    /**
     * the array stroed all neurons.
     */
    private Neuron[][] nntA ;
    private int den = 0;
    /**
     * half absolute output range of network.
     */
    private final float a= 1.716F;
    private final float b= 0.6F;
    private int midlay=0 , midsize=0;
    /**
     * Creates a new instance of BackPropagation
     * @param nettop int array stored numbers of each layer.
     * @param branch dendrities of neuron.
     */
    public BackPropagation(int[] nettop , int branch) {
        network = new NeuralNetwork(nettop,branch);
        nntA = network.neuralNet_A;
        den = nntA[0][0].dendrites.length -1;
        midlay = (int)(network.getNetInformation().nettop.length /2);
        midsize = network.getNetInformation().nettop[midlay];
    }
    /**
     * create a back propagation instance ,a neural network included.
     * @param filename this is the neural net file.
     */
    public BackPropagation(File filename){
        try {
            network = new NeuralNetwork(filename);
            nntA = network.neuralNet_A;
            den = nntA[0][0].dendrites.length -1;
        } catch (IOException ex) {
            ex.printStackTrace();
            System.exit(-1);
        }
        midlay = (int)(network.getNetInformation().nettop.length /2) ;
        midsize = network.getNetInformation().nettop[midlay];
    }
//    public Neuron[][]  getNet(){
//        return nntA;
//    }
     /**
     * encode input data .
     * @param indata soure data to be encoded
     * @return encoded data.
     */
    public double[] encode(double[] indata){
        double[] endata = forwardCalculate(indata);
        for (int i = 0 ; i< midsize; i++){
            endata[i] = nntA[midlay][i].output();
        }
        return endata;
    }
    /**
     * get encoded data .
     * @return return encoded data.
     */
    public double[] encode(){
        double[] endata = new double[midsize];
        for (int i = 0 ; i< midsize; i++){
            endata[i] = nntA[midlay][i].output();
        }
        return endata;
    }
    /**
     * decode input data.
     * @param sourceData data to be decoded.
     * @return decoded data.
     */
    public double[] decode(double[] sourceData){
        if( ! (((sourceData.length % den) ==0 ) || ((den % sourceData.length) ==0 ))){
           System.err.append("decode error!!! size of soure data cann't matches dendrities of neuron.");
           System.exit(-1);
        }
        Fetcher linker = new Fetcher(sourceData.length);
        double[] input = new double[den];        
        int[] linkArray ;
        Neuron curNp= null;
        int midnextSize =nntA[midlay+1].length;
        for ( int curn =0;curn < midnextSize; curn ++){
            linkArray =linker.nextGroup(den);
            for ( int k =0; k< den;k++){
                input[k] = sourceData[linkArray[k]];
            }
            nntA[midlay+1][curn].input(input);
        }
        if (midlay +2 < nntA.length){
            for ( int curl = midlay+2; curl<nntA.length ; curl++){  
                for ( int i =0 ; i< nntA[curl].length ;i++){
                    curNp = (Neuron)nntA[curl][i];
                    for(int cp=0;cp<den;cp++){
                        input[cp]=curNp.dendrites[cp+1].in.output();                    
                    }
                    curNp.input(input);
                }                       
            }
        }

        double[] temp = new double[nntA[nntA.length-1].length];
        for (int i=0; i<nntA[nntA.length-1].length;i++){
            temp[i] = nntA[nntA.length-1][i].output();
        }
        return temp;
    }
    /**
     * backward propagate compution.
     * @param aOfw value of momentum.
     * @param fout ouput stream for debug.
     * @param sourceData , input signal of the network.
     * @param outputData , output signal of the network.
     * @param step , length of learning step.
     */
    public  void backwardCalculate(double[] sourceData, double[] outputData ,double step,double aOfw ,PrintWriter fout){
        double grad =0 ;
        Neuron curNp =null;
        // for out put layers: D3 , the last layer.
        double[] dif = Evaluate.difference(sourceData,outputData);
        int lastlay = nntA.length-1;
        for (int i =0;i< nntA[lastlay].length;i++){
            grad =0 ;
            curNp = nntA[lastlay][i];
//            fout.println("bc,"+curNp);      // for testing only
//            System.out.println("bc,"+curNp);
            grad=dif[i] * curNp.output() * (1-curNp.output());
//            grad =dif[i] * (Math.pow(a,2) -Math.pow(curNp.output(),2) )*b/(2*a);
            curNp.grad = grad;
            curNp.setWeight(step * 1.25,aOfw);
//            fout.println("bc,"+curNp);      // for testing only
//            System.out.println("bc,"+curNp);
        }
        
        // for layers : D2 , D1 , LO , L3 , L2 ,L1, 
        for ( int curl =lastlay-1 ; curl >-1;curl--){
            for (int i =0 ;i<nntA[curl].length;i++) {
                //calculate product of sub-neuron's linked weight and grad
                grad=0;
                curNp = nntA[curl][i];
//                fout.println("bc,"+curNp);      // for testing only
//                System.out.println("bc,"+curNp);
                for (int k = 0 ; k< curNp.subDen.length;k++){
//                    grad += curNp.sub.get(k).weight * curNp.sub.get(k).out.grad ;
                    grad += curNp.subDen[k].weight * curNp.subDen[k].out.grad ;
                } 
                // get grad
                grad = grad* curNp.output() * (1-curNp.output());
//                grad =grad * (Math.pow(a,2) -Math.pow(curNp.output(),2) )*b/(2*a);
                curNp.grad = grad;
                curNp.setWeight(step,aOfw);            
//                fout.println("bc,"+curNp);      // for testing only
//                System.out.println("bc,"+curNp);
            }
        }
        
    }
    /**
     * backward propagate compution.
     * @param sourceData , input signal of the network.
     * @param outputData , output signal of the network.
     * @param step , length of learning step.
     * @param aOfw value of momentum.
     */
    public  void backwardCalculate(double[] sourceData, double[] outputData ,double step,double aOfw ){
        double grad =0 ;
        Neuron curNp =null;
        // for out put layers, the output layer.
        double[] dif = Evaluate.difference(sourceData,outputData);
        int lastlay = nntA.length-1;
        for (int i =0;i< nntA[lastlay].length;i++){
            grad =0 ;
            curNp = nntA[lastlay][i];
            grad = dif[i]* curNp.output() * (1-curNp.output());
//            grad =dif[i] * (Math.pow(a,2) - Math.pow(curNp.output(),2) )*b/(2*a);
            curNp.grad = grad;
            curNp.setWeight((step * 1.1) ,aOfw);
        }
        // for layers : D2 , D1 , LO , L3 , L2 ,L1,hideds 
        for ( int curl =lastlay-1 ; curl >-1;curl--){
            for (int i =0 ;i<nntA[curl].length;i++) {
                //calculate product of sub-neuron's linked weight and grad
                grad=0;
                curNp = nntA[curl][i];
                for (int k = 0 ; k< curNp.subDen.length;k++){
//                    grad += curNp.sub.get(k).weight * curNp.sub.get(k).out.grad ;
                    grad += curNp.subDen[k].weight * curNp.subDen[k].out.grad ;
                } 
                // get grad
                grad = grad* curNp.output() * (1-curNp.output());
//                grad =grad * (Math.pow(a,2) -Math.pow(curNp.output(),2) )*b/(2*a);
                curNp.grad = grad;
                curNp.setWeight(step ,aOfw);   
            }
        }
        
    }
    ////////////////////////////////////////////////////////////////////////////////
    /**
     * froward calculate .
     * @param sourceData input data for neural network.
     * @param fout  used to output the process of calculation for debuging.
     * @return an array of elments, which is data decompressed.
     */
    public double[] forwardCalculate(double[] sourceData, PrintWriter fout){
        network.inputAdapte(sourceData);
        Neuron curNp= null;
        double[] input = new double[den];;

        for ( int curl = 0; curl<nntA.length ; curl++){  
            for ( int i =0 ; i< nntA[curl].length ;i++){
                
                curNp = (Neuron)nntA[curl][i];
//                System.out.println("fc,"+curNp);        // for testing only
//                fout.println("fc," +curNp);        // for testing only
                // prepare input vectors.
//                input = new double[den];
                for(int cp=0;cp<den;cp++){
                    input[cp]=curNp.dendrites[cp+1].in.output();                    
                }
                curNp.input(input);
//                fout.println("fc," +curNp);        // for testing only
//                System.out.println("fc,"+curNp);        // for testing only
            }                       
        }
        int outsize = nntA[nntA.length-1].length;
        double[] temp = new double[outsize];
        Neuron[] outLayer = nntA[nntA.length-1];
        for (int i=0; i<outsize;i++){
            temp[i] = outLayer[i].output();
        }
        return temp;
    }
    /**
     * forward calculation.
     * @param sourceData input data.
     * @return output of network.
     */
    public double[] forwardCalculate(double[] sourceData){
        network.inputAdapte(sourceData);
        Neuron curNp= null;
        double[] input = new double[den];
        for ( int curl = 0; curl<nntA.length ; curl++){  
            for ( int i =0 ; i< nntA[curl].length ;i++){                
                curNp = nntA[curl][i];
                for(int cp=0;cp<den;cp++){
                    input[cp]=curNp.dendrites[cp+1].in.output();                    
                }
                curNp.input(input);
            }                       
        }

        double[] temp = new double[nntA[nntA.length-1].length];
        for (int i=0; i<nntA[nntA.length-1].length;i++){
            temp[i] = nntA[nntA.length-1][i].output();
        }
        return temp;
    }
    
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产亚洲在线| 日韩一级免费观看| 日韩av一区二| 中文字幕不卡在线观看| 欧美精品久久99| 成人激情文学综合网| 美腿丝袜亚洲一区| 一区二区三区不卡在线观看| 久久先锋影音av鲁色资源| 精品视频999| 成人av资源站| 国产盗摄一区二区| 日本不卡高清视频| 亚洲国产欧美在线| ...xxx性欧美| 国产三级欧美三级日产三级99| 欧美日韩成人在线一区| 波波电影院一区二区三区| 国产激情偷乱视频一区二区三区| 丝袜亚洲另类欧美| 高清国产一区二区三区| 肉色丝袜一区二区| 亚洲精品成人在线| 国产精品私房写真福利视频| 日韩精品一区二区三区中文不卡 | 成人亚洲一区二区一| 国产在线精品一区二区不卡了| 亚洲va中文字幕| 亚洲男帅同性gay1069| 中文字幕乱码久久午夜不卡 | 国产清纯美女被跳蛋高潮一区二区久久w| 欧美卡1卡2卡| 欧美日韩亚洲国产综合| 欧美色倩网站大全免费| 欧美综合一区二区| 91福利在线导航| 欧美制服丝袜第一页| 日本精品裸体写真集在线观看| 色婷婷久久久久swag精品| 色婷婷久久99综合精品jk白丝| 99精品视频在线观看免费| 不卡av在线免费观看| www.亚洲在线| 色综合天天做天天爱| 91欧美一区二区| 色系网站成人免费| 欧美在线高清视频| 欧美色手机在线观看| 7777精品伊人久久久大香线蕉超级流畅| 欧美性生活大片视频| 欧美日韩dvd在线观看| 91精品啪在线观看国产60岁| 日韩一级黄色片| 久久蜜臀中文字幕| 国产精品成人一区二区艾草 | 91啪在线观看| 欧美在线看片a免费观看| 欧美日韩国产在线播放网站| 欧美剧在线免费观看网站| 欧美一区中文字幕| 精品美女在线播放| 中文字幕的久久| 亚洲一区日韩精品中文字幕| 免费人成精品欧美精品| 国产一区二区三区视频在线播放| 国产成都精品91一区二区三| 91蝌蚪porny成人天涯| 精品视频一区二区不卡| 精品电影一区二区三区| 国产精品欧美精品| 亚洲无线码一区二区三区| 久久精品国产亚洲a| 风流少妇一区二区| 在线观看视频一区二区欧美日韩| 欧美一级在线免费| 国产视频一区在线观看| 亚洲国产毛片aaaaa无费看| 蜜桃av噜噜一区二区三区小说| 成人午夜av在线| 欧美日韩国产精品自在自线| 亚洲精品一区在线观看| 亚洲人成人一区二区在线观看| 亚洲成年人网站在线观看| 国产黄色精品网站| 在线观看免费一区| 久久久777精品电影网影网| 一区二区在线观看免费| 免费在线观看精品| 91视频在线观看免费| 欧美一区欧美二区| 国产精品久久久久久福利一牛影视 | 欧美另类变人与禽xxxxx| 久久久精品国产免大香伊| 一区二区欧美国产| 国产精品香蕉一区二区三区| 色婷婷激情综合| 久久精品人人做人人综合| 午夜精品久久一牛影视| 成人免费视频网站在线观看| 67194成人在线观看| 亚洲欧洲成人精品av97| 精品午夜久久福利影院| 欧美在线观看18| 欧美国产日本视频| 久久精品国产色蜜蜜麻豆| 欧美视频一二三区| 国产精品久久久久一区二区三区| 蜜臀av性久久久久蜜臀aⅴ| 日本电影亚洲天堂一区| 国产精品乱码一区二三区小蝌蚪| 久久精品国产成人一区二区三区| 色综合久久久久久久| 国产欧美一区二区精品久导航| 日韩精品一二三区| 一本大道久久a久久精品综合| 久久精品视频一区二区三区| 蓝色福利精品导航| 制服.丝袜.亚洲.中文.综合| 一区二区成人在线视频| 不卡一区二区在线| 久久精品夜色噜噜亚洲aⅴ| 老司机精品视频线观看86| 51精品久久久久久久蜜臀| 亚洲午夜免费视频| 色狠狠综合天天综合综合| 国产精品欧美久久久久无广告| 国产精品一区二区久久不卡 | 久久精品无码一区二区三区| 青青青伊人色综合久久| 欧美精品成人一区二区三区四区| 亚洲精品菠萝久久久久久久| 97se亚洲国产综合在线| 中文字幕欧美一| 成人av网站在线观看免费| 中文字幕第一区第二区| 成人免费电影视频| 中文字幕亚洲一区二区av在线| 成人午夜私人影院| 国产精品私人自拍| 97aⅴ精品视频一二三区| 亚洲精品乱码久久久久久| 97精品国产露脸对白| 1区2区3区欧美| 91成人在线观看喷潮| 一区二区三区欧美亚洲| 欧美伊人精品成人久久综合97 | 久久你懂得1024| 国产成人综合网站| 国产精品美女视频| 一本一道波多野结衣一区二区| 亚洲黄色片在线观看| 欧洲精品中文字幕| 视频一区二区三区在线| 91精品国产福利在线观看 | 欧美羞羞免费网站| 亚洲一区二区在线免费观看视频 | 日韩一级二级三级精品视频| 久久精品国产99| 中文一区在线播放| 91麻豆精品秘密| 午夜久久久久久电影| 欧美一区二区三区在线观看| 激情六月婷婷久久| 国产精品麻豆久久久| 色婷婷一区二区| 蜜臀av一区二区在线观看| 国产欧美一区二区三区在线看蜜臀| 成人看片黄a免费看在线| 亚洲高清在线视频| 久久嫩草精品久久久久| 91麻豆免费在线观看| 蜜臀av性久久久久蜜臀av麻豆| 日本一区二区免费在线观看视频| 91亚洲资源网| 蜜桃av噜噜一区| 国产精品传媒入口麻豆| 在线电影欧美成精品| 国产一区二区三区综合| 一区二区三区鲁丝不卡| 精品91自产拍在线观看一区| 成人av影视在线观看| 日产国产欧美视频一区精品| 国产日本欧美一区二区| 欧美日韩国产美女| 成人av资源下载| 麻豆久久久久久| 亚洲少妇30p| 精品福利一二区| 在线观看欧美黄色| 成人性生交大合| 天天综合色天天综合色h| 国产精品国产三级国产有无不卡| 欧美日本一道本| 91丨porny丨国产入口| 国产自产视频一区二区三区| 亚洲小少妇裸体bbw| 国产午夜亚洲精品理论片色戒 | 日韩欧美国产一区二区在线播放 | 国产精品灌醉下药二区| 欧美成人欧美edvon|