當前位置: 首頁>>代碼示例>>Java>>正文


Java DenseVector類代碼示例

本文整理匯總了Java中it.uniroma2.sag.kelp.data.representation.vector.DenseVector的典型用法代碼示例。如果您正苦於以下問題:Java DenseVector類的具體用法?Java DenseVector怎麽用?Java DenseVector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DenseVector類屬於it.uniroma2.sag.kelp.data.representation.vector包,在下文中一共展示了DenseVector類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCopyDense

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testCopyDense() {
	DenseVector aVector = (DenseVector) a.getRepresentation(denseName);
	DenseVector copyVector = aVector.copyVector();
	DenseVector copy = (DenseVector) copyVector;
	
	Assert.assertEquals(aVector.getTextFromData(), copy.getTextFromData());
	Assert.assertNotSame(copy, aVector);
	
	DenseMatrix64F featureValuesOIrig = aVector.getFeatureValues();
	DenseMatrix64F featureValuesCopy = copy.getFeatureValues();
	
	Assert.assertEquals(featureValuesOIrig.numCols, featureValuesCopy.numCols);
	Assert.assertEquals(featureValuesOIrig.numRows, featureValuesCopy.numRows);
	
	for (int i=0; i<featureValuesCopy.data.length; ++i) {
		Assert.assertEquals(featureValuesOIrig.data[i], featureValuesCopy.data[i], 0.000000001f);
	}
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:20,代碼來源:VectorsTest.java

示例2: testDenseStandardization

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testDenseStandardization() {
	StandardizationManipulator standardizer = new StandardizationManipulator(denseName, dataset.getExamples());
	dataset.manipulate(standardizer);
	DenseVector vector = new DenseVector();
	try {
		vector.setDataFromText("0.9999999701976776,-1.154700552067176,0");
		DenseVector vecA = (DenseVector) dataset.getExample(0).getRepresentation(denseName);
		vector.add(-1, vecA);
		Assert.assertTrue(vector.getSquaredNorm() < 0.0001f);
		vector.setDataFromText("-1.0000000298023224,0.5773502244144524,0");
		DenseVector vecB = (DenseVector) dataset.getExample(1).getRepresentation(denseName);
		vector.add(-1, vecB);
		Assert.assertTrue(vector.getSquaredNorm() < 0.0001f);
		vector.setDataFromText("-2.9802322387695312E-8,0.5773502244144524,0");
		DenseVector vecC = (DenseVector) dataset.getExample(2).getRepresentation(denseName);
		vector.add(-1, vecC);
		Assert.assertTrue(vector.getSquaredNorm() < 0.0001f);
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail();
	}
	Assert.assertTrue(true);
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:25,代碼來源:VectorStandardizationTest.java

示例3: testDenseSum

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testDenseSum() {
	DenseVector aVector = (DenseVector) a.getRepresentation(denseName);
	DenseVector bVector = (DenseVector) b.getRepresentation(denseName);
	
	aVector.add(bVector);
	
	Assert.assertEquals(1.0f, aVector.getFeatureValue(0), 0.0001f);
	Assert.assertEquals(1.0f, aVector.getFeatureValue(1), 0.0001f);
	Assert.assertEquals(2.0f, aVector.getFeatureValue(2), 0.0001f);	
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:12,代碼來源:VectorsTest.java

示例4: testDenseSumWithCoefficient

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testDenseSumWithCoefficient() {
	DenseVector aVector = (DenseVector) a.getRepresentation(denseName);
	DenseVector bVector = (DenseVector) b.getRepresentation(denseName);
	
	aVector.add(2.0f, bVector);
	
	Assert.assertEquals(1.0f, aVector.getFeatureValue(0), 0.0001f);
	Assert.assertEquals(2.0f, aVector.getFeatureValue(1), 0.0001f);
	Assert.assertEquals(3.0f, aVector.getFeatureValue(2), 0.0001f);	
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:12,代碼來源:VectorsTest.java

示例5: testDensePointWiseProduct

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testDensePointWiseProduct() {
	DenseVector aVector = (DenseVector) a.getRepresentation(denseName);
	DenseVector bVector = (DenseVector) b.getRepresentation(denseName);
	
	aVector.pointWiseProduct(bVector);
	
	Assert.assertEquals(0.0f, aVector.getFeatureValue(0), 0.0001f);
	Assert.assertEquals(0.0f, aVector.getFeatureValue(1), 0.0001f);
	Assert.assertEquals(1.0f, aVector.getFeatureValue(2), 0.0001f);
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:12,代碼來源:VectorsTest.java

示例6: testDenseInnerProduct

import it.uniroma2.sag.kelp.data.representation.vector.DenseVector; //導入依賴的package包/類
@Test
public void testDenseInnerProduct() {
	DenseVector aVector = (DenseVector) a.getRepresentation(denseName);
	DenseVector bVector = (DenseVector) b.getRepresentation(denseName);
	
	float innerProduct = aVector.innerProduct(bVector);
	
	Assert.assertEquals(1.0f, innerProduct, 0.000001f);
}
 
開發者ID:SAG-KeLP-Legacy,項目名稱:kelp-full,代碼行數:10,代碼來源:VectorsTest.java


注:本文中的it.uniroma2.sag.kelp.data.representation.vector.DenseVector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。