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

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

?? smo.java

?? JAVA版本的支持向量機(jī)(SVM)處理器。可配置參數(shù)。
?? JAVA
?? 第 1 頁 / 共 2 頁
字號(hào):
import java.util.*;
import java.lang.*;
import java.io.*;
import java.rmi.*;
import java.math.*;


class sparse_binary_vector
{
	Vector id = new Vector();
}

class sparse_vector
{
	Vector id = new Vector();
	Vector val =  new Vector();
}

public class Smo
{
	
	public int N = 0;                    /* N points(rows) */
	public int d = -1;                   /* d variables */
	public float C=(float)0.05;
	public float tolerance=(float)0.001;
	public float eps=(float)0.001;
	public float two_sigma_squared=2;
	public int MATRIX=2000;
 
  
	Vector alph = new Vector();           /* Lagrange multipliers */
	float b = 0;                      /* threshold */
	Vector w =  new Vector();              /* weight vector: only for linear kernel */

	Vector error_cache = new Vector();
  
	Vector dense_vector =  new Vector();

	public boolean is_sparse_data = false;
	public boolean is_binary = false;
  
	public boolean is_libsvm_file = true;
  
	int learned_func_flag = -1;
	int dot_product_flag = -1;
	int kernel_flag = -1;
  
  

	Vector sparse_binary_points =  new Vector();
 
 
	Vector sparse_points =  new Vector();
 

	float dense_points[][] = new float[MATRIX][MATRIX];
	

	Vector target = new Vector();

	boolean is_test_only = false;
	boolean is_linear_kernel = false;
  
	/* data points with index in [first_test_i .. N)
	 * will be tested to compute error rate
	 */
	int first_test_i = 0;

	/*
	 * support vectors are within [0..end_support_i)
	 */
	int end_support_i = -1;
  
	float delta_b=0;
   

	Vector precomputed_self_dot_product = new Vector();
 
	float precomputed_dot_product[][] = new float[MATRIX][MATRIX];

	public Smo()
	{
	
		for ( int i=0; i< MATRIX; i++)
			for ( int j =0; j< MATRIX; j++)
				dense_points[i][j] = 0;

	}

	float object2float(Object o)
	{
		Float result = (Float)o;
		return result.floatValue();
	}

	int object2int(Object o)
	{
		Integer result = (Integer)o;
		return result.intValue();
	}
	void setVector(Vector v, int location, float value)
	{
		Float result = new Float(value);
		v.set(location,result);
	}
	
	void setVector(Vector v, int location, int value)
	{
		Integer result = new Integer(value);
		v.set(location,result);
	}
	
	float getFloatValue(Vector v, int location)
	{	
		Float result =(Float) v.elementAt(location);
		return result.floatValue();
	}
	
	int getIntValue(Vector v, int location)
	{
		Integer result =(Integer) v.elementAt(location);
		return result.intValue();
	}	

	int examineExample(int i1)
	{

		float y1=0, alph1=0, E1=0, r1=0;
		y1 = object2int(target.elementAt(i1));
		alph1 = object2float(alph.elementAt(i1));
 
		if (alph1 > 0 && alph1 < C)
			E1 = object2float(error_cache.elementAt(i1));
		else 
			E1 = learned_func(i1,learned_func_flag) - y1;
 
		r1 = y1 * E1;
		if ((r1 < -tolerance && alph1 < C) || (r1 > tolerance && alph1 > 0))
		{       
			{
				int k=0, i2=0;
				float tmax=0;
      
				for (i2 = (-1), tmax = 0, k = 0; k < end_support_i; k++)
					if (object2float(alph.elementAt(k)) > 0 && object2float(alph.elementAt(k)) < C) 
					{
						float E2=0, temp=0;
      
						E2 = object2float(error_cache.elementAt(k));
						temp = Math.abs(E1 - E2);
						if (temp > tmax)
						{
							tmax = temp;
							i2 = k;
      
						}
					}
   
				if (i2 >= 0) 
				{
					if (takeStep (i1, i2)==1)
					{   
  
						return 1;
					}
				}
			}
			float rands = 0;
			{
				int k=0, k0=0;
				int i2=0;
   
				for (rands = (float)Math.random(), k0 = (int) (rands * end_support_i), k = k0; k < end_support_i + k0; k++) 
				{
    
					i2 = k % end_support_i;
        
					if (object2float(alph.elementAt(i2)) > 0 && object2float(alph.elementAt(i2)) < C) 
					{
						if (takeStep(i1, i2)==1)
						{
        
							return 1;
						}
					}
				}
			}

			{      
				int k0=0, k=0, i2=0;
				rands = 0;
     
				for (rands = (float)Math.random(),k0 = (int)(rands * end_support_i), k = k0; k < end_support_i + k0; k++) 
				{
					i2 = k % end_support_i;
					if (takeStep(i1, i2)== 1)
					{ 	
       
						return 1;
					}
				}
			}
		}
		return 0;
	}
	
	int takeStep(int i1, int i2) 
	{ 
		int y1=0, y2=0, s=0;
		float alph1=0, alph2=0; /* old_values of alpha_1, alpha_2 */
		float a1=0, a2=0;       /* new values of alpha_1, alpha_2 */
		float E1=0, E2=0, L=0, H=0, k11=0, k22=0, k12=0, eta=0, Lobj=0, Hobj=0;


 
		if (i1 == i2) return 0;
    
		alph1 = object2float(alph.elementAt(i1));
		y1 = object2int(target.elementAt(i1));
		if (alph1 > 0 && alph1 < C)
			E1 = object2float(error_cache.elementAt(i1));
		else 
			E1 = learned_func(i1,learned_func_flag) - y1;
  
		alph2 = object2float(alph.elementAt(i2));
		y2 = object2int(target.elementAt(i2));
		if (alph2 > 0 && alph2 < C)
			E2 = object2float(error_cache.elementAt(i2));
		else 
			E2 = learned_func(i2,learned_func_flag) - y2;
  
		s = y1 * y2;


  
		if (y1 == y2) 
		{
			float gamma = alph1 + alph2;
			if (gamma > C) 
			{
				L = gamma-C;
				H = C;
			}
			else 
			{
				L = 0;
				H = gamma;
			}
		}
		else 
		{
			float gamma = alph1 - alph2;
			if (gamma > 0) 
			{
				L = 0;
				H = C - gamma;
			}
			else 
			{
				L = -gamma;
				H = C;
			}
		}

 

		if (L == H)
		{

			return 0;
		}


		k11 = kernel_func(i1, i1,kernel_flag);
		k12 = kernel_func(i1, i2,kernel_flag);
		k22 = kernel_func(i2, i2,kernel_flag);
		eta = 2 * k12 - k11 - k22;


		if (eta < 0) 
		{
			a2 = alph2 + y2 * (E2 - E1) / eta;
			if (a2 < L)
				a2 = L;
			else if (a2 > H)
				a2 = H;
		}
		else 
		{
    

			{
				float c1 = eta/2;
				float c2 = y2 * (E1-E2)- eta * alph2;
				Lobj = c1 * L * L + c2 * L;
				Hobj = c1 * H * H + c2 * H;
			}


			if (Lobj > Hobj+eps)
				a2 = L;
			else if (Lobj < Hobj-eps)
				a2 = H;
			else
				a2 = alph2;
		}

		if (Math.abs(a2-alph2) < eps*(a2+alph2+eps))
			return 0;

		a1 = alph1 - s * (a2 - alph2);
		if (a1 < 0) 
		{
			a2 += s * a1;
			a1 = 0;
		}
		else if (a1 > C) 
		{
			float t = a1-C;
			a2 += s * t;
			a1 = C;
		}

		{
			float b1=0, b2=0, bnew=0;
  
			if (a1 > 0 && a1 < C)
				bnew = b + E1 + y1 * (a1 - alph1) * k11 + y2 * (a2 - alph2) * k12;
			else 
			{
				if (a2 > 0 && a2 < C)
					bnew = b + E2 + y1 * (a1 - alph1) * k12 + y2 * (a2 - alph2) * k22;
				else 
				{
					b1 = b + E1 + y1 * (a1 - alph1) * k11 + y2 * (a2 - alph2) * k12;
					b2 = b + E2 + y1 * (a1 - alph1) * k12 + y2 * (a2 - alph2) * k22;
					bnew = (b1 + b2) / 2;
				}
			}
  
			delta_b = bnew - b;
			b = bnew;
		}

  
		if (is_linear_kernel) 
		{
			float t1 = y1 * (a1 - alph1);
			float t2 = y2 * (a2 - alph2);
  
			if (is_sparse_data && is_binary) 
			{
				int p1=0,num1=0,p2=0,num2=0;
  
				num1 = ((sparse_binary_vector)sparse_binary_points.elementAt(i1)).id.size();
          
				for (p1=0; p1<num1; p1++)
				{
					int temp0 = object2int(((sparse_binary_vector)sparse_binary_points.elementAt(i1)).id.elementAt(p1));
					float temp = object2float(w.elementAt(temp0));
					w.set(temp0,new Float(temp + t1));
				}
				num2 = ((sparse_binary_vector)sparse_binary_points.elementAt(i2)).id.size();
         
				for (p2=0; p2<num2; p2++)
				{
					int temp0 = object2int(((sparse_binary_vector)sparse_binary_points.elementAt(i2)).id.elementAt(p2));
					float temp = object2float(w.elementAt(temp0));          
					w.set(temp0,new Float(temp + t2));
				}
             
			}
			else if (is_sparse_data && !is_binary) 
			{
				int p1=0,num1=0,p2=0,num2=0;
  
				num1 = ((sparse_vector)sparse_points.elementAt(i1)).id.size();
  
          
				for (p1=0; p1<num1; p1++)
				{
					int temp1 = object2int(((sparse_vector)sparse_points.elementAt(i1)).id.elementAt(p1));
					float temp = object2float(w.elementAt(temp1));
					float temp2 = object2float(((sparse_vector)sparse_points.elementAt(i1)).val.elementAt(p1));          	 
					w.set(temp1,new Float(temp + t1 * temp2));          	
				}
          
				num2 = ((sparse_vector)sparse_points.elementAt(i2)).id.size();
    
           
				for (p2=0; p2<num2; p2++)
				{
					int temp1 = object2int(((sparse_vector)sparse_points.elementAt(i2)).id.elementAt(p2));
					float temp = object2float(w.elementAt(temp1));
					float temp2 = object2float(((sparse_vector)sparse_points.elementAt(i2)).val.elementAt(p2));
					temp = temp + t2*temp2;
					Float value = new Float(temp);
					w.set(temp1,value);
				}
     
			}
			else
				for (int i=0; i<d; i++)
				{
					float temp = dense_points[i1][i] * t1 + dense_points[i2][i] * t2;;
					float temp1 = object2float(w.elementAt(i));
					Float value = new Float(temp + temp1);
					w.set(i,value);
				}
		}

		{
			float t1 = y1 * (a1-alph1);
			float t2 = y2 * (a2-alph2);
  
			for (int i=0; i<end_support_i; i++)
				if (0 < object2float(alph.elementAt(i)) && object2float(alph.elementAt(i)) < C)
				{  
					float tmp = object2float(error_cache.elementAt(i));
					tmp +=  t1 * kernel_func(i1,i,kernel_flag) + t2 * kernel_func(i2,i,kernel_flag)
						- delta_b;
					error_cache.set(i,new Float(tmp));
				}
			error_cache.set(i1,new Float(0));
			error_cache.set(i2,new Float(0));

		}

		alph.set(i1,new Float(a1));
		alph.set(i2,new Float(a2));

		return 1;
	}
	
	float learned_func_linear_sparse_binary(int k) 
	{
		float s = 0;
		int temp =0;
		for (int i=0; i<((sparse_binary_vector)sparse_binary_points.elementAt(k)).id.size(); i++)
  
		{
			temp =object2int(((sparse_binary_vector)sparse_binary_points.elementAt(i)).id.elementAt(i));
			s += object2float(w.elementAt(temp));
		}

		s -= b;
		return s;
	}
	
	float learned_func_linear_sparse_nonbinary(int k) 
	{
		float s = 0;

		for (int i=0; i<((sparse_vector)sparse_points.elementAt(k)).id.size(); i++)
		{
    
			int j = object2int (((sparse_vector)sparse_points.elementAt(k)).id.elementAt(i));
   
			float v = object2float (((sparse_vector)sparse_points.elementAt(k)).val.elementAt(i));
     
			s += object2float(w.elementAt(j)) * v;
		}
		s -= b;
		return s;
	}

	float learned_func_linear_dense(int k) 
	{
		float s = 0;

		for (int i=0; i<d; i++)
			s += object2float(w.elementAt(i)) * dense_points[k][i];

		s -= b;
		return s;
	}

	float learned_func_nonlinear(int k) 
	{
		float s = 0;
		for (int i=0; i<end_support_i; i++)
			if (object2float(alph.elementAt(i)) > 0)
			{   
				s += object2float(alph.elementAt(i)) * object2int(target.elementAt(i)) * kernel_func(i,k,kernel_flag);        
			}
		s -= b;
		return s;
	}

	float dot_product_sparse_binary(int i1, int i2)
	{
		int p1=0, p2=0, dot=0;
		int num1 = ((sparse_binary_vector)sparse_binary_points.elementAt(i1)).id.size();
		int num2 = ((sparse_binary_vector)sparse_binary_points.elementAt(i2)).id.size();

		while (p1 < num1 && p2 < num2) 
		{
			int a1 = object2int(((sparse_binary_vector)sparse_binary_points.elementAt(i1)).id.elementAt(p1));
			int a2 = object2int(((sparse_binary_vector)sparse_binary_points.elementAt(i2)).id.elementAt(p2));
			if (a1 == a2) 
			{
				dot++;
				p1++;
				p2++;
			}
			else if (a1 > a2)
				p2++;
			else
				p1++;
		}
		return (float)dot;
	}


	float dot_product_sparse_nonbinary(int i1, int i2)
	{
		int p1=0, p2=0;
		float dot = 0;
		int num1 = ((sparse_vector)sparse_points.elementAt(i1)).id.size();
		int num2 = ((sparse_vector)sparse_points.elementAt(i2)).id.size();
 
		while (p1 < num1 && p2 < num2) 
		{
			int a1 = object2int(((sparse_vector)sparse_points.elementAt(i1)).id.elementAt(p1));
			int a2 = object2int(((sparse_vector)sparse_points.elementAt(i2)).id.elementAt(p2));
			if (a1 == a2) 
			{
				float val1 = object2float(((sparse_vector)sparse_points.elementAt(i1)).val.elementAt(p1));
				float val2 = object2float(((sparse_vector)sparse_points.elementAt(i2)).val.elementAt(p2));
      
				dot += val1 * val2;
				p1++;
				p2++;
			}
			else if (a1 > a2)
				p2++;
			else
				p1++;
		}

		return (float)dot;
	}

	float dot_product_dense(int i1, int i2)
	{

		float dot = 0;
		for (int i=0; i<d; i++)
			dot += dense_points[i1][i] * dense_points[i2][i];
 
		return dot;
	}


	float rbf_kernel(int i1, int i2)
	{

		float s = this.precomputed_dot_product[i1][i2];
		s *= -2;
		s += object2float(precomputed_self_dot_product.elementAt(i1))
			+ object2float(precomputed_self_dot_product.elementAt(i2));
		return (float)Math.exp((float)(-s/two_sigma_squared));    
	}

	int read_data(DataInputStream is)
	{
  
		String s = new String();
		int n_lines =0;
		try
		{
			for ( n_lines=0; (s= is.readLine()) != null; n_lines++)
			{
				StringTokenizer st = new StringTokenizer(s," \t\n\r\f:"); 
				Vector v =new Vector();
				float t=0;
   
				int g=0;
				try
				{
					while (st.hasMoreTokens()) 
					{
						float tmp = Float.valueOf(st.nextToken()).floatValue();
						v.add(new Float(tmp));
						g++;
					}
				}
				catch (NumberFormatException e) 
				{
					System.err.println("Number format error " + e.toString());
				}
   
				int tar =0, n=0;
    
				if ( this.is_libsvm_file && is_sparse_data )
				{
					tar = Float.valueOf(v.firstElement().toString()).intValue();
					target.add(new Integer (tar));      
  
					if ( !this.is_binary)
					{
						if (d < Float.valueOf(v.elementAt(v.size()-2).toString()).intValue())
							d = Float.valueOf(v.elementAt(v.size()-2).toString()).intValue();
    
					}
					else
					{
						if (d < Float.valueOf(v.elementAt(v.size()-1).toString()).intValue())
							d = Float.valueOf(v.elementAt(v.size()-1).toString()).intValue();
    
					}
					v.remove(0);
					n = v.size();
				}
				else

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲丰满少妇videoshd| 天天色综合天天| 欧美精品色综合| 国产不卡视频在线播放| 亚洲国产精品一区二区久久恐怖片 | 中文无字幕一区二区三区| 色哟哟一区二区三区| 精品一区二区免费视频| 亚洲一区在线观看免费| 国产精品国产三级国产普通话99| 欧美一区二区啪啪| 欧美亚洲综合在线| 91美女在线视频| 粉嫩久久99精品久久久久久夜| 日本sm残虐另类| 亚洲一区二区三区小说| 国产精品亲子乱子伦xxxx裸| 精品国精品自拍自在线| 6080国产精品一区二区| 色婷婷综合久色| av中文字幕一区| 国产一区二区在线观看视频| 日本欧美在线看| 五月综合激情日本mⅴ| 亚洲六月丁香色婷婷综合久久| 国产丝袜在线精品| 欧美精品一区二区三区久久久| 8x8x8国产精品| 欧美日韩不卡视频| 精品污污网站免费看| 色婷婷激情久久| 99综合影院在线| av在线不卡网| 99久久久无码国产精品| 成人黄色网址在线观看| 成人毛片在线观看| av午夜精品一区二区三区| 国产传媒久久文化传媒| 国产精品91一区二区| 国产麻豆日韩欧美久久| 久久99久久久久久久久久久| 麻豆精品久久久| 久久精品99国产精品日本| 在线这里只有精品| 色哟哟一区二区| 欧美探花视频资源| 欧美日高清视频| 91精品国产91久久综合桃花| 欧美一区中文字幕| 精品剧情在线观看| 欧美激情一区二区三区在线| 中文字幕欧美一| 一区二区在线观看视频| 亚洲大片免费看| 美女性感视频久久| 国产精品99久久久久久似苏梦涵| 国产91色综合久久免费分享| 99精品欧美一区二区蜜桃免费| 色中色一区二区| 884aa四虎影成人精品一区| 欧美成人性战久久| 国产精品进线69影院| 亚洲在线免费播放| 免费成人av在线播放| 国产黄色成人av| 日本乱码高清不卡字幕| 91精品午夜视频| 国产日韩高清在线| 亚洲一区二区欧美日韩| 免播放器亚洲一区| 成人免费视频免费观看| 在线视频你懂得一区| 日韩欧美www| 国产精品国产自产拍在线| 亚洲国产成人高清精品| 国产综合久久久久影院| 色综合久久久久综合体桃花网| 欧美精品丝袜中出| 亚洲国产成人自拍| 亚州成人在线电影| 国产 欧美在线| 欧美丝袜丝nylons| 国产视频视频一区| 午夜一区二区三区视频| 国产成a人亚洲| 欧美精品日日鲁夜夜添| 亚洲国产精品激情在线观看| 无吗不卡中文字幕| 成人视屏免费看| 在线观看91av| 亚洲欧美偷拍卡通变态| 精品一区二区精品| 欧美三级欧美一级| 欧美国产亚洲另类动漫| 日韩黄色免费电影| 色综合色综合色综合色综合色综合| 欧美一级二级三级蜜桃| 亚洲欧美成aⅴ人在线观看 | 成人av集中营| 日韩精品一区二区在线观看| 亚洲免费色视频| 国产成人av电影在线播放| 欧美美女直播网站| 亚洲品质自拍视频| 国产精品1区2区3区在线观看| 91精品国产综合久久久久久久| 国产精品久久久久久妇女6080| 六月丁香婷婷久久| 欧美人与禽zozo性伦| 亚洲视频在线一区观看| 国产suv一区二区三区88区| 日韩美女天天操| 丝袜美腿亚洲一区二区图片| 一道本成人在线| 亚洲欧美在线高清| 懂色av一区二区三区蜜臀| 久久亚洲一级片| 蜜臀av一区二区在线观看 | 欧美在线综合视频| 中文字幕亚洲成人| 成人高清伦理免费影院在线观看| 精品久久五月天| 久久69国产一区二区蜜臀| 这里只有精品视频在线观看| 午夜视频久久久久久| 在线观看日韩国产| 依依成人精品视频| 色婷婷av一区二区| 专区另类欧美日韩| 一本色道久久综合亚洲91| 亚洲婷婷综合久久一本伊一区| 丁香天五香天堂综合| 中文字幕第一区第二区| 国产精品白丝jk白祙喷水网站| 久久综合色播五月| 国产91丝袜在线播放| 国产免费观看久久| 成人动漫在线一区| 亚洲视频在线一区| 欧美亚洲一区三区| 图片区日韩欧美亚洲| 91精品国产综合久久精品麻豆| 亚洲v精品v日韩v欧美v专区| 7777精品久久久大香线蕉| 日韩av不卡一区二区| 精品成人在线观看| 国产成人午夜精品影院观看视频 | 91亚洲永久精品| 夜夜爽夜夜爽精品视频| 欧美日韩精品福利| 蜜臀久久久99精品久久久久久| 日韩精品一区二区三区在线| 国产在线乱码一区二区三区| 国产欧美一区二区三区鸳鸯浴| 成年人国产精品| 亚洲制服丝袜av| 欧美一个色资源| 国产乱对白刺激视频不卡| 国产精品国产三级国产a | 精品国产免费人成在线观看| 国产伦精品一区二区三区免费 | 日韩—二三区免费观看av| 日韩欧美一二三| 国产·精品毛片| 亚洲一区在线视频观看| 日韩精品中文字幕一区二区三区| 国产乱理伦片在线观看夜一区 | 国内精品视频一区二区三区八戒| 国产欧美一区二区三区在线老狼| 97久久精品人人做人人爽50路| 亚洲成a人v欧美综合天堂| 精品va天堂亚洲国产| 不卡一区中文字幕| 日本亚洲一区二区| 中文天堂在线一区| 欧美二区在线观看| 国产成人无遮挡在线视频| 亚洲欧美视频在线观看| 日韩精品在线一区| 色综合天天综合狠狠| 麻豆精品久久精品色综合| ●精品国产综合乱码久久久久| 欧美日韩国产中文| 国产成人鲁色资源国产91色综| 亚洲国产欧美一区二区三区丁香婷| 日韩欧美二区三区| 在线亚洲免费视频| 国产呦精品一区二区三区网站| 亚洲精品久久嫩草网站秘色| 久久亚洲精华国产精华液 | 人禽交欧美网站| 亚洲欧洲日韩女同| 欧美成人伊人久久综合网| 色婷婷狠狠综合| 懂色av一区二区夜夜嗨| 美女视频一区二区三区| 亚洲中国最大av网站| 中文字幕国产一区| 精品久久国产老人久久综合| 欧美亚洲国产怡红院影院|