use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelMergeAndConvert method convertModel.
private static void convertModel(Configuration conf, String modelInputDir, String convertedModelDir, MatrixFilesMeta meta, ModelLineConvert lineConvert) throws IOException {
Path outputFile = new Path(convertedModelDir, dataFile);
FileSystem fs = outputFile.getFileSystem(conf);
FSDataOutputStream output = fs.create(outputFile);
convertHeader(meta, output);
RowType rowType = RowType.valueOf(meta.getRowType());
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_DENSE_COMPONENT:
{
convertDenseDoubleModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_DOUBLE_SPARSE:
case T_DOUBLE_SPARSE_COMPONENT:
{
convertSparseDoubleModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_DOUBLE_SPARSE_LONGKEY:
case T_DOUBLE_SPARSE_LONGKEY_COMPONENT:
{
convertSparseDoubleLongKeyModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_FLOAT_DENSE:
case T_FLOAT_DENSE_COMPONENT:
{
convertDenseFloatModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_FLOAT_SPARSE:
case T_FLOAT_SPARSE_COMPONENT:
{
convertSparseFloatModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_INT_DENSE:
case T_INT_DENSE_COMPONENT:
{
convertDenseIntModel(conf, output, modelInputDir, lineConvert);
break;
}
case T_INT_SPARSE:
case T_INT_SPARSE_COMPONENT:
{
convertSparseIntModel(conf, output, modelInputDir, lineConvert);
break;
}
}
output.close();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToIntMaps.
/**
* Load dense double model to int->int maps
*
* @param modelDir model save directory path
* @return model data
*/
public static Int2IntOpenHashMap[] loadToIntMaps(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_INT_SPARSE && rowType != RowType.T_INT_SPARSE_COMPONENT) {
throw new IOException("model row type is not sparse int, you should check it");
}
// Load model
SparseIntModel model = new SparseIntModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToDoubleArrays.
/**
* Load dense double model to a 2-dimension double array
*
* @param modelDir model save directory path
* @return model data
*/
public static double[][] loadToDoubleArrays(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_DOUBLE_DENSE && rowType != RowType.T_DOUBLE_DENSE_COMPONENT) {
throw new IOException("model row type is not dense double, you should check it");
}
// Load model
DenseDoubleModel model = new DenseDoubleModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToDoubleMaps.
/**
* Load dense double model to int->double maps
*
* @param modelDir model save directory path
* @return model data
*/
public static Int2DoubleOpenHashMap[] loadToDoubleMaps(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_DOUBLE_SPARSE && rowType != RowType.T_DOUBLE_SPARSE_COMPONENT) {
throw new IOException("model row type is not sparse double, you should check it");
}
// Load model
SparseDoubleModel model = new SparseDoubleModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToIntArrays.
/**
* Load dense float model to a 2-dimension int array
*
* @param modelDir model save directory path
* @return model data
*/
public static int[][] loadToIntArrays(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_INT_DENSE && rowType != RowType.T_INT_DENSE_COMPONENT) {
throw new IOException("model row type is not dense int, you should check it");
}
// Load model
DenseIntModel model = new DenseIntModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
Aggregations