Package org.encog.persist

Examples of org.encog.persist.EncogFileSection


   */
  @Override
  public Object read(final InputStream is) {
    final SVM result = new SVM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("SVM-PARAM")) {
        final Map<String, String> params = section.parseParams();
        result.setInputCount(EncogFileSection.parseInt(params,
            PersistConst.INPUT_COUNT));
        result.getParams().C = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_C);
        result.getParams().cache_size = EncogFileSection.parseDouble(
            params, PersistSVM.PARAM_CACHE_SIZE);
        result.getParams().coef0 = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_COEF0);
        result.getParams().degree = EncogFileSection.parseInt(params,
            PersistSVM.PARAM_DEGREE);
        result.getParams().eps = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_EPS);
        result.getParams().gamma = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_GAMMA);
        result.getParams().kernel_type = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_KERNEL_TYPE);
        result.getParams().nr_weight = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_NUM_WEIGHT);
        result.getParams().nu = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_NU);
        result.getParams().p = EncogFileSection.parseDouble(params,
            PersistSVM.PARAM_P);
        result.getParams().probability = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_PROBABILITY);
        result.getParams().shrinking = EncogFileSection.parseInt(
            params, PersistSVM.PARAM_SHRINKING);
        result.getParams().svm_type = EncogFileSection.parseInt(params,
            PersistSVM.PARAM_SVM_TYPE);
        result.getParams().weight = section.parseDoubleArray(
            params, PersistSVM.PARAM_WEIGHT);
        result.getParams().weight_label = EncogFileSection
            .parseIntArray(params, PersistSVM.PARAM_WEIGHT_LABEL);
      } else if (section.getSectionName().equals("SVM")
          && section.getSubSectionName().equals("SVM-MODEL")) {
        try {
          final StringReader rdr = new StringReader(
              section.getLinesAsString());
          final BufferedReader br = new BufferedReader(rdr);
          final svm_model model = svm.svm_load_model(br);
          result.setModel(model);
          br.close();
          rdr.close();
View Full Code Here


    double min=0;
    double max=0;
    Map<String, String> objParams=null;
    BasicUniverse result = null;
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BasicUniverse")
          && section.getSubSectionName().equals("PARAMS")) {
        objParams = section.parseParams();       
      }
      if (section.getSectionName().equals("BasicUniverse")
          && section.getSubSectionName().equals("UNIVERSE-PARAM")) {
        final Map<String, String> params = section.parseParams();
        cols = EncogFileSection.parseInt(params,PersistConst.COLS);
        rows = EncogFileSection.parseInt(params,PersistConst.ROWS);       
      } else if (section.getSectionName().equals("BasicUniverse")
          && section.getSubSectionName().equals("UNIVERSE-CELLS")) {
        final Map<String, String> params = section.parseParams();
        min = EncogFileSection.parseDouble(params,PersistConst.MIN);
        max = EncogFileSection.parseDouble(params,PersistConst.MAX);
        elementCount = EncogFileSection.parseInt(params,BasicUniverse.ELEMENT_COUNT);
        size = EncogFileSection.parseInt(params,PersistConst.SIZE);
       
      } else if (section.getSectionName().equals("BasicUniverse")
          && section.getSubSectionName().equals("UNIVERSE")) {
       
        // first create the universe
        BasicCellFactory factory;
       
        if( elementCount==-1 ) {
          factory = new BasicCellFactory(size,min,max);
        } else {
          factory = new BasicCellFactory(size,elementCount);
        }
       
        result = new BasicUniverse(rows,cols,factory);
        result.getProperties().putAll(objParams);
       
        // now fill the universe
        int ec = 1;
        if( elementCount!=-1 ) {
          ec = elementCount;
        }
        int row = 0;
        for(String line : section.getLines() ) {
          double[] d = NumberList.fromList(CSVFormat.EG_FORMAT, line);
          int idx = 0;
          for(int col=0;col<cols;col++) {
            UniverseCell cell = result.get(row, col);
            for(int i=0;i<size;i++) {
View Full Code Here

TOP

Related Classes of org.encog.persist.EncogFileSection

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.