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

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

?? svm.m4

?? 一種應(yīng)用廣泛的分類算法
?? M4
?? 第 1 頁 / 共 5 頁
字號:
define(`swap',`do {$1 _=$2; $2=$3; $3=_;} while(false)')define(`Qfloat',`float')define(`SIZE_OF_QFLOAT',4)define(`TAU',1e-12)package libsvm;import java.io.*;import java.util.*;//// Kernel Cache//// l is the number of total data items// size is the cache size limit in bytes//class Cache {	private final int l;	private int size;	private final class head_t	{		head_t prev, next;	// a cicular list		Qfloat[] data;		int len;		// data[0,len) is cached in this entry	}	private final head_t[] head;	private head_t lru_head;	Cache(int l_, int size_)	{		l = l_;		size = size_;		head = new head_t[l];		for(int i=0;i<l;i++) head[i] = new head_t();		size /= SIZE_OF_QFLOAT;		size -= l * (16/SIZE_OF_QFLOAT);	// sizeof(head_t) == 16		size = Math.max(size, 2*l);  // cache must be large enough for two columns		lru_head = new head_t();		lru_head.next = lru_head.prev = lru_head;	}	private void lru_delete(head_t h)	{		// delete from current location		h.prev.next = h.next;		h.next.prev = h.prev;	}	private void lru_insert(head_t h)	{		// insert to last position		h.next = lru_head;		h.prev = lru_head.prev;		h.prev.next = h;		h.next.prev = h;	}	// request data [0,len)	// return some position p where [p,len) need to be filled	// (p >= len if nothing needs to be filled)	// java: simulate pointer using single-element array	int get_data(int index, Qfloat[][] data, int len)	{		head_t h = head[index];		if(h.len > 0) lru_delete(h);		int more = len - h.len;		if(more > 0)		{			// free old space			while(size < more)			{				head_t old = lru_head.next;				lru_delete(old);				size += old.len;				old.data = null;				old.len = 0;			}			// allocate new space			Qfloat[] new_data = new Qfloat[len];			if(h.data != null) System.arraycopy(h.data,0,new_data,0,h.len);			h.data = new_data;			size -= more;			swap(int,h.len,len);		}		lru_insert(h);		data[0] = h.data;		return len;	}	void swap_index(int i, int j)	{		if(i==j) return;				if(head[i].len > 0) lru_delete(head[i]);		if(head[j].len > 0) lru_delete(head[j]);		swap(Qfloat[],head[i].data,head[j].data);		swap(int,head[i].len,head[j].len);		if(head[i].len > 0) lru_insert(head[i]);		if(head[j].len > 0) lru_insert(head[j]);		if(i>j) swap(int,i,j);		for(head_t h = lru_head.next; h!=lru_head; h=h.next)		{			if(h.len > i)			{				if(h.len > j)					swap(Qfloat,h.data[i],h.data[j]);				else				{					// give up					lru_delete(h);					size += h.len;					h.data = null;					h.len = 0;				}			}		}	}}//// Kernel evaluation//// the static method k_function is for doing single kernel evaluation// the constructor of Kernel prepares to calculate the l*l kernel matrix// the member function get_Q is for getting one column from the Q Matrix//abstract class QMatrix {	abstract Qfloat[] get_Q(int column, int len);	abstract Qfloat[] get_QD();	abstract void swap_index(int i, int j);};abstract class Kernel extends QMatrix {	private svm_node[][] x;	private final double[] x_square;	// svm_parameter	private final int kernel_type;	private final int degree;	private final double gamma;	private final double coef0;	abstract Qfloat[] get_Q(int column, int len);	abstract Qfloat[] get_QD();	void swap_index(int i, int j)	{		swap(svm_node[],x[i],x[j]);		if(x_square != null) swap(double,x_square[i],x_square[j]);	}	private static double powi(double base, int times)	{	        double tmp = base, ret = 1.0;        	for(int t=times; t>0; t/=2)		{                	if(t%2==1) ret*=tmp;	                tmp = tmp * tmp;        	}	        return ret;	}	private static double tanh(double x)	{		double e = Math.exp(x);		return 1.0-2.0/(e*e+1);	}	double kernel_function(int i, int j)	{		switch(kernel_type)		{			case svm_parameter.LINEAR:				return dot(x[i],x[j]);			case svm_parameter.POLY:				return powi(gamma*dot(x[i],x[j])+coef0,degree);			case svm_parameter.RBF:				return Math.exp(-gamma*(x_square[i]+x_square[j]-2*dot(x[i],x[j])));			case svm_parameter.SIGMOID:				return tanh(gamma*dot(x[i],x[j])+coef0);			case svm_parameter.PRECOMPUTED:				return x[i][(int)(x[j][0].value)].value;			default:				return 0;	// java		}	}	Kernel(int l, svm_node[][] x_, svm_parameter param)	{		this.kernel_type = param.kernel_type;		this.degree = param.degree;		this.gamma = param.gamma;		this.coef0 = param.coef0;		x = (svm_node[][])x_.clone();		if(kernel_type == svm_parameter.RBF)		{			x_square = new double[l];			for(int i=0;i<l;i++)				x_square[i] = dot(x[i],x[i]);		}		else x_square = null;	}	static double dot(svm_node[] x, svm_node[] y)	{		double sum = 0;		int xlen = x.length;		int ylen = y.length;		int i = 0;		int j = 0;		while(i < xlen && j < ylen)		{			if(x[i].index == y[j].index)				sum += x[i++].value * y[j++].value;			else			{				if(x[i].index > y[j].index)					++j;				else					++i;			}		}		return sum;	}	static double k_function(svm_node[] x, svm_node[] y,					svm_parameter param)	{		switch(param.kernel_type)		{			case svm_parameter.LINEAR:				return dot(x,y);			case svm_parameter.POLY:				return powi(param.gamma*dot(x,y)+param.coef0,param.degree);			case svm_parameter.RBF:			{				double sum = 0;				int xlen = x.length;				int ylen = y.length;				int i = 0;				int j = 0;				while(i < xlen && j < ylen)				{					if(x[i].index == y[j].index)					{						double d = x[i++].value - y[j++].value;						sum += d*d;					}					else if(x[i].index > y[j].index)					{						sum += y[j].value * y[j].value;						++j;					}					else					{						sum += x[i].value * x[i].value;						++i;					}				}				while(i < xlen)				{					sum += x[i].value * x[i].value;					++i;				}				while(j < ylen)				{					sum += y[j].value * y[j].value;					++j;				}				return Math.exp(-param.gamma*sum);			}			case svm_parameter.SIGMOID:				return tanh(param.gamma*dot(x,y)+param.coef0);			case svm_parameter.PRECOMPUTED:				return 	x[(int)(y[0].value)].value;			default:				return 0;	// java		}	}}// Generalized SMO+SVMlight algorithm// Solves:////	min 0.5(\alpha^T Q \alpha) + b^T \alpha////		y^T \alpha = \delta//		y_i = +1 or -1//		0 <= alpha_i <= Cp for y_i = 1//		0 <= alpha_i <= Cn for y_i = -1//// Given:////	Q, b, y, Cp, Cn, and an initial feasible point \alpha//	l is the size of vectors and matrices//	eps is the stopping criterion//// solution will be put in \alpha, objective value will be put in obj//class Solver {	int active_size;	byte[] y;	double[] G;		// gradient of objective function	static final byte LOWER_BOUND = 0;	static final byte UPPER_BOUND = 1;	static final byte FREE = 2;	byte[] alpha_status;	// LOWER_BOUND, UPPER_BOUND, FREE	double[] alpha;	QMatrix Q;	Qfloat[] QD;	double eps;	double Cp,Cn;	double[] b;	int[] active_set;	double[] G_bar;		// gradient, if we treat free variables as 0	int l;	boolean unshrinked;	// XXX		static final double INF = java.lang.Double.POSITIVE_INFINITY;	double get_C(int i)	{		return (y[i] > 0)? Cp : Cn;	}	void update_alpha_status(int i)	{		if(alpha[i] >= get_C(i))			alpha_status[i] = UPPER_BOUND;		else if(alpha[i] <= 0)			alpha_status[i] = LOWER_BOUND;		else alpha_status[i] = FREE;	}	boolean is_upper_bound(int i) { return alpha_status[i] == UPPER_BOUND; }	boolean is_lower_bound(int i) { return alpha_status[i] == LOWER_BOUND; }	boolean is_free(int i) {  return alpha_status[i] == FREE; }	// java: information about solution except alpha,	// because we cannot return multiple values otherwise...	static class SolutionInfo {		double obj;		double rho;		double upper_bound_p;		double upper_bound_n;		double r;	// for Solver_NU	}	void swap_index(int i, int j)	{		Q.swap_index(i,j);		swap(byte,	y[i],y[j]);		swap(double,	G[i],G[j]);		swap(byte,	alpha_status[i],alpha_status[j]);		swap(double,	alpha[i],alpha[j]);		swap(double,	b[i],b[j]);		swap(int,	active_set[i],active_set[j]);		swap(double,	G_bar[i],G_bar[j]);	}	void reconstruct_gradient()	{		// reconstruct inactive elements of G from G_bar and free variables		if(active_size == l) return;		int i;		for(i=active_size;i<l;i++)			G[i] = G_bar[i] + b[i];		for(i=0;i<active_size;i++)			if(is_free(i))			{				Qfloat[] Q_i = Q.get_Q(i,l);				double alpha_i = alpha[i];				for(int j=active_size;j<l;j++)					G[j] += alpha_i * Q_i[j];			}	}	void Solve(int l, QMatrix Q, double[] b_, byte[] y_,		   double[] alpha_, double Cp, double Cn, double eps, SolutionInfo si, int shrinking)	{		this.l = l;		this.Q = Q;		QD = Q.get_QD();		b = (double[])b_.clone();		y = (byte[])y_.clone();		alpha = (double[])alpha_.clone();		this.Cp = Cp;		this.Cn = Cn;		this.eps = eps;		this.unshrinked = false;		// initialize alpha_status		{			alpha_status = new byte[l];			for(int i=0;i<l;i++)				update_alpha_status(i);		}		// initialize active set (for shrinking)		{			active_set = new int[l];			for(int i=0;i<l;i++)				active_set[i] = i;			active_size = l;		}		// initialize gradient		{			G = new double[l];			G_bar = new double[l];			int i;			for(i=0;i<l;i++)			{				G[i] = b[i];				G_bar[i] = 0;			}			for(i=0;i<l;i++)				if(!is_lower_bound(i))				{					Qfloat[] Q_i = Q.get_Q(i,l);					double alpha_i = alpha[i];					int j;					for(j=0;j<l;j++)						G[j] += alpha_i*Q_i[j];					if(is_upper_bound(i))						for(j=0;j<l;j++)							G_bar[j] += get_C(i) * Q_i[j];				}		}		// optimization step		int iter = 0;		int counter = Math.min(l,1000)+1;		int[] working_set = new int[2];		while(true)		{			// show progress and do shrinking			if(--counter == 0)			{				counter = Math.min(l,1000);				if(shrinking!=0) do_shrinking();				System.err.print(".");			}			if(select_working_set(working_set)!=0)			{				// reconstruct the whole gradient				reconstruct_gradient();				// reset active set size and check				active_size = l;				System.err.print("*");				if(select_working_set(working_set)!=0)					break;				else					counter = 1;	// do shrinking next iteration			}						int i = working_set[0];			int j = working_set[1];			++iter;			// update alpha[i] and alpha[j], handle bounds carefully			Qfloat[] Q_i = Q.get_Q(i,active_size);			Qfloat[] Q_j = Q.get_Q(j,active_size);			double C_i = get_C(i);			double C_j = get_C(j);			double old_alpha_i = alpha[i];			double old_alpha_j = alpha[j];			if(y[i]!=y[j])			{				double quad_coef = Q_i[i]+Q_j[j]+2*Q_i[j];				if (quad_coef <= 0)					quad_coef = TAU;				double delta = (-G[i]-G[j])/quad_coef;				double diff = alpha[i] - alpha[j];				alpha[i] += delta;				alpha[j] += delta;							if(diff > 0)				{					if(alpha[j] < 0)					{						alpha[j] = 0;						alpha[i] = diff;					}				}				else				{					if(alpha[i] < 0)					{						alpha[i] = 0;						alpha[j] = -diff;					}				}				if(diff > C_i - C_j)				{					if(alpha[i] > C_i)					{						alpha[i] = C_i;						alpha[j] = C_i - diff;					}				}				else				{					if(alpha[j] > C_j)					{						alpha[j] = C_j;						alpha[i] = C_j + diff;					}				}			}			else			{				double quad_coef = Q_i[i]+Q_j[j]-2*Q_i[j];				if (quad_coef <= 0)					quad_coef = TAU;				double delta = (G[i]-G[j])/quad_coef;				double sum = alpha[i] + alpha[j];				alpha[i] -= delta;				alpha[j] += delta;				if(sum > C_i)				{					if(alpha[i] > C_i)					{						alpha[i] = C_i;						alpha[j] = sum - C_i;					}				}				else				{					if(alpha[j] < 0)					{						alpha[j] = 0;						alpha[i] = sum;					}				}				if(sum > C_j)				{					if(alpha[j] > C_j)					{						alpha[j] = C_j;						alpha[i] = sum - C_j;					}				}				else

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲影视在线观看| 欧美激情一区二区| 偷拍日韩校园综合在线| 91福利在线观看| 亚洲午夜精品网| 欧美日韩一区二区三区在线看 | 日韩亚洲欧美一区| 美女视频网站黄色亚洲| 日韩美女视频在线| 国产成人亚洲精品青草天美| 国产精品网曝门| 在线观看网站黄不卡| 日韩国产一二三区| 久久丝袜美腿综合| 一本色道亚洲精品aⅴ| 亚洲gay无套男同| 久久男人中文字幕资源站| 99视频一区二区三区| 亚洲国产精品久久人人爱蜜臀| 欧美日韩成人综合天天影院 | 久久亚洲精精品中文字幕早川悠里 | 欧美在线一区二区三区| 亚洲激情欧美激情| 欧美精品久久99久久在免费线| 亚洲一区二区三区视频在线| 欧美色视频在线| 日韩av电影免费观看高清完整版 | 99re热视频这里只精品| 成人免费在线视频| 欧洲精品视频在线观看| 蜜臀a∨国产成人精品| 久久久久久99久久久精品网站| 国产成人精品免费在线| 亚洲桃色在线一区| 欧美福利电影网| 国产一区视频导航| 亚洲男帅同性gay1069| 欧美日韩免费高清一区色橹橹| 日韩中文字幕一区二区三区| 精品黑人一区二区三区久久| 国产不卡在线一区| 亚洲在线免费播放| 精品国产一区二区三区四区四| 国产成人午夜精品影院观看视频| 国产精品久久99| 欧美日韩免费电影| 国产伦精品一区二区三区免费迷| 综合av第一页| 日韩久久免费av| 99视频超级精品| 日本欧美一区二区三区| 国产情人综合久久777777| 在线观看日产精品| 国产夫妻精品视频| 一区二区理论电影在线观看| 精品国产凹凸成av人导航| 成人国产精品免费观看动漫| 亚洲va欧美va人人爽| 亚洲国产岛国毛片在线| 欧美酷刑日本凌虐凌虐| 99久久99久久精品国产片果冻| 亚洲丶国产丶欧美一区二区三区| 久久久综合精品| 欧美一区二区三区电影| 波多野结衣一区二区三区| 日韩电影免费在线| 亚洲精品伦理在线| 国产精品欧美精品| 3d成人h动漫网站入口| 成人av网站在线| 九九**精品视频免费播放| 中文字幕永久在线不卡| 欧美成人vps| 欧美少妇一区二区| 91久久精品网| 国产一区二区三区美女| 成人欧美一区二区三区视频网页| 精品美女一区二区| 欧美精品免费视频| 欧美日韩一区二区三区在线看| 92国产精品观看| 成人av电影免费在线播放| 美女脱光内衣内裤视频久久网站| 亚洲电影第三页| 夜夜亚洲天天久久| 亚洲欧美日韩中文字幕一区二区三区| 久久伊人中文字幕| 日韩免费一区二区三区在线播放| 欧美日韩亚洲不卡| 欧美性大战久久| 色域天天综合网| 成人av在线一区二区| 国产精品一区在线观看乱码 | 成人小视频在线| 韩国女主播成人在线观看| 丝袜美腿亚洲综合| 日韩电影在线观看一区| 午夜精品福利一区二区三区av | 国产欧美精品在线观看| 久久免费视频一区| 久久天堂av综合合色蜜桃网| 久久影音资源网| 久久久亚洲高清| 国产三级一区二区| 国产精品青草综合久久久久99| 久久精品亚洲精品国产欧美| 国产午夜精品一区二区三区嫩草| 久久久国产精品麻豆| 欧美刺激脚交jootjob| 精品欧美黑人一区二区三区| 精品国产欧美一区二区| 国产网站一区二区| 亚洲视频在线一区| 一区二区三区日韩精品视频| 亚洲成a人v欧美综合天堂| 日韩电影在线观看网站| 久久精品99国产精品| 国产精品亚洲专一区二区三区| 国产精品影视在线| 99国产精品久久| 欧美伊人久久大香线蕉综合69| 3d动漫精品啪啪一区二区竹菊| 日韩欧美国产精品一区| 久久久久久97三级| 亚洲欧美欧美一区二区三区| 伊人夜夜躁av伊人久久| 蜜臀精品一区二区三区在线观看 | 日韩电影免费在线看| 国产综合成人久久大片91| 国产成人a级片| 欧美中文一区二区三区| 日韩一级免费观看| 国产精品天美传媒沈樵| 亚洲国产视频在线| 国产酒店精品激情| 在线欧美日韩精品| 欧美精品一区二区三| 国产精品精品国产色婷婷| 亚洲一区二区在线免费看| 紧缚捆绑精品一区二区| 91网站视频在线观看| 99九九99九九九视频精品| 欧美精品自拍偷拍动漫精品| 久久九九影视网| 亚洲一区二区不卡免费| 国产精品自在欧美一区| 欧美中文字幕一区| 国产亚洲污的网站| 丝袜国产日韩另类美女| 成人免费毛片aaaaa**| 88在线观看91蜜桃国自产| 国产午夜精品久久久久久免费视| 亚洲一区二区三区中文字幕| 日韩一区精品字幕| 波多野结衣一区二区三区 | 国产精品综合视频| 欧美精品xxxxbbbb| 国产精品进线69影院| 精彩视频一区二区| 欧美一区二区啪啪| 亚洲一区中文日韩| 99久久精品国产毛片| 亚洲精品在线免费播放| 亚洲高清在线精品| 91视频观看视频| 国产亚洲自拍一区| 久久国产尿小便嘘嘘尿| 欧美午夜不卡视频| 国产精品美女久久久久久| 国产一区二区电影| 精品精品欲导航| 日韩高清不卡在线| 欧美性受xxxx| 一区二区视频免费在线观看| 成人美女在线视频| 欧美精品一区男女天堂| 日本亚洲最大的色成网站www| 日本道在线观看一区二区| 亚洲欧美综合另类在线卡通| 福利电影一区二区| 国产亚洲综合av| 国产91丝袜在线观看| 久久久久久久久久久久久夜| 经典三级在线一区| 欧美r级在线观看| 不卡的av电影| 1区2区3区精品视频| 成人福利视频网站| 中文字幕在线一区免费| 不卡一区二区在线| 国产精品久久久久久户外露出| 高清不卡一二三区| 国产精品国产三级国产普通话三级| 国产一区二区导航在线播放| 亚洲精品在线观看网站| 国产精品一区二区无线| 久久久久久久久久美女| 国产精品一区不卡| 国产精品久久久久aaaa| 99综合电影在线视频|