Package org.gd.spark.opendl.downpourSGD.Softmax

Examples of org.gd.spark.opendl.downpourSGD.Softmax.LR


      JavaSparkContext context = SparkContextBuild.getContext(args);
      JavaRDD<SampleVector> rdds = context.parallelize(trainList);
      rdds.count();
      logger.info("RDD ok.");
     
      LR lr = new LR(x_feature, y_feature);
            SGDTrainConfig config = new SGDTrainConfig();
            config.setUseCG(true);
            config.setCgEpochStep(100);
            config.setCgTolerance(0);
            config.setCgMaxIterations(30);
            config.setMaxEpochs(100);
            config.setNbrModelReplica(4);
            config.setMinLoss(0.01);
            config.setUseRegularization(true);
            config.setMrDataStorage(StorageLevel.MEMORY_ONLY());
            config.setPrintLoss(true);
            config.setLossCalStep(3);
            config.setParamOutput(true);
            config.setParamOutputStep(3);
            config.setParamOutputPath("wb.bin");
           
            logger.info("Start to train lr.");
            DownpourSGDTrain.train(lr, rdds, config);
           
            int trueCount = 0;
            int falseCount = 0;
            double[] predict_y = new double[y_feature];
            for(SampleVector test : testList) {
              lr.predict(test.getX(), predict_y);
              if(ClassVerify.classTrue(test.getY(), predict_y)) {
                trueCount++;
              }
              else {
                falseCount++;
View Full Code Here


     
      List<SampleVector> trainList = new ArrayList<SampleVector>();
      List<SampleVector> testList = new ArrayList<SampleVector>();
      DataInput.splitList(samples, trainList, testList, 0.7);
     
      LR lr = new LR(x_feature, y_feature);
            SGDTrainConfig config = new SGDTrainConfig();
            config.setUseCG(true);
            config.setCgEpochStep(100);
            config.setCgTolerance(0);
            config.setCgMaxIterations(30);
            config.setMaxEpochs(100);
            config.setNbrModelReplica(4);
            config.setMinLoss(0.01);
            config.setUseRegularization(true);
            config.setPrintLoss(true);
           
            logger.info("Start to train lr.");
            DownpourSGDTrain.train(lr, trainList, config);
           
            int trueCount = 0;
            int falseCount = 0;
            double[] predict_y = new double[y_feature];
            for(SampleVector test : testList) {
              lr.predict(test.getX(), predict_y);
              if(ClassVerify.classTrue(test.getY(), predict_y)) {
                trueCount++;
              }
              else {
                falseCount++;
View Full Code Here

TOP

Related Classes of org.gd.spark.opendl.downpourSGD.Softmax.LR

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.