Package org.encog.persist

Examples of org.encog.persist.EncogWriteHelper


  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final TrainingContinuation cont = (TrainingContinuation) obj;
    out.addSection("CONT");
    out.addSubSection("PARAMS");
    out.writeProperty("type", cont.getTrainingType());
    for (final String key : cont.getContents().keySet()) {
      final double[] list = (double[]) cont.get(key);
      out.writeProperty(key, list);
    }
    out.flush();
  }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final BasicNetwork net = (BasicNetwork) obj;
    final FlatNetwork flat = net.getStructure().getFlat();
    out.addSection("BASIC");
    out.addSubSection("PARAMS");
    out.addProperties(net.getProperties());
    out.addSubSection("NETWORK");

    out.writeProperty(BasicNetwork.TAG_BEGIN_TRAINING,
        flat.getBeginTraining());
    out.writeProperty(BasicNetwork.TAG_CONNECTION_LIMIT,
        flat.getConnectionLimit());
    out.writeProperty(BasicNetwork.TAG_CONTEXT_TARGET_OFFSET,
        flat.getContextTargetOffset());
    out.writeProperty(BasicNetwork.TAG_CONTEXT_TARGET_SIZE,
        flat.getContextTargetSize());
    out.writeProperty(BasicNetwork.TAG_END_TRAINING, flat.getEndTraining());
    out.writeProperty(BasicNetwork.TAG_HAS_CONTEXT, flat.getHasContext());
    out.writeProperty(PersistConst.INPUT_COUNT, flat.getInputCount());
    out.writeProperty(BasicNetwork.TAG_LAYER_COUNTS, flat.getLayerCounts());
    out.writeProperty(BasicNetwork.TAG_LAYER_FEED_COUNTS,
        flat.getLayerFeedCounts());
    out.writeProperty(BasicNetwork.TAG_LAYER_CONTEXT_COUNT,
        flat.getLayerContextCount());
    out.writeProperty(BasicNetwork.TAG_LAYER_INDEX, flat.getLayerIndex());
    out.writeProperty(PersistConst.OUTPUT, flat.getLayerOutput());
    out.writeProperty(PersistConst.OUTPUT_COUNT, flat.getOutputCount());
    out.writeProperty(BasicNetwork.TAG_WEIGHT_INDEX, flat.getWeightIndex());
    out.writeProperty(PersistConst.WEIGHTS, flat.getWeights());
    out.writeProperty(BasicNetwork.TAG_BIAS_ACTIVATION,
        flat.getBiasActivation());
    out.addSubSection("ACTIVATION");
    for (final ActivationFunction af : flat.getActivationFunctions()) {
      out.addColumn(af.getClass().getSimpleName());
      for (int i = 0; i < af.getParams().length; i++) {
        out.addColumn(af.getParams()[i]);
      }
      out.writeLine();
    }

    out.flush();
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final CPN cpn = (CPN) obj;
    out.addSection("CPN");
    out.addSubSection("PARAMS");
    out.addProperties(cpn.getProperties());
    out.addSubSection("NETWORK");

    out.writeProperty(PersistConst.INPUT_COUNT, cpn.getInputCount());
    out.writeProperty(PersistConst.INSTAR, cpn.getInstarCount());
    out.writeProperty(PersistConst.OUTPUT_COUNT, cpn.getOutputCount());
    out.writeProperty(PersistCPN.PROPERTY_inputToInstar,
        cpn.getWeightsInputToInstar());
    out.writeProperty(PersistCPN.PROPERTY_instarToInput,
        cpn.getWeightsInstarToOutstar());
    out.writeProperty(PersistCPN.PROPERTY_winnerCount,
        cpn.getWinnerCount());

    out.flush();
  }
View Full Code Here

    return result;
  }

  @Override
  public void save(OutputStream os, Object obj) {
    EncogWriteHelper out = new EncogWriteHelper(os);
    NEATNetwork neat = (NEATNetwork)obj;
    out.addSection("NEAT");
    out.addSubSection("PARAMS");
    out.addProperties(neat.getProperties());
    out.addSubSection("NETWORK");
   
    out.writeProperty(PersistConst.INPUT_COUNT, neat.getInputCount());
    out.writeProperty(PersistConst.OUTPUT_COUNT, neat.getOutputCount());
    out.writeProperty(PersistConst.ACTIVATION_FUNCTION, neat.getActivationFunction());
    out.writeProperty(NEATPopulation.PROPERTY_OUTPUT_ACTIVATION, neat.getOutputActivationFunction());
    out.writeProperty(PersistConst.DEPTH, neat.getNetworkDepth());
    out.writeProperty(PersistConst.SNAPSHOT, neat.isSnapshot());
   
    out.addSubSection("NEURONS");
    for (NEATNeuron neatNeuron : neat.getNeurons() ) {
      out.addColumn(neatNeuron.getNeuronID());
      out.addColumn(PersistNEATPopulation.neuronTypeToString(neatNeuron.getNeuronType()));
      out.addColumn(neatNeuron.getActivationResponse());
      out.addColumn(neatNeuron.getSplitX());
      out.addColumn(neatNeuron.getSplitY());
      out.writeLine();
    }
   
    out.addSubSection("LINKS");
    for (NEATNeuron neatNeuron : neat.getNeurons() ) {
           
      for(NEATLink link: neatNeuron.getOutputboundLinks() ) {
        writeLink(out,link);
      }     
    }
   
    out.flush();
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final HopfieldNetwork hopfield = (HopfieldNetwork) obj;
    out.addSection("HOPFIELD");
    out.addSubSection("PARAMS");
    out.addProperties(hopfield.getProperties());
    out.addSubSection("NETWORK");
    out.writeProperty(PersistConst.WEIGHTS, hopfield.getWeights());
    out.writeProperty(PersistConst.OUTPUT, hopfield.getCurrentState()
        .getData());
    out.writeProperty(PersistConst.NEURON_COUNT, hopfield.getNeuronCount());
    out.flush();
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final BAM bam = (BAM) obj;
    out.addSection("BAM");
    out.addSubSection("PARAMS");
    out.addProperties(bam.getProperties());
    out.addSubSection("NETWORK");

    out.writeProperty(PersistConst.PROPERTY_F1_COUNT, bam.getF1Count());
    out.writeProperty(PersistConst.PROPERTY_F2_COUNT, bam.getF2Count());
    out.writeProperty(PersistConst.PROPERTY_WEIGHTS_F1_F2,
        bam.getWeightsF1toF2());
    out.writeProperty(PersistConst.PROPERTY_WEIGHTS_F2_F1,
        bam.getWeightsF2toF1());

    out.flush();

  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final BoltzmannMachine boltz = (BoltzmannMachine) obj;
    out.addSection("BOLTZMANN");
    out.addSubSection("PARAMS");
    out.addProperties(boltz.getProperties());
    out.addSubSection("NETWORK");
    out.writeProperty(PersistConst.WEIGHTS, boltz.getWeights());
    out.writeProperty(PersistConst.OUTPUT, boltz.getCurrentState()
        .getData());
    out.writeProperty(PersistConst.NEURON_COUNT, boltz.getNeuronCount());

    out.writeProperty(PersistConst.THRESHOLDS, boltz.getThreshold());
    out.writeProperty(BoltzmannMachine.ANNEAL_CYCLES,
        boltz.getAnnealCycles());
    out.writeProperty(BoltzmannMachine.RUN_CYCLES, boltz.getRunCycles());
    out.writeProperty(PersistConst.TEMPERATURE, boltz.getTemperature());

    out.flush();

  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final ART1 art1 = (ART1) obj;
    out.addSection("ART1");
    out.addSubSection("PARAMS");
    out.addProperties(art1.getProperties());
    out.addSubSection("NETWORK");

    out.writeProperty(ART.PROPERTY_A1, art1.getA1());
    out.writeProperty(ART.PROPERTY_B1, art1.getB1());
    out.writeProperty(ART.PROPERTY_C1, art1.getC1());
    out.writeProperty(ART.PROPERTY_D1, art1.getD1());
    out.writeProperty(PersistConst.PROPERTY_F1_COUNT, art1.getF1Count());
    out.writeProperty(PersistConst.PROPERTY_F2_COUNT, art1.getF2Count());
    out.writeProperty(ART.PROPERTY_NO_WINNER, art1.getNoWinner());
    out.writeProperty(ART.PROPERTY_L, art1.getL());
    out.writeProperty(ART.PROPERTY_VIGILANCE, art1.getVigilance());
    out.writeProperty(PersistConst.PROPERTY_WEIGHTS_F1_F2,
        art1.getWeightsF1toF2());
    out.writeProperty(PersistConst.PROPERTY_WEIGHTS_F2_F1,
        art1.getWeightsF2toF1());

    out.flush();

  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void save(final OutputStream os, final Object obj) {
    final EncogWriteHelper out = new EncogWriteHelper(os);
    final RBFNetwork net = (RBFNetwork) obj;
    final FlatNetworkRBF flat = (FlatNetworkRBF) net.getFlat();
    out.addSection("RBF-NETWORK");
    out.addSubSection("PARAMS");
    out.addProperties(net.getProperties());
    out.addSubSection("NETWORK");
    out.writeProperty(BasicNetwork.TAG_BEGIN_TRAINING,
        flat.getBeginTraining());
    out.writeProperty(BasicNetwork.TAG_CONNECTION_LIMIT,
        flat.getConnectionLimit());
    out.writeProperty(BasicNetwork.TAG_CONTEXT_TARGET_OFFSET,
        flat.getContextTargetOffset());
    out.writeProperty(BasicNetwork.TAG_CONTEXT_TARGET_SIZE,
        flat.getContextTargetSize());
    out.writeProperty(BasicNetwork.TAG_END_TRAINING, flat.getEndTraining());
    out.writeProperty(BasicNetwork.TAG_HAS_CONTEXT, flat.getHasContext());
    out.writeProperty(PersistConst.INPUT_COUNT, flat.getInputCount());
    out.writeProperty(BasicNetwork.TAG_LAYER_COUNTS, flat.getLayerCounts());
    out.writeProperty(BasicNetwork.TAG_LAYER_FEED_COUNTS,
        flat.getLayerFeedCounts());
    out.writeProperty(BasicNetwork.TAG_LAYER_CONTEXT_COUNT,
        flat.getLayerContextCount());
    out.writeProperty(BasicNetwork.TAG_LAYER_INDEX, flat.getLayerIndex());
    out.writeProperty(PersistConst.OUTPUT, flat.getLayerOutput());
    out.writeProperty(PersistConst.OUTPUT_COUNT, flat.getOutputCount());
    out.writeProperty(BasicNetwork.TAG_WEIGHT_INDEX, flat.getWeightIndex());
    out.writeProperty(PersistConst.WEIGHTS, flat.getWeights());
    out.writeProperty(BasicNetwork.TAG_BIAS_ACTIVATION,
        flat.getBiasActivation());
    out.addSubSection("ACTIVATION");
    for (final ActivationFunction af : flat.getActivationFunctions()) {
      out.addColumn(af.getClass().getSimpleName());
      for (int i = 0; i < af.getParams().length; i++) {
        out.addColumn(af.getParams()[i]);
      }
      out.writeLine();
    }
    out.addSubSection("RBF");
    for (final RadialBasisFunction rbf : flat.getRBF()) {
      out.addColumn(rbf.getClass().getSimpleName());
      out.addColumn(rbf.getWidth());
      out.addColumn(rbf.getPeak());
      for (int i = 0; i < rbf.getCenters().length; i++) {
        out.addColumn(rbf.getCenters()[i]);
      }
      out.writeLine();
    }

    out.flush();
  }
View Full Code Here

    return result;
  }

  @Override
  public void save(OutputStream os, Object obj) {
    EncogWriteHelper out = new EncogWriteHelper(os);
    NEATPopulation pop = (NEATPopulation) obj;
    out.addSection("NEAT-POPULATION");
    out.addSubSection("CONFIG");
    out.writeProperty(PersistConst.SNAPSHOT, pop.isSnapshot());
    out.writeProperty(NEATPopulation.PROPERTY_OUTPUT_ACTIVATION, pop.getOutputActivationFunction());
    out.writeProperty(NEATPopulation.PROPERTY_NEAT_ACTIVATION, pop.getNeatActivationFunction());
    out.writeProperty(PersistConst.INPUT_COUNT, pop.getInputCount());
    out.writeProperty(PersistConst.OUTPUT_COUNT, pop.getOutputCount());
    out.writeProperty(NEATPopulation.PROPERTY_OLD_AGE_PENALTY,
        pop.getOldAgePenalty());
    out.writeProperty(NEATPopulation.PROPERTY_OLD_AGE_THRESHOLD,
        pop.getOldAgeThreshold());
    out.writeProperty(NEATPopulation.PROPERTY_POPULATION_SIZE,
        pop.getPopulationSize());
    out.writeProperty(NEATPopulation.PROPERTY_SURVIVAL_RATE,
        pop.getSurvivalRate());
    out.writeProperty(NEATPopulation.PROPERTY_YOUNG_AGE_THRESHOLD,
        pop.getYoungBonusAgeThreshold());
    out.writeProperty(NEATPopulation.PROPERTY_YOUNG_AGE_BONUS,
        pop.getYoungScoreBonus());
    out.writeProperty(NEATPopulation.PROPERTY_NEXT_GENOME_ID, pop
        .getGenomeIDGenerate().getCurrentID());
    out.writeProperty(NEATPopulation.PROPERTY_NEXT_INNOVATION_ID, pop
        .getInnovationIDGenerate().getCurrentID());
    out.writeProperty(NEATPopulation.PROPERTY_NEXT_GENE_ID, pop
        .getGeneIDGenerate().getCurrentID());
    out.writeProperty(NEATPopulation.PROPERTY_NEXT_SPECIES_ID, pop
        .getSpeciesIDGenerate().getCurrentID());
    out.addSubSection("INNOVATIONS");
    if (pop.getInnovations() != null) {
      for (Innovation innovation : pop.getInnovations().getInnovations()) {
        NEATInnovation neatInnovation = (NEATInnovation) innovation;
        out.addColumn(neatInnovation.getInnovationID());
        out.addColumn(PersistNEATPopulation
            .innovationTypeToString(neatInnovation
                .getInnovationType()));
        out.addColumn(PersistNEATPopulation
            .neuronTypeToString(neatInnovation.getNeuronType()));
        out.addColumn(neatInnovation.getSplitX());
        out.addColumn(neatInnovation.getSplitY());
        out.addColumn(neatInnovation.getNeuronID());
        out.addColumn(neatInnovation.getFromNeuronID());
        out.addColumn(neatInnovation.getToNeuronID());
        out.writeLine();
      }
    }
    out.addSubSection("GENOMES");
    for (Genome genome : pop.getGenomes()) {
      NEATGenome neatGenome = (NEATGenome) genome;
      out.addColumn("g");
      out.addColumn(neatGenome.getGenomeID());
      out.addColumn(neatGenome.getSpeciesID());
      out.addColumn(neatGenome.getAdjustedScore());
      out.addColumn(neatGenome.getAmountToSpawn());
      out.addColumn(neatGenome.getNetworkDepth());
      out.addColumn(neatGenome.getScore());
      out.writeLine();

      for (Gene neuronGene : neatGenome.getNeurons().getGenes()) {
        NEATNeuronGene neatNeuronGene = (NEATNeuronGene) neuronGene;
        out.addColumn("n");
        out.addColumn(neatNeuronGene.getId());
        out.addColumn(PersistNEATPopulation
            .neuronTypeToString(neatNeuronGene.getNeuronType()));
        out.addColumn(neatNeuronGene.isEnabled());
        out.addColumn(neatNeuronGene.getInnovationId());
        out.addColumn(neatNeuronGene.getActivationResponse());
        out.addColumn(neatNeuronGene.getSplitX());
        out.addColumn(neatNeuronGene.getSplitY());
        out.writeLine();
      }
      for (Gene linkGene : neatGenome.getLinks().getGenes()) {
        NEATLinkGene neatLinkGene = (NEATLinkGene) linkGene;
        out.addColumn("l");
        out.addColumn(neatLinkGene.getId());
        out.addColumn(neatLinkGene.isEnabled());
        out.addColumn(neatLinkGene.isRecurrent());
        out.addColumn(neatLinkGene.getFromNeuronID());
        out.addColumn(neatLinkGene.getToNeuronID());
        out.addColumn(neatLinkGene.getWeight());
        out.addColumn(neatLinkGene.getInnovationId());
        out.writeLine();
      }
    }
    out.addSubSection("SPECIES");
    for (Species species : pop.getSpecies()) {
      out.addColumn(species.getSpeciesID());
      out.addColumn(species.getAge());
      out.addColumn(species.getBestScore());
      out.addColumn(species.getGensNoImprovement());
      out.addColumn(species.getNumToSpawn());
      out.addColumn(species.getSpawnsRequired());
      out.addColumn(species.getLeader().getGenomeID());
      out.writeLine();
    }
    out.flush();

  }
View Full Code Here

TOP

Related Classes of org.encog.persist.EncogWriteHelper

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.