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

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

?? cachedkernel.java

?? Weka
?? JAVA
字號:
/* *    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. */package weka.classifiers.functions.supportVector;import weka.core.Instance;import weka.core.Instances;import weka.core.Option;import weka.core.Utils;import java.util.Enumeration;import java.util.Vector;/** * Base class for RBFKernel and PolyKernel that implements a simple LRU. * (least-recently-used) cache if the cache size is set to a value > 0. * Otherwise it uses a full cache. *  * @author Eibe Frank (eibe@cs.waikato.ac.nz) * @author Shane Legg (shane@intelligenesis.net) (sparse vector code) * @author Stuart Inglis (stuart@reeltwo.com) (sparse vector code) * @author J. Lindgren (jtlindgr{at}cs.helsinki.fi) (RBF kernel) * @author Steven Hugg (hugg@fasterlight.com) (refactored, LRU cache) * @author Bernhard Pfahringer (bernhard@cs.waikato.ac.nz) (full cache) * @version $Revision: 1.7 $ */public abstract class CachedKernel   extends Kernel {  /** for serialization */  private static final long serialVersionUID = 702810182699015136L;      /** Counts the number of kernel evaluations. */  protected int m_kernelEvals;  /** Counts the number of kernel cache hits. */  protected int m_cacheHits;  /** The size of the cache (a prime number) */  protected int m_cacheSize = 250007;  /** Kernel cache */  protected double[] m_storage;  protected long[] m_keys;  /** The kernel matrix if full cache is used (i.e. size is set to 0) */  protected double[][] m_kernelMatrix;  /** The number of instance in the dataset */  protected int m_numInsts;  /** number of cache slots in an entry */  protected int m_cacheSlots = 4;  /**   * default constructor - does nothing.   */  public CachedKernel() {    super();  }    /**   * Initializes the kernel cache. The actual size of the cache in bytes is   * (64 * cacheSize).   *    * @param data	the data to use   * @param cacheSize	the cache size   * @throws Exception	if something goes wrong   */  protected CachedKernel(Instances data, int cacheSize) throws Exception {    super();        setCacheSize(cacheSize);        buildKernel(data);  }    /**   * Returns an enumeration describing the available options.   *   * @return 		an enumeration of all the available options.   */  public Enumeration listOptions() {    Vector		result;    Enumeration		en;        result = new Vector();    en = super.listOptions();    while (en.hasMoreElements())      result.addElement(en.nextElement());    result.addElement(new Option(	"\tThe size of the cache (a prime number), 0 for full cache and \n"	+ "\t-1 to turn it off.\n"	+ "\t(default: 250007)",	"C", 1, "-C <num>"));    return result.elements();  }  /**   * Parses a given list of options. <p/>   *    * @param options 	the list of options as an array of strings   * @throws Exception 	if an option is not supported   */  public void setOptions(String[] options) throws Exception {    String	tmpStr;        tmpStr = Utils.getOption('C', options);    if (tmpStr.length() != 0)      setCacheSize(Integer.parseInt(tmpStr));    else      setCacheSize(250007);        super.setOptions(options);  }  /**   * Gets the current settings of the Kernel.   *   * @return an array of strings suitable for passing to setOptions   */  public String[] getOptions() {    int       i;    Vector    result;    String[]  options;    result = new Vector();    options = super.getOptions();    for (i = 0; i < options.length; i++)      result.add(options[i]);    result.add("-C");    result.add("" + getCacheSize());    return (String[]) result.toArray(new String[result.size()]);	    }  /**   * This method is overridden in subclasses to implement specific kernels.   *    * @param id1   	the index of instance 1   * @param id2		the index of instance 2   * @param inst1	the instance 1 object   * @return 		the dot product   * @throws Exception 	if something goes wrong   */  protected abstract double evaluate(int id1, int id2, Instance inst1)    throws Exception;  /**   * Implements the abstract function of Kernel using the cache. This method   * uses the evaluate() method to do the actual dot product.   *   * @param id1 	the index of the first instance in the dataset   * @param id2 	the index of the second instance in the dataset   * @param inst1 	the instance corresponding to id1 (used if id1 == -1)   * @return 		the result of the kernel function   * @throws Exception 	if something goes wrong   */  public double eval(int id1, int id2, Instance inst1) throws Exception {		    double result = 0;    long key = -1;    int location = -1;    // we can only cache if we know the indexes and caching is not     // disbled (m_cacheSize == -1)    if ( (id1 >= 0) && (m_cacheSize != -1) ) {      // Use full cache?      if (m_cacheSize == 0) {	if (m_kernelMatrix == null) {	  m_kernelMatrix = new double[m_data.numInstances()][];	  for(int i = 0; i < m_data.numInstances(); i++) {	    m_kernelMatrix[i] = new double[i + 1];	    for(int j = 0; j <= i; j++) {	      m_kernelEvals++;	      m_kernelMatrix[i][j] = evaluate(i, j, m_data.instance(i));	    }	  }	} 	m_cacheHits++;	result = (id1 > id2) ? m_kernelMatrix[id1][id2] : m_kernelMatrix[id2][id1];	return result;      }      // Use LRU cache      if (id1 > id2) {	key = (id1 + ((long) id2 * m_numInsts));      } else {	key = (id2 + ((long) id1 * m_numInsts));      }      location = (int) (key % m_cacheSize) * m_cacheSlots;      int loc = location;      for (int i = 0; i < m_cacheSlots; i++) {	long thiskey = m_keys[loc];	if (thiskey == 0)	  break; // empty slot, so break out of loop early	if (thiskey == (key + 1)) {	  m_cacheHits++;	  // move entry to front of cache (LRU) by swapping	  // only if it's not already at the front of cache	  if (i > 0) {	    double tmps = m_storage[loc];	    m_storage[loc] = m_storage[location];	    m_keys[loc] = m_keys[location];	    m_storage[location] = tmps;	    m_keys[location] = thiskey;	    return tmps;	  } else	    return m_storage[loc];	}	loc++;      }    }    result = evaluate(id1, id2, inst1);    m_kernelEvals++;    // store result in cache    if ( (key != -1) && (m_cacheSize != -1) ) {      // move all cache slots forward one array index      // to make room for the new entry      System.arraycopy(m_keys, location, m_keys, location + 1,		       m_cacheSlots - 1);      System.arraycopy(m_storage, location, m_storage, location + 1,		       m_cacheSlots - 1);      m_storage[location] = result;      m_keys[location] = (key + 1);    }    return result;  }  /**   * Returns the number of time Eval has been called.   *    * @return 		the number of kernel evaluation.   */  public int numEvals() {    return m_kernelEvals;  }  /**   * Returns the number of cache hits on dot products.   *    * @return 		the number of cache hits.   */  public int numCacheHits() {    return m_cacheHits;  }  /**   * Frees the cache used by the kernel.   */  public void clean() {    m_storage = null;    m_keys = null;    m_kernelMatrix = null;  }  /**   * Calculates a dot product between two instances   *    * @param inst1	the first instance   * @param inst2	the second instance   * @return 		the dot product of the two instances.   * @throws Exception	if an error occurs   */  protected final double dotProd(Instance inst1, Instance inst2)    throws Exception {    double result = 0;    // we can do a fast dot product    int n1 = inst1.numValues();    int n2 = inst2.numValues();    int classIndex = m_data.classIndex();    for (int p1 = 0, p2 = 0; p1 < n1 && p2 < n2;) {      int ind1 = inst1.index(p1);      int ind2 = inst2.index(p2);      if (ind1 == ind2) {	if (ind1 != classIndex) {	  result += inst1.valueSparse(p1) * inst2.valueSparse(p2);	}	p1++;	p2++;      } else if (ind1 > ind2) {	p2++;      } else {	p1++;      }    }    return (result);  }  /**   * Sets the size of the cache to use (a prime number)   *    * @param value	the size of the cache   */  public void setCacheSize(int value) {    if (value >= -1) {      m_cacheSize = value;      clean();    }    else {      System.out.println(	  "Cache size cannot be smaller than -1 (provided: " + value + ")!");    }  }    /**   * Gets the size of the cache   *    * @return 		the cache size   */  public int getCacheSize() {    return m_cacheSize;  }  /**   * Returns the tip text for this property   *    * @return 		tip text for this property suitable for   * 			displaying in the explorer/experimenter gui   */  public String cacheSizeTipText() {    return "The size of the cache (a prime number), 0 for full cache and -1 to turn it off.";  }  /**   * initializes variables etc.   *    * @param data	the data to use   */  protected void initVars(Instances data) {    super.initVars(data);        m_kernelEvals = 0;    m_cacheHits   = 0;    m_numInsts    = m_data.numInstances();    if (getCacheSize() > 0) {      // Use LRU cache      m_storage = new double[m_cacheSize * m_cacheSlots];      m_keys    = new long[m_cacheSize * m_cacheSlots];    }     else {      m_storage      = null;      m_keys         = null;      m_kernelMatrix = null;    }  }    /**   * builds the kernel with the given data. Initializes the kernel cache.    * The actual size of the cache in bytes is (64 * cacheSize).   *    * @param data	the data to base the kernel on   * @throws Exception	if something goes wrong   */  public void buildKernel(Instances data) throws Exception {    // does kernel handle the data?    if (!getChecksTurnedOff())      getCapabilities().testWithFail(data);    initVars(data);  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
六月丁香综合在线视频| 国产一区二区三区免费看| 香蕉乱码成人久久天堂爱免费| 99re成人精品视频| 日韩理论片在线| 欧洲精品在线观看| 日韩精品亚洲一区| 欧美不卡一二三| 国产成人精品三级麻豆| 中文字幕一区二区三区四区| 91国偷自产一区二区开放时间 | 丁香网亚洲国际| 欧美激情一区二区三区四区| 色综合天天综合网国产成人综合天 | 亚洲激情网站免费观看| 欧美日韩三级一区二区| 蜜臀av在线播放一区二区三区| 欧美精品一区二区高清在线观看| 丁香亚洲综合激情啪啪综合| 艳妇臀荡乳欲伦亚洲一区| 日韩一级大片在线| 成人午夜电影久久影院| 亚洲一区二区精品视频| 欧美精品一区视频| 一本久久综合亚洲鲁鲁五月天| 日本不卡免费在线视频| 国产精品久久一级| 91精品欧美久久久久久动漫| 国产成人av一区二区三区在线| 亚洲自拍偷拍综合| 国产日韩精品一区| 欧美日本在线播放| 高清免费成人av| 午夜精品爽啪视频| 国产精品美女一区二区| 91精品久久久久久久久99蜜臂| 风间由美性色一区二区三区| 爽爽淫人综合网网站| 国产精品网站在线观看| 日韩手机在线导航| 99精品视频在线观看| 久久se精品一区二区| 一区二区三区毛片| 久久久国产精品午夜一区ai换脸| 欧美午夜精品理论片a级按摩| 国产精品18久久久| 日韩1区2区3区| 亚洲激情六月丁香| 国产精品人成在线观看免费 | 久久九九99视频| 欧美精品久久天天躁| 成人av电影免费在线播放| 久久精品国产77777蜜臀| 亚洲激情成人在线| 国产精品久久久久永久免费观看| 精品久久久久久久久久久久久久久久久 | 中文子幕无线码一区tr| 亚洲精品一区二区三区影院| 欧美日韩高清不卡| 欧美亚洲国产一区二区三区va | 欧美日韩精品欧美日韩精品一综合| 粉嫩蜜臀av国产精品网站| 奇米影视一区二区三区| 五月综合激情日本mⅴ| 亚洲精品精品亚洲| 国产精品网站导航| 国产欧美视频一区二区| 久久久一区二区三区| 欧美大胆人体bbbb| 日韩精品一区二区三区中文精品| 制服.丝袜.亚洲.中文.综合| 欧美日韩国产综合久久 | www.欧美亚洲| 丁香桃色午夜亚洲一区二区三区| 国模一区二区三区白浆| 精品一区二区精品| 国产一区美女在线| 国产精品一区二区免费不卡 | 国产精品天美传媒| 国产日韩成人精品| 国产精品视频看| 中文字幕一区二区三区在线不卡| 中文字幕一区二区三区不卡在线| 国产精品色婷婷| 国产精品盗摄一区二区三区| 中文字幕中文乱码欧美一区二区| 久久精品人人做| 欧美国产综合色视频| 综合自拍亚洲综合图不卡区| 亚洲男人电影天堂| 亚洲成人激情av| 青青草国产精品97视觉盛宴 | 国产精品女同一区二区三区| 日本一区二区久久| 亚洲女人的天堂| 亚洲综合视频在线| 亚洲成av人片在线| 看片网站欧美日韩| 福利一区福利二区| 在线观看亚洲成人| 欧美一区二区三区思思人 | 亚洲国产精品高清| 洋洋成人永久网站入口| 蜜臀va亚洲va欧美va天堂| 国产综合色视频| 91免费版在线| 91精品免费观看| 欧美激情一区二区| 亚洲bt欧美bt精品| 国产精品99久久久| 精品视频一区二区三区免费| 精品福利二区三区| 亚洲综合激情另类小说区| 青青国产91久久久久久| 不卡的av电影| 日韩视频免费观看高清完整版在线观看| 精品国产乱码91久久久久久网站| 一区视频在线播放| 久久精品国产秦先生| 91小视频在线| 欧美电影免费观看高清完整版在| 中文字幕亚洲一区二区av在线 | 一个色妞综合视频在线观看| 青青国产91久久久久久 | 国产91丝袜在线播放0| 欧美日产在线观看| 国产精品久久久久久亚洲毛片 | 欧美日韩中文字幕一区二区| 精品国产亚洲一区二区三区在线观看| 国产精品网站一区| 久久精品国产成人一区二区三区| 91小视频免费看| 精品国产亚洲在线| 亚洲国产综合人成综合网站| 国产精品一区专区| 9191久久久久久久久久久| 亚洲卡通动漫在线| 国产成人自拍在线| 欧美一级在线观看| 亚洲男人的天堂在线观看| 国产成人亚洲精品狼色在线 | 欧美性猛交xxxxxx富婆| 国产精品色哟哟| 国产美女娇喘av呻吟久久| 欧美体内she精高潮| 亚洲欧美日韩国产综合在线| 国产精品自在欧美一区| 欧美大白屁股肥臀xxxxxx| 日日摸夜夜添夜夜添亚洲女人| 91免费版在线| 国产精品久久久久影院亚瑟 | 91视视频在线观看入口直接观看www| 欧美本精品男人aⅴ天堂| 五月天激情综合| 欧美日韩在线播放| 亚洲成人免费看| 在线观看欧美黄色| 亚洲最新视频在线播放| 一本高清dvd不卡在线观看| 国产精品无遮挡| 福利视频网站一区二区三区| 久久精品水蜜桃av综合天堂| 国产一区二区不卡老阿姨| 精品国产免费人成在线观看| 蜜桃久久精品一区二区| 欧美一区二区三区在线看| 日韩主播视频在线| 欧美一级一级性生活免费录像| 午夜影院在线观看欧美| 欧美人成免费网站| 美女高潮久久久| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 日韩av电影一区| 日韩视频免费直播| 国产一区二区视频在线播放| 精品对白一区国产伦| 国产在线精品免费av| 中文字幕乱码亚洲精品一区| 99久久精品情趣| 一区二区三区国产精华| 欧美高清激情brazzers| 久久99热这里只有精品| 久久精品一区蜜桃臀影院| 波多野结衣一区二区三区| 亚洲精品亚洲人成人网在线播放| 欧美日韩免费高清一区色橹橹| 婷婷开心激情综合| 日韩欧美一级二级| 丁香婷婷综合色啪| 亚洲一区二区在线免费观看视频 | 亚洲色图.com| 欧美日韩国产小视频在线观看| 日韩影院在线观看| 久久久午夜电影| 91丝袜美腿高跟国产极品老师 | 国产制服丝袜一区| 亚洲日本丝袜连裤袜办公室| 欧美日韩1区2区| 经典三级在线一区| 亚洲男人天堂一区|