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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? network.java

?? java neural networkin
?? JAVA
字號(hào):
/**
 * Network
 * Copyright 2005 by Jeff Heaton(jeff@jeffheaton.com)
 *
 * Example program from Chapter 10
 * Programming Neural Networks in Java
 * http://www.heatonresearch.com/articles/series/1/
 *
 * This software is copyrighted. You may use it in programs
 * of your own, without restriction, but you may not
 * publish the source code without the author's permission.
 * For more information on distributing this code, please
 * visit:
 *    http://www.heatonresearch.com/hr_legal.php
 *
 * @author Jeff Heaton
 * @version 1.1
 */

public class Network {

  /**
   * The global error for the training.
   */
  protected double globalError;


  /**
   * The number of input neurons.
   */
  protected int inputCount;

  /**
   * The number of hidden neurons.
   */
  protected int hiddenCount;

  /**
   * The number of output neurons
   */
  protected int outputCount;

  /**
   * The total number of neurons in the network.
   */
  protected int neuronCount;

  /**
   * The number of weights in the network.
   */
  protected int weightCount;

  /**
   * The learning rate.
   */
  protected double learnRate;

  /**
   * The outputs from the various levels.
   */
  protected double fire[];

  /**
   * The weight matrix this, along with the thresholds can be
   * thought of as the "memory" of the neural network.
   */
  protected double matrix[];

  /**
   * The errors from the last calculation.
   */
  protected double error[];

  /**
   * Accumulates matrix delta's for training.
   */
  protected double accMatrixDelta[];

  /**
   * The thresholds, this value, along with the weight matrix
   * can be thought of as the memory of the neural network.
   */
  protected double thresholds[];

  /**
   * The changes that should be applied to the weight
   * matrix.
   */
  protected double matrixDelta[];

  /**
   * The accumulation of the threshold deltas.
   */
  protected double accThresholdDelta[];

  /**
   * The threshold deltas.
   */
  protected double thresholdDelta[];

  /**
   * The momentum for training.
   */
  protected double momentum;

  /**
   * The changes in the errors.
   */
  protected double errorDelta[];


  /**
   * Construct the neural network.
   *
   * @param inputCount The number of input neurons.
   * @param hiddenCount The number of hidden neurons
   * @param outputCount The number of output neurons
   * @param learnRate The learning rate to be used when training.
   * @param momentum The momentum to be used when training.
   */
  public Network(int inputCount,
                 int hiddenCount,
                 int outputCount,
                 double learnRate,
                 double momentum) {

    this.learnRate = learnRate;
    this.momentum = momentum;

    this.inputCount = inputCount;
    this.hiddenCount = hiddenCount;
    this.outputCount = outputCount;
    neuronCount = inputCount + hiddenCount + outputCount;
    weightCount = (inputCount * hiddenCount) + (hiddenCount * outputCount);

    fire        = new double[neuronCount];
    matrix      = new double[weightCount];
    matrixDelta = new double[weightCount];
    thresholds  = new double[neuronCount];
    errorDelta  = new double[neuronCount];
    error       = new double[neuronCount];
    accThresholdDelta = new double[neuronCount];
    accMatrixDelta = new double[weightCount];
    thresholdDelta = new double[neuronCount];

    reset();
  }



  /**
   * Returns the root mean square error for a complete training set.
   *
   * @param len The length of a complete training set.
   * @return The current error for the neural network.
   */
  public double getError(int len) {
    double err = Math.sqrt(globalError / (len * outputCount));
    globalError = 0;  // clear the accumulator
    return err;

  }

  /**
   * The threshold method. You may wish to override this class to provide other
   * threshold methods.
   *
   * @param sum The activation from the neuron.
   * @return The activation applied to the threshold method.
   */
  public double threshold(double sum) {
    return 1.0 / (1 + Math.exp(-1.0 * sum));
  }

  /**
   * Compute the output for a given input to the neural network.
   *
   * @param input The input provide to the neural network.
   * @return The results from the output neurons.
   */
  public double []computeOutputs(double input[]) {
    int i, j;
    final int hiddenIndex = inputCount;
    final int outIndex = inputCount + hiddenCount;

    for (i = 0; i < inputCount; i++) {
      fire[i] = input[i];
    }

    // first layer
    int inx = 0;

    for (i = hiddenIndex; i < outIndex; i++) {
      double sum = thresholds[i];

      for (j = 0; j < inputCount; j++) {
        sum += fire[j] * matrix[inx++];
      }
      fire[i] = threshold(sum);
    }

    // hidden layer

    double result[] = new double[outputCount];

    for (i = outIndex; i < neuronCount; i++) {
      double sum = thresholds[i];

      for (j = hiddenIndex; j < outIndex; j++) {
        sum += fire[j] * matrix[inx++];
      }
      fire[i] = threshold(sum);
      result[i-outIndex] = fire[i];
    }

    return result;
  }


  /**
   * Calculate the error for the recognition just done.
   *
   * @param ideal What the output neurons should have yielded.
   */
  public void calcError(double ideal[]) {
    int i, j;
    final int hiddenIndex = inputCount;
    final int outputIndex = inputCount + hiddenCount;

    // clear hidden layer errors
    for (i = inputCount; i < neuronCount; i++) {
      error[i] = 0;
    }

    // layer errors and deltas for output layer
    for (i = outputIndex; i < neuronCount; i++) {
      error[i] = ideal[i - outputIndex] - fire[i];
      globalError += error[i] * error[i];
      errorDelta[i] = error[i] * fire[i] * (1 - fire[i]);
    }

    // hidden layer errors
    int winx = inputCount * hiddenCount;

    for (i = outputIndex; i < neuronCount; i++) {
      for (j = hiddenIndex; j < outputIndex; j++) {
        accMatrixDelta[winx] += errorDelta[i] * fire[j];
        error[j] += matrix[winx] * errorDelta[i];
        winx++;
      }
      accThresholdDelta[i] += errorDelta[i];
    }

    // hidden layer deltas
    for (i = hiddenIndex; i < outputIndex; i++) {
      errorDelta[i] = error[i] * fire[i] * (1 - fire[i]);
    }

    // input layer errors
    winx = 0;  // offset into weight array
    for (i = hiddenIndex; i < outputIndex; i++) {
      for (j = 0; j < hiddenIndex; j++) {
        accMatrixDelta[winx] += errorDelta[i] * fire[j];
        error[j] += matrix[winx] * errorDelta[i];
        winx++;
      }
      accThresholdDelta[i] += errorDelta[i];
    }
  }

  /**
   * Modify the weight matrix and thresholds based on the last call to
   * calcError.
   */
  public void learn() {
    int i;

    // process the matrix
    for (i = 0; i < matrix.length; i++) {
      matrixDelta[i] = (learnRate * accMatrixDelta[i]) + (momentum * matrixDelta[i]);
      matrix[i] += matrixDelta[i];
      accMatrixDelta[i] = 0;
    }

    // process the thresholds
    for (i = inputCount; i < neuronCount; i++) {
      thresholdDelta[i] = learnRate * accThresholdDelta[i] + (momentum * thresholdDelta[i]);
      thresholds[i] += thresholdDelta[i];
      accThresholdDelta[i] = 0;
    }
  }

  /**
   * Reset the weight matrix and the thresholds.
   */
  public void reset() {
    int i;

    for (i = 0; i < neuronCount; i++) {
      thresholds[i] = 0.5 - (Math.random());
      thresholdDelta[i] = 0;
      accThresholdDelta[i] = 0;
    }
    for (i = 0; i < matrix.length; i++) {
      matrix[i] = 0.5 - (Math.random());
      matrixDelta[i] = 0;
      accMatrixDelta[i] = 0;
    }
  }

  /**
   * Convert to an array. This is used with some training algorithms
   * that require that the "memory" of the neuron(the weight and threshold
   * values) be expressed as a linear array.
   *
   * @return The memory of the neuron.
   */
  public double []toArray()
  {
    double result[] = new double[matrix.length+thresholds.length];
    for (int i=0;i<matrix.length;i++)
      result[i] = matrix[i];
    for (int i=0;i<thresholds.length;i++)
      result[matrix.length+i] = thresholds[i];
    return result;
  }

  /**
   * Use an array to populate the memory of the neural network.
   *
   * @param array An array of doubles.
   */
  public void fromArray(double array[])
  {
    for (int i=0;i<matrix.length;i++)
      matrix[i] = array[i];
    for (int i=0;i<thresholds.length;i++)
      thresholds[i] = array[matrix.length+i];
  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩三级中文字幕| 亚洲精品一区二区三区在线观看| 91精彩视频在线| 日韩一区二区三区电影| 国产亚洲一区二区三区四区| 亚洲日本免费电影| 国产美女视频一区| 欧美日韩aaaaa| 国产欧美久久久精品影院| 日韩中文字幕麻豆| 成人黄色一级视频| 91精品国产综合久久福利软件| 国产精品系列在线| 另类人妖一区二区av| 色综合久久88色综合天天| 色婷婷久久久亚洲一区二区三区| 成人av网站免费观看| 欧美一级在线观看| 亚洲亚洲精品在线观看| 久久99精品国产麻豆婷婷洗澡| 91免费看片在线观看| 2024国产精品| 久久久久久9999| 久久97超碰国产精品超碰| 欧美日韩精品福利| 亚洲国产视频a| 成年人午夜久久久| 亚洲国产精品成人综合| 国产成人一级电影| 欧美videofree性高清杂交| 精品久久久久久最新网址| 蜜臀精品久久久久久蜜臀 | 在线观看精品一区| 亚洲日本中文字幕区| 国产中文字幕一区| 日韩欧美国产一二三区| 久久国产精品99久久久久久老狼 | 蜜桃一区二区三区在线| 色婷婷综合久久久中文字幕| 久久久久国产免费免费 | 26uuu另类欧美亚洲曰本| 日韩影院精彩在线| 国产一区在线观看视频| 久久久99精品免费观看不卡| 久久激情五月激情| 精品电影一区二区| 国产乱码精品一区二区三区五月婷| 欧美乱熟臀69xxxxxx| 蜜臀久久99精品久久久画质超高清| 欧美日韩免费一区二区三区 | 久久久久久久久久电影| 国产精品一二三四五| 欧美一区二区性放荡片| 午夜在线电影亚洲一区| 欧美久久久久久蜜桃| 精彩视频一区二区三区| 久久欧美一区二区| 成人在线综合网| 亚洲午夜激情av| 在线成人午夜影院| 青娱乐精品视频在线| 26uuu欧美日本| aaa欧美大片| 日韩高清一区二区| 久久免费精品国产久精品久久久久| 国产精品久久久久久久久久免费看 | 高清不卡一二三区| 亚洲国产成人私人影院tom| 国产高清久久久| 一区二区三区在线观看欧美 | 一区免费观看视频| 欧美四级电影网| 久久国产精品99久久人人澡| 91精品国产综合久久精品| 国产露脸91国语对白| 中文字幕制服丝袜一区二区三区 | 91女神在线视频| 另类的小说在线视频另类成人小视频在线 | 麻豆精品视频在线| 久久久久久亚洲综合影院红桃| 97久久精品人人做人人爽50路| 亚洲在线中文字幕| 欧美日韩午夜影院| 一本大道久久a久久综合婷婷| 日韩精品一二三四| 国产精品久久久久久久蜜臀 | 日韩欧美一区在线| 国产91精品一区二区麻豆网站 | 欧美亚洲动漫另类| 国产在线视频一区二区三区| 亚洲成人在线免费| 欧美经典一区二区三区| 91免费国产视频网站| 激情偷乱视频一区二区三区| 亚洲欧洲日产国码二区| 久久综合色播五月| 91麻豆精品国产91久久久久| 成人性生交大片免费看中文| 久久国产尿小便嘘嘘| 亚洲最大成人网4388xx| 日韩欧美一区二区久久婷婷| 欧美日韩第一区日日骚| 99国内精品久久| 成人激情图片网| 精品系列免费在线观看| 青青草国产成人99久久| 亚洲福利视频导航| 亚洲欧美偷拍三级| 亚洲欧美另类小说| 国产清纯美女被跳蛋高潮一区二区久久w| 欧美久久久久中文字幕| 欧美日精品一区视频| 不卡视频在线观看| 国产成人午夜片在线观看高清观看| 久久精品国产一区二区三| 亚洲成av人**亚洲成av**| 综合久久久久久久| 亚洲欧美一区二区三区久本道91 | 波多野结衣的一区二区三区| 韩国v欧美v亚洲v日本v| 美女诱惑一区二区| 麻豆91在线观看| 精品一区二区三区的国产在线播放| 亚洲国产一区二区三区| 日韩国产欧美三级| 青娱乐精品在线视频| 亚洲日本一区二区| 午夜欧美2019年伦理 | 欧美成人猛片aaaaaaa| 精品少妇一区二区三区| 日韩一区二区三区电影在线观看 | 色偷偷成人一区二区三区91| 一本色道久久综合亚洲aⅴ蜜桃| 一本高清dvd不卡在线观看| av电影天堂一区二区在线观看| 国产成人精品三级麻豆| 91在线免费播放| 日本乱人伦一区| 97久久超碰国产精品| 欧美无人高清视频在线观看| 欧美性高清videossexo| 欧美性欧美巨大黑白大战| 7777精品伊人久久久大香线蕉| 欧美精品日韩一本| 国产视频在线观看一区二区三区| 亚洲国产精品二十页| 日韩伦理免费电影| 麻豆91在线看| 波多野结衣亚洲| 色综合久久中文综合久久97| 欧美日韩精品一区二区| 日韩午夜中文字幕| 亚洲欧洲精品成人久久奇米网| 亚洲自拍都市欧美小说| 强制捆绑调教一区二区| 福利视频网站一区二区三区| 欧美视频一区二区三区在线观看 | 欧美私模裸体表演在线观看| 制服丝袜日韩国产| 亚洲欧洲日韩在线| 丝袜诱惑亚洲看片| 成人精品在线视频观看| 欧美日韩在线观看一区二区 | 欧美美女网站色| 国产亚洲制服色| 亚洲电影中文字幕在线观看| 国产大陆a不卡| 欧美在线三级电影| 日本一二三四高清不卡| 青青草国产精品97视觉盛宴| 粉嫩av一区二区三区在线播放| 欧美精品vⅰdeose4hd| 国产女人18水真多18精品一级做| 亚洲欧洲一区二区在线播放| 国产精品亚洲综合一区在线观看| 99re视频精品| 国产视频一区在线观看| 蜜桃视频一区二区| 色综合久久88色综合天天 | 中文字幕欧美激情一区| 免费人成在线不卡| 色综合久久久久| 欧美国产综合色视频| 蜜臀av亚洲一区中文字幕| 日本久久电影网| 自拍偷拍欧美激情| 久久精品国产秦先生| 不卡的电影网站| 国产精品乱人伦一区二区| 久久99久久精品| 日韩一级片在线播放| 一区二区三区在线观看视频| 国内成+人亚洲+欧美+综合在线 | 欧美高清dvd| 一区二区三区中文在线观看| 丁香婷婷深情五月亚洲| 欧美一区二区三区婷婷月色| 肉色丝袜一区二区| 欧美在线小视频| 午夜精品久久久久久不卡8050|