Search in sources :

Example 1 with LR

use of ml.shifu.shifu.core.LR in project shifu by ShifuML.

the class LogisticRegressionMaster method initOrRecoverParams.

private LogisticRegressionParams initOrRecoverParams(MasterContext<LogisticRegressionParams, LogisticRegressionParams> context) {
    LOG.info("read from existing model");
    LogisticRegressionParams params = null;
    // read existing model weights
    try {
        Path modelPath = new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
        LR existingModel = (LR) ModelSpecLoaderUtils.loadModel(modelConfig, modelPath, ShifuFileUtils.getFileSystemBySourceType(this.modelConfig.getDataSet().getSource()));
        if (existingModel == null) {
            params = initWeights();
            LOG.info("Starting to train model from scratch.");
        } else {
            params = initModelParams(existingModel);
            LOG.info("Starting to train model from existing model {}.", modelPath);
        }
    } catch (IOException e) {
        throw new GuaguaRuntimeException(e);
    }
    return params;
}
Also used : Path(org.apache.hadoop.fs.Path) LR(ml.shifu.shifu.core.LR) IOException(java.io.IOException) GuaguaRuntimeException(ml.shifu.guagua.GuaguaRuntimeException)

Aggregations

IOException (java.io.IOException)1 GuaguaRuntimeException (ml.shifu.guagua.GuaguaRuntimeException)1 LR (ml.shifu.shifu.core.LR)1 Path (org.apache.hadoop.fs.Path)1