当前位置: 首页>>代码示例>>Java>>正文


Java FileIO.deserialize方法代码示例

本文整理汇总了Java中happy.coding.io.FileIO.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java FileIO.deserialize方法的具体用法?Java FileIO.deserialize怎么用?Java FileIO.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在happy.coding.io.FileIO的用法示例。


在下文中一共展示了FileIO.deserialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerialization

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Test
public void testSerialization() throws Exception {
	String filePath = Systems.getDesktop() + "vec.dat";

	DenseVector vec = new DenseVector(11);
	for (int i = 10, j = 0; i >= 0; i--, j++)
		vec.set(j, i);

	FileIO.serialize(vec, filePath);

	DenseVector v2 = (DenseVector) FileIO.deserialize(filePath);
	Logs.debug(v2.toString());

	DenseMatrix mat = new DenseMatrix(3, 4);
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 4; j++)
			mat.set(i, j, i + j);
	Logs.debug(mat);

	String matPath = Systems.getDesktop() + "mat.dat";
	FileIO.serialize(mat, matPath);

	DenseMatrix mat2 = (DenseMatrix) FileIO.deserialize(matPath);
	Logs.debug(mat2);

}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:27,代码来源:UnitTests.java

示例2: initModel

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Override
protected void initModel() throws Exception {
	P = new DenseMatrix(numUsers, numFactors);
	Q = new DenseMatrix(numUsers, numFactors);
	P.init(0.01);
	Q.init(0.01);

	itemBias = new DenseVector(numItems);
	itemBias.init(0.01);

	rho = cf.getInt("FISM.rho");
	alpha = cf.getDouble("FISM.alpha");

	regBeta = cf.getDouble("FISM.reg.beta");
	regGamma = cf.getDouble("FISM.reg.gamma");
	tau = cf.getDouble("FUST.trust.tau");

	flag = Debug.ON;
	numUsers = trainMatrix.numRows();
	userCorr = flag ? buildCorrs(true) : null;

	users = numUsers;
	numUsers = socialMatrix.numRows();

	String dirPath = "Results\\TrustPredictor\\";
	uFactors = (DenseMatrix) FileIO.deserialize(dirPath + "userFactors.bin");
	vFactors = (DenseMatrix) FileIO.deserialize(dirPath + "itemFactors.bin");
}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:29,代码来源:FUSTauc_backup.java

示例3: testSparseMatrix

import happy.coding.io.FileIO; //导入方法依赖的package包/类
@Test
public void testSparseMatrix() throws Exception {
	Table<Integer, Integer, Double> vals = HashBasedTable.create();
	vals.put(0, 0, 10.0);
	vals.put(0, 4, -2.0);
	vals.put(1, 0, 3.0);
	vals.put(1, 1, 9.0);
	vals.put(1, 5, 3.0);
	vals.put(2, 1, 7.0);
	vals.put(2, 2, 8.0);
	vals.put(2, 3, 7.0);
	vals.put(3, 0, 3.0);
	vals.put(3, 2, 8.0);
	vals.put(3, 3, 7.0);
	vals.put(3, 4, 5.0);
	vals.put(4, 1, 8.0);
	vals.put(4, 3, 9.0);
	vals.put(4, 4, 9.0);
	vals.put(4, 5, 13.0);
	vals.put(5, 1, 4.0);
	vals.put(5, 4, 2.0);
	vals.put(5, 5, -1.0);

	SparseMatrix A = new SparseMatrix(6, 6, vals);
	Logs.debug(A);

	String dirPath = FileIO.desktop;
	FileIO.serialize(A, dirPath + "A.mat");

	SparseMatrix A2 = (SparseMatrix) FileIO.deserialize(dirPath + "A.mat");
	Logs.debug(A2);

	SparseVector v = new SparseVector(10);
	v.set(2, 5);
	v.set(9, 10);
	Logs.debug(v);

	FileIO.serialize(v, dirPath + "v.vec");
	SparseVector v2 = (SparseVector) FileIO.deserialize(dirPath + "v.vec");
	Logs.debug(v2);

	SymmMatrix mm = new SymmMatrix(5);
	mm.set(0, 1, 0.5);
	mm.set(2, 3, 0.3);
	mm.set(4, 2, 0.8);
	Logs.debug(mm);

	FileIO.serialize(mm, dirPath + "mm.mat");
	SymmMatrix mm2 = (SymmMatrix) FileIO.deserialize(dirPath + "mm.mat");
	Logs.debug(mm2);

}
 
开发者ID:466152112,项目名称:HappyResearch,代码行数:53,代码来源:UnitTests.java


注:本文中的happy.coding.io.FileIO.deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。