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

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

?? multilayerperceptron.java

?? MacroWeka擴展了著名數據挖掘工具weka
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
/*
 *    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.
 */

/*
 *    MultilayerPerceptron.java
 *    Copyright (C) 2000 Malcolm Ware
 */

package weka.classifiers.functions;

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import weka.classifiers.functions.neural.*;
import weka.classifiers.*;
import weka.core.*;
import weka.filters.unsupervised.attribute.NominalToBinary;
import weka.filters.Filter;

/** 
 * A Classifier that uses backpropagation to classify instances.
 * This network can be built by hand, created by an algorithm or both.
 * The network can also be monitored and modified during training time.
 * The nodes in this network are all sigmoid (except for when the class
 * is numeric in which case the the output nodes become unthresholded linear
 * units).
 *
 * @author Malcolm Ware (mfw4@cs.waikato.ac.nz)
 * @version $Revision: 1.1 $
 */
public class MultilayerPerceptron extends Classifier 
  implements OptionHandler, WeightedInstancesHandler {
  
  /**
   * Main method for testing this class.
   *
   * @param argv should contain command line options (see setOptions)
   */
  public static void main(String [] argv) {
    
    try {
      System.out.println(Evaluation.evaluateModel(new MultilayerPerceptron(), argv));
    } catch (Exception e) {
      System.err.println(e.getMessage());
      e.printStackTrace();
    }
    System.exit(0);
  }
  

  /** 
   * This inner class is used to connect the nodes in the network up to
   * the data that they are classifying, Note that objects of this class are
   * only suitable to go on the attribute side or class side of the network
   * and not both.
   */
  protected class NeuralEnd extends NeuralConnection {
    
    
    /** 
     * the value that represents the instance value this node represents. 
     * For an input it is the attribute number, for an output, if nominal
     * it is the class value. 
     */
    private int m_link;
    
    /** True if node is an input, False if it's an output. */
    private boolean m_input;


    public NeuralEnd(String id) {
      super(id);

      m_link = 0;
      m_input = true;
      
    }
  
    /**
     * Call this function to determine if the point at x,y is on the unit.
     * @param g The graphics context for font size info.
     * @param x The x coord.
     * @param y The y coord.
     * @param w The width of the display.
     * @param h The height of the display.
     * @return True if the point is on the unit, false otherwise.
     */
    public boolean onUnit(Graphics g, int x, int y, int w, int h) {
      
      FontMetrics fm = g.getFontMetrics();
      int l = (int)(m_x * w) - fm.stringWidth(m_id) / 2;
      int t = (int)(m_y * h) - fm.getHeight() / 2;
      if (x < l || x > l + fm.stringWidth(m_id) + 4 
	  || y < t || y > t + fm.getHeight() + fm.getDescent() + 4) {
	return false;
      }
      return true;
      
    }
   

    /**
     * This will draw the node id to the graphics context.
     * @param g The graphics context.
     * @param w The width of the drawing area.
     * @param h The height of the drawing area.
     */
    public void drawNode(Graphics g, int w, int h) {
      
      if ((m_type & PURE_INPUT) == PURE_INPUT) {
	g.setColor(Color.green);
      }
      else {
	g.setColor(Color.orange);
      }
      
      FontMetrics fm = g.getFontMetrics();
      int l = (int)(m_x * w) - fm.stringWidth(m_id) / 2;
      int t = (int)(m_y * h) - fm.getHeight() / 2;
      g.fill3DRect(l, t, fm.stringWidth(m_id) + 4
		   , fm.getHeight() + fm.getDescent() + 4
		   , true);
      g.setColor(Color.black);
      
      g.drawString(m_id, l + 2, t + fm.getHeight() + 2);

    }


    /**
     * Call this function to draw the node highlighted.
     * @param g The graphics context.
     * @param w The width of the drawing area.
     * @param h The height of the drawing area.
     */
    public void drawHighlight(Graphics g, int w, int h) {
      
      g.setColor(Color.black);
      FontMetrics fm = g.getFontMetrics();
      int l = (int)(m_x * w) - fm.stringWidth(m_id) / 2;
      int t = (int)(m_y * h) - fm.getHeight() / 2;
      g.fillRect(l - 2, t - 2, fm.stringWidth(m_id) + 8
		 , fm.getHeight() + fm.getDescent() + 8); 
      drawNode(g, w, h);
    }
    
    /**
     * Call this to get the output value of this unit. 
     * @param calculate True if the value should be calculated if it hasn't 
     * been already.
     * @return The output value, or NaN, if the value has not been calculated.
     */
    public double outputValue(boolean calculate) {
     
      if (Double.isNaN(m_unitValue) && calculate) {
	if (m_input) {
	  if (m_currentInstance.isMissing(m_link)) {
	    m_unitValue = 0;
	  }
	  else {
	    
	    m_unitValue = m_currentInstance.value(m_link);
	  }
	}
	else {
	  //node is an output.
	  m_unitValue = 0;
	  for (int noa = 0; noa < m_numInputs; noa++) {
	    m_unitValue += m_inputList[noa].outputValue(true);
	   
	  }
	  if (m_numeric && m_normalizeClass) {
	    //then scale the value;
	    //this scales linearly from between -1 and 1
	    m_unitValue = m_unitValue * 
	      m_attributeRanges[m_instances.classIndex()] + 
	      m_attributeBases[m_instances.classIndex()];
	  }
	}
      }
      return m_unitValue;
      
      
    }
    
    /**
     * Call this to get the error value of this unit, which in this case is
     * the difference between the predicted class, and the actual class.
     * @param calculate True if the value should be calculated if it hasn't 
     * been already.
     * @return The error value, or NaN, if the value has not been calculated.
     */
    public double errorValue(boolean calculate) {
      
      if (!Double.isNaN(m_unitValue) && Double.isNaN(m_unitError) 
	  && calculate) {
	
	if (m_input) {
	  m_unitError = 0;
	  for (int noa = 0; noa < m_numOutputs; noa++) {
	    m_unitError += m_outputList[noa].errorValue(true);
	  }
	}
	else {
	  if (m_currentInstance.classIsMissing()) {
	    m_unitError = .1;  
	  }
	  else if (m_instances.classAttribute().isNominal()) {
	    if (m_currentInstance.classValue() == m_link) {
	      m_unitError = 1 - m_unitValue;
	    }
	    else {
	      m_unitError = 0 - m_unitValue;
	    }
	  }
	  else if (m_numeric) {
	    
	    if (m_normalizeClass) {
	      if (m_attributeRanges[m_instances.classIndex()] == 0) {
		m_unitError = 0;
	      }
	      else {
		m_unitError = (m_currentInstance.classValue() - m_unitValue ) /
		  m_attributeRanges[m_instances.classIndex()];
		//m_numericRange;
		
	      }
	    }
	    else {
	      m_unitError = m_currentInstance.classValue() - m_unitValue;
	    }
	  }
	}
      }
      return m_unitError;
    }
    
    
    /**
     * Call this to reset the value and error for this unit, ready for the next
     * run. This will also call the reset function of all units that are 
     * connected as inputs to this one.
     * This is also the time that the update for the listeners will be 
     * performed.
     */
    public void reset() {
      
      if (!Double.isNaN(m_unitValue) || !Double.isNaN(m_unitError)) {
	m_unitValue = Double.NaN;
	m_unitError = Double.NaN;
	m_weightsUpdated = false;
	for (int noa = 0; noa < m_numInputs; noa++) {
	  m_inputList[noa].reset();
	}
      }
    }
    
    
    /** 
     * Call this function to set What this end unit represents.
     * @param input True if this unit is used for entering an attribute,
     * False if it's used for determining a class value.
     * @param val The attribute number or class type that this unit represents.
     * (for nominal attributes).
     */
    public void setLink(boolean input, int val) throws Exception {
      m_input = input;
      
      if (input) {
	m_type = PURE_INPUT;
      }
      else {
	m_type = PURE_OUTPUT;
      }
      if (val < 0 || (input && val > m_instances.numAttributes()) 
	  || (!input && m_instances.classAttribute().isNominal() 
	      && val > m_instances.classAttribute().numValues())) {
	m_link = 0;
      }
      else {
	m_link = val;
      }
    }
    
    /**
     * @return link for this node.
     */
    public int getLink() {
      return m_link;
    }
    

  }
  

 
  /** Inner class used to draw the nodes onto.(uses the node lists!!) 
   * This will also handle the user input. */
  private class NodePanel extends JPanel {
    


    /**
     * The constructor.
     */
    public NodePanel() {
      

      addMouseListener(new MouseAdapter() {
	  
	  public void mousePressed(MouseEvent e) {
	    
	    if (!m_stopped) {
	      return;
	    }
	    if ((e.getModifiers() & e.BUTTON1_MASK) == e.BUTTON1_MASK && 
		!e.isAltDown()) {
	      Graphics g = NodePanel.this.getGraphics();
	      int x = e.getX();
	      int y = e.getY();
	      int w = NodePanel.this.getWidth();
	      int h = NodePanel.this.getHeight();
	      int u = 0;
	      FastVector tmp = new FastVector(4);
	      for (int noa = 0; noa < m_numAttributes; noa++) {
		if (m_inputs[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_inputs[noa]);
		  selection(tmp, 
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , true);
		  return;
		}
	      }
	      for (int noa = 0; noa < m_numClasses; noa++) {
		if (m_outputs[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_outputs[noa]);
		  selection(tmp,
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , true);
		  return;
		}
	      }
	      for (int noa = 0; noa < m_neuralNodes.length; noa++) {
		if (m_neuralNodes[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_neuralNodes[noa]);
		  selection(tmp,
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , true);
		  return;
		}

	      }
	      NeuralNode temp = new NeuralNode(String.valueOf(m_nextId), 
					       m_random, m_sigmoidUnit);
	      m_nextId++;
	      temp.setX((double)e.getX() / w);
	      temp.setY((double)e.getY() / h);
	      tmp.addElement(temp);
	      addNode(temp);
	      selection(tmp, (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			, true);
	    }
	    else {
	      //then right click
	      Graphics g = NodePanel.this.getGraphics();
	      int x = e.getX();
	      int y = e.getY();
	      int w = NodePanel.this.getWidth();
	      int h = NodePanel.this.getHeight();
	      int u = 0;
	      FastVector tmp = new FastVector(4);
	      for (int noa = 0; noa < m_numAttributes; noa++) {
		if (m_inputs[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_inputs[noa]);
		  selection(tmp, 
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , false);
		  return;
		}
		
		
	      }
	      for (int noa = 0; noa < m_numClasses; noa++) {
		if (m_outputs[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_outputs[noa]);
		  selection(tmp,
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , false);
		  return;
		}
	      }
	      for (int noa = 0; noa < m_neuralNodes.length; noa++) {
		if (m_neuralNodes[noa].onUnit(g, x, y, w, h)) {
		  tmp.addElement(m_neuralNodes[noa]);
		  selection(tmp,
			    (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			    , false);
		  return;
		}
	      }
	      selection(null, (e.getModifiers() & e.CTRL_MASK) == e.CTRL_MASK
			, false);
	    }
	  }
	});
    }
    
    
    /**
     * This function gets called when the user has clicked something
     * It will amend the current selection or connect the current selection
     * to the new selection.
     * Or if nothing was selected and the right button was used it will 
     * delete the node.
     * @param v The units that were selected.
     * @param ctrl True if ctrl was held down.
     * @param left True if it was the left mouse button.
     */
    private void selection(FastVector v, boolean ctrl, boolean left) {
      
      if (v == null) {
	//then unselect all.
	m_selected.removeAllElements();
	repaint();
	return;
      }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性色综合网| 亚洲欧美另类在线| 亚洲一区二区成人在线观看| 亚洲成人免费观看| www.欧美亚洲| 久久日韩精品一区二区五区| 亚洲午夜av在线| av不卡免费电影| 亚洲精品一区二区三区蜜桃下载 | 欧美成人欧美edvon| 一区二区三国产精华液| jizzjizzjizz欧美| 国产精品色哟哟| 国产黄色精品网站| 亚洲精品一区二区三区香蕉| 免费人成网站在线观看欧美高清| 色婷婷综合激情| 亚洲图片另类小说| 99久久综合狠狠综合久久| 精品国产免费一区二区三区四区| 三级成人在线视频| 91麻豆精品91久久久久久清纯 | 日韩电影在线看| 欧美性感一区二区三区| 亚洲精品精品亚洲| 欧美伊人久久久久久久久影院 | 国产精品久久久久久久岛一牛影视 | 亚洲国产成人一区二区三区| 国产又黄又大久久| 国产女人水真多18毛片18精品视频| 狠狠色丁香久久婷婷综| 久久女同精品一区二区| 国产黄色91视频| 国产精品视频一二| 色综合天天综合网天天看片| 亚洲精品你懂的| 欧美日韩一区中文字幕| 日本亚洲电影天堂| 精品91自产拍在线观看一区| 国产麻豆视频一区| 日本一区免费视频| 一本到一区二区三区| 亚洲综合在线观看视频| 制服丝袜成人动漫| 激情丁香综合五月| 国产精品伦一区二区三级视频| 不卡一卡二卡三乱码免费网站| 亚洲人123区| 欧美午夜片在线看| 九九**精品视频免费播放| 亚洲精品在线三区| 91同城在线观看| 日韩精品色哟哟| 中文字幕欧美激情| 成人在线一区二区三区| 精品国产一区二区精华| 大胆亚洲人体视频| 一区二区三区日韩精品| 日韩女优av电影| 99re这里只有精品视频首页| 亚洲午夜精品在线| 久久久久国产精品人| 色久综合一二码| 麻豆一区二区三| 中文字幕乱码日本亚洲一区二区| 色呦呦国产精品| 国内成+人亚洲+欧美+综合在线| 国产精品理论片| 欧美一级久久久久久久大片| 国产成人午夜视频| 亚洲国产成人高清精品| 国产欧美一区二区三区网站| 欧美视频一二三区| 丁香激情综合五月| 蜜桃久久久久久| 亚洲精品伦理在线| 久久色视频免费观看| 欧美性猛片aaaaaaa做受| 国产成人欧美日韩在线电影| 亚洲一二三级电影| 中文字幕av一区二区三区| 欧美卡1卡2卡| 91一区在线观看| 国产尤物一区二区在线| 天天综合网天天综合色| 亚洲欧美视频在线观看| 2023国产精华国产精品| 欧美一区二区国产| 91黄色免费看| 97久久超碰国产精品电影| 国产精品一区在线观看你懂的| 亚洲成av人片| 亚洲精品ww久久久久久p站| 欧美激情一区二区三区四区| 日韩精品一区二区三区视频 | 国产在线精品一区二区夜色 | 精品免费一区二区三区| 精品视频123区在线观看| 99v久久综合狠狠综合久久| 成人中文字幕在线| 成人性生交大片免费| 国产精华液一区二区三区| 精品中文字幕一区二区| 日韩av午夜在线观看| 午夜久久久久久| 午夜精品一区二区三区电影天堂 | 国产一级精品在线| 国产中文一区二区三区| 久88久久88久久久| 久久99久久99小草精品免视看| 日本不卡在线视频| 日韩成人一级大片| 免费成人在线视频观看| 欧美aa在线视频| 久久精品国产亚洲5555| 久久国产精品色婷婷| 男女激情视频一区| 精品中文字幕一区二区| 国产一区二区三区在线看麻豆| 久久国产精品72免费观看| 理论电影国产精品| 国产麻豆成人精品| 成人免费av网站| 一本色道a无线码一区v| 欧美亚洲综合色| 欧美一区二区三区性视频| 日韩欧美高清dvd碟片| 久久网站热最新地址| 亚洲国产精品av| 一区二区三区中文在线| 性感美女久久精品| 国产一区二区视频在线播放| 风间由美一区二区三区在线观看 | 床上的激情91.| 97se亚洲国产综合在线| 欧美少妇一区二区| 精品久久久久久综合日本欧美 | 国产一区二区三区在线观看精品 | 国产亚洲一区二区三区四区| 国产精品欧美精品| 亚欧色一区w666天堂| 国产主播一区二区| 日本韩国欧美一区| 91精品国产一区二区三区蜜臀| 亚洲精品一区二区三区福利| 国产精品国产三级国产专播品爱网| 亚洲综合成人在线| 日韩制服丝袜先锋影音| 国产激情视频一区二区在线观看 | 蜜桃免费网站一区二区三区| 风间由美中文字幕在线看视频国产欧美| av一区二区久久| 欧美日韩国产精选| 国产欧美一区二区在线| 日日嗨av一区二区三区四区| 成人蜜臀av电影| 欧美一卡二卡在线观看| 一区二区中文视频| 精品无码三级在线观看视频 | 久久久久久久一区| 亚洲午夜久久久久中文字幕久| 国产精品一品视频| 6080亚洲精品一区二区| 中文字幕日韩av资源站| 蜜臀精品一区二区三区在线观看 | 欧美一级生活片| 亚洲欧美日韩国产手机在线| 美国三级日本三级久久99| 色国产综合视频| 久久精品视频一区二区三区| 亚洲制服欧美中文字幕中文字幕| 国产成人亚洲精品狼色在线| 91精品国产91久久久久久一区二区 | 成年人网站91| 欧美精品一区二区在线播放| 亚洲成av人片在线| 在线观看亚洲精品视频| 国产精品私人影院| 国产精品一二二区| 欧美大胆一级视频| 天天综合色天天| 欧美艳星brazzers| 一区二区三区在线不卡| 不卡的av电影| 欧美激情在线一区二区| 国产精品综合在线视频| 久久蜜桃一区二区| 久久99国内精品| 日韩精品在线一区| 久久精品国产99久久6| 日韩欧美一区二区视频| 日韩精品免费视频人成| 欧美午夜电影一区| 一区二区三区美女| 欧美在线看片a免费观看| 亚洲在线视频网站| 欧美日韩国产首页| 日本欧洲一区二区| 欧美一区二区三级| 久久成人免费网站|