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")) { for(String line : section.getLines() ) { double[] d = NumberList.fromList(CSVFormat.EG_FORMAT, line); int idx = 0;
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,
private void loadOpcodes(EncogFileSection section) { boolean first = true; for (final String line : section.getLines()) { if (!first) { final List<String> cols = EncogFileSection.splitColumns(line); final String name = cols.get(0); final int childCount = Integer.parseInt(cols.get(1)); ScriptOpcode opcode = new ScriptOpcode(name, childCount); this.script.getOpcodes().add(opcode); } else { first = false; } } }
/** * Load a generic subsection. * * @param section * The section to load from. */ private void loadSubSection(final EncogFileSection section) { final Map<String, String> prop = section.parseParams(); for (final String name : prop.keySet()) { final String key = section.getSectionName().toUpperCase() + ":" + section.getSubSectionName().toUpperCase() + "_" + name; String value = prop.get(name); if (value == null) { value = ""; } validateProperty(section.getSectionName(), section.getSubSectionName(), name, value); this.script.getProperties().setProperty(key, value); } }
/** * {@inheritDoc} */ @Override public Object read(final InputStream is) { final SOM result = new SOM(); final EncogReadHelper in = new EncogReadHelper(is); EncogFileSection section; while ((section = in.readNextSection()) != null) { if (section.getSectionName().equals("SOM") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); } if (section.getSectionName().equals("SOM") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); result.setWeights(EncogFileSection.parseMatrix(params, PersistConst.WEIGHTS)); } } return result; }
EncogFileSection section; while((section = in.readNextSection()) != null) { if(section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); if(section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); flat.setBeginTraining(EncogFileSection.parseInt(params, BasicNetwork.TAG_BEGIN_TRAINING)); flat.setConnectionLimit(EncogFileSection.parseDouble(params, BasicNetwork.TAG_CONNECTION_LIMIT)); flat.setContextTargetOffset(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_CONTEXT_TARGET_OFFSET)); flat.setContextTargetSize(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_CONTEXT_TARGET_SIZE)); flat.setEndTraining(EncogFileSection.parseInt(params, BasicNetwork.TAG_END_TRAINING)); flat.setHasContext(EncogFileSection.parseBoolean(params, BasicNetwork.TAG_HAS_CONTEXT)); flat.setInputCount(EncogFileSection.parseInt(params, PersistConst.INPUT_COUNT)); flat.setLayerCounts(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_COUNTS)); flat.setLayerFeedCounts(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_FEED_COUNTS)); flat.setLayerContextCount(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_CONTEXT_COUNT)); flat.setLayerIndex(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_INDEX)); flat.setLayerOutput(EncogFileSection.parseDoubleArray(params, PersistConst.OUTPUT)); flat.setLayerSums(new double[flat.getLayerOutput().length]); flat.setOutputCount(EncogFileSection.parseInt(params, PersistConst.OUTPUT_COUNT)); flat.setWeightIndex(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_WEIGHT_INDEX)); flat.setWeights(EncogFileSection.parseDoubleArray(params, PersistConst.WEIGHTS)); flat.setBiasActivation(EncogFileSection.parseDoubleArray(params, BasicNetwork.TAG_BIAS_ACTIVATION)); } else if(section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("ACTIVATION")) { int index = 0;
if (section.getSectionName().equals("NEAT-POPULATION") && section.getSubSectionName().equals("INNOVATIONS")) { for (final String line : section.getLines()) { final List<String> cols = EncogFileSection .splitColumns(line); final NEATInnovation innovation = new NEATInnovation(); final int innovationID = Integer.parseInt(cols.get(1)); } else if (section.getSectionName().equals("NEAT-POPULATION") && section.getSubSectionName().equals("SPECIES")) { NEATGenome lastGenome = null; BasicSpecies lastSpecies = null; for (final String line : section.getLines()) { final List<String> cols = EncogFileSection .splitColumns(line); .parseActivationFunction(cols.get(2)); neuronGene.setActivationFunction(af); } else if (section.getSectionName().equals("NEAT-POPULATION") && section.getSubSectionName().equals("CONFIG")) { final Map<String, String> params = section.parseParams(); } else { result.setNEATActivationFunction(EncogFileSection .parseActivationFunction(params, NEATPopulation.PROPERTY_NEAT_ACTIVATION));
if (section.getSectionName().equals("HMM") && section.getSubSectionName().equals("PARAMS")) { properties = section.parseParams(); if (section.getSectionName().equals("HMM") && section.getSubSectionName().equals("CONFIG")) { final Map<String, String> params = section.parseParams(); states = EncogFileSection.parseInt(params, HiddenMarkovModel.TAG_STATES); items = EncogFileSection.parseIntArray(params, HiddenMarkovModel.TAG_ITEMS); pi = section.parseDoubleArray(params, HiddenMarkovModel.TAG_PI); transitionProbability = section.parseMatrix(params, HiddenMarkovModel.TAG_TRANSITION); } else if (section.getSectionName().equals("HMM") && section.getSubSectionName().startsWith("DISTRIBUTION-")) { final Map<String, String> params = section.parseParams(); String t = params.get(HiddenMarkovModel.TAG_DIST_TYPE); if( "ContinousDistribution".equals(t) ) { double[] mean = section.parseDoubleArray(params, HiddenMarkovModel.TAG_MEAN); Matrix cova = section.parseMatrix(params, HiddenMarkovModel.TAG_COVARIANCE); ContinousDistribution dist = new ContinousDistribution(mean,cova.getData()); distributions.add(dist); } else if( "DiscreteDistribution".equals(t) ) { Matrix prob = section.parseMatrix(params, HiddenMarkovModel.TAG_PROBABILITIES); DiscreteDistribution dist = new DiscreteDistribution(prob.getData()); distributions.add(dist);
/** * {@inheritDoc} */ @Override public Object read(final InputStream is) { final HopfieldNetwork result = new HopfieldNetwork(); final EncogReadHelper in = new EncogReadHelper(is); EncogFileSection section; while ((section = in.readNextSection()) != null) { if (section.getSectionName().equals("HOPFIELD") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); } if (section.getSectionName().equals("HOPFIELD") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); result.setWeights(section.parseDoubleArray(params, PersistConst.WEIGHTS)); result.setCurrentState(section.parseDoubleArray(params, PersistConst.OUTPUT)); result.setNeuronCount(EncogFileSection.parseInt(params, PersistConst.NEURON_COUNT)); } } return result; }
if (section.getSectionName().equals("BAYES-NETWORK") && section.getSubSectionName().equals("BAYES-PARAM")) { final Map<String, String> params = section.parseParams(); queryType = params.get("queryType"); queryStr = params.get("query"); contentsStr = params.get("contents"); if (section.getSectionName().equals("BAYES-NETWORK") && section.getSubSectionName().equals("BAYES-TABLE")) { for (String line : section.getLines()) { result.defineRelationship(line); for (String line : section.getLines()) { result.defineProbability(line); if (section.getSectionName().equals("BAYES-NETWORK") && section.getSubSectionName().equals("BAYES-PROPERTIES")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params);
/** * Handle loading a task. * * @param section * The section. */ private void handleTask(final EncogFileSection section) { final AnalystTask task = new AnalystTask(section.getSubSectionName()); for (final String line : section.getLines()) { task.getLines().add(line); } this.script.addTask(task); }
this.section = new EncogFileSection( this.currentSectionName, this.currentSubSectionName); this.section.getLines().addAll(this.lines); this.section.setLargeArrays(largeArrays); return this.section; } else if (line.length() < 1) { this.section = new EncogFileSection(this.currentSectionName, this.currentSubSectionName); this.section.getLines().addAll(this.lines); this.currentSectionName = ""; this.currentSubSectionName = ""; this.section.setLargeArrays(largeArrays); return this.section; } catch (final IOException ex) {
final String currentSection = section.getSectionName(); final String currentSubsection = section.getSubSectionName();
/** * Handle loading the filenames. * * @param section * The section being loaded. */ private void handleFilenames(final EncogFileSection section) { final Map<String, String> prop = section.parseParams(); this.script.getProperties().clearFilenames(); for (final Entry<String, String> e : prop.entrySet()) { this.script.getProperties().setFilename(e.getKey(), e.getValue()); } }
if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); flat.setBeginTraining(EncogFileSection.parseInt(params, BasicNetwork.TAG_BEGIN_TRAINING)); flat.setConnectionLimit(EncogFileSection.parseDouble(params, BasicNetwork.TAG_CONNECTION_LIMIT)); flat.setContextTargetOffset(EncogFileSection.parseIntArray( params, BasicNetwork.TAG_CONTEXT_TARGET_OFFSET)); flat.setContextTargetSize(EncogFileSection.parseIntArray( params, BasicNetwork.TAG_CONTEXT_TARGET_SIZE)); flat.setEndTraining(EncogFileSection.parseInt(params, BasicNetwork.TAG_END_TRAINING)); flat.setHasContext(EncogFileSection.parseBoolean(params, BasicNetwork.TAG_HAS_CONTEXT)); flat.setInputCount(EncogFileSection.parseInt(params, PersistConst.INPUT_COUNT)); flat.setLayerCounts(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_COUNTS)); flat.setLayerFeedCounts(EncogFileSection.parseIntArray(params, BasicNetwork.TAG_LAYER_FEED_COUNTS)); flat.setLayerContextCount(EncogFileSection.parseIntArray( params, BasicNetwork.TAG_LAYER_CONTEXT_COUNT));
/** * {@inheritDoc} */ @Override public Object read(final InputStream is) { final TrainingContinuation result = new TrainingContinuation(); final EncogReadHelper in = new EncogReadHelper(is); EncogFileSection section; while ((section = in.readNextSection()) != null) { if (section.getSectionName().equals("CONT") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); for (final String key : params.keySet()) { if (key.equalsIgnoreCase("type")) { result.setTrainingType(params.get(key)); } else { final double[] list = section .parseDoubleArray(params, key); result.put(key, list); } } } } return result; }
Species lastSpecies = null; while ((section = in.readNextSection()) != null) { if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); } else if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("EPL-POPULATION")) { for (final String line : section.getLines()) { final List<String> cols = EncogFileSection .splitColumns(line); } else if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("EPL-OPCODES")) { for (final String line : section.getLines()) { final List<String> cols = EncogFileSection .splitColumns(line); final String name = cols.get(0); final int args = Integer.parseInt(cols.get(1)); result.getContext().getFunctions().addExtension(name, args); } else if (section.getSectionName().equals("BASIC") && section.getSubSectionName().equals("EPL-SYMBOLIC")) { boolean first = true; for (final String line : section.getLines()) { if (!first) { final List<String> cols = EncogFileSection .splitColumns(line); final String name = cols.get(0);
if (section.getSectionName().equals("PNN") && section.getSubSectionName().equals("PARAMS")) { networkParams = section.parseParams(); if (section.getSectionName().equals("PNN") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); inputCount = EncogFileSection.parseInt(params, PersistConst.INPUT_COUNT); outputCount = EncogFileSection.parseInt(params, PersistConst.OUTPUT_COUNT); kernel = PersistBasicPNN.stringToKernel(params .get(PersistBasicPNN.PROPERTY_outputMode)); error = EncogFileSection .parseDouble(params, PersistConst.ERROR); sigma = section.parseDoubleArray(params, PersistConst.SIGMA); if (section.getSectionName().equals("PNN") && section.getSubSectionName().equals("SAMPLES")) { for (final String line : section.getLines()) { final List<String> cols = EncogFileSection .splitColumns(line); int index = 0; final MLData inputData = new BasicMLData(inputCount);
/** * {@inheritDoc} */ @Override public Object read(final InputStream is) { final BAM result = new BAM(); final EncogReadHelper in = new EncogReadHelper(is); EncogFileSection section; while ((section = in.readNextSection()) != null) { if (section.getSectionName().equals("BAM") && section.getSubSectionName().equals("PARAMS")) { final Map<String, String> params = section.parseParams(); result.getProperties().putAll(params); } if (section.getSectionName().equals("BAM") && section.getSubSectionName().equals("NETWORK")) { final Map<String, String> params = section.parseParams(); result.setF1Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F1_COUNT)); result.setF2Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F2_COUNT)); result.setWeightsF1toF2(EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F1_F2)); result.setWeightsF2toF1(EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F2_F1)); } } return result; }
private void handleProcessFields(final EncogFileSection section) { List<ProcessField> fields = this.script.getProcess().getFields(); boolean first = true; fields.clear(); for (final String line : section.getLines()) { if (!first) { final List<String> cols = EncogFileSection.splitColumns(line); final String name = cols.get(0); final String command = cols.get(1); final ProcessField pf = new ProcessField(name, command); fields.add(pf); } else { first = false; } } }