/** {@inheritDoc} */ @Override public final void save(final OutputStream os, final Object obj) { final EncogWriteHelper out = new EncogWriteHelper(os); final SOM som = (SOM) obj; out.addSection("SOM"); out.addSubSection("PARAMS"); out.addProperties(som.getProperties()); out.addSubSection("NETWORK"); out.writeProperty(PersistConst.WEIGHTS, som.getWeights()); out.writeProperty(PersistConst.INPUT_COUNT, som.getInputCount()); out.writeProperty(PersistConst.OUTPUT_COUNT, som.getOutputNeuronCount()); out.flush(); }
/** {@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(); }
/** {@inheritDoc} */ @Override public 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(); }
/** {@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(); }
/** {@inheritDoc} */ @Override public 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()) { String sn = af.getClass().getSimpleName(); // if this is an Encog class then only add the simple name, so it works with C# if (sn.startsWith("org.encog.")) { out.addColumn(sn); } else { out.addColumn(af.getClass().getName()); } for (int i = 0; i < af.getParams().length; i++) { out.addColumn(af.getParams()[i]); } out.writeLine(); } out.flush(); }
/** {@inheritDoc} */ @Override public 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(); }
/** {@inheritDoc} */ @Override public 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(); }
/** {@inheritDoc} */ @Override public final void save(final OutputStream os, final Object obj) { final EncogWriteHelper out = new EncogWriteHelper(os); final BayesianNetwork b = (BayesianNetwork) obj; out.addSection("BAYES-NETWORK"); out.addSubSection("BAYES-PARAM"); String queryType = ""; String queryStr = b.getClassificationStructure(); if (b.getQuery() != null) { queryType = b.getQuery().getClass().getSimpleName(); } out.writeProperty("queryType", queryType); out.writeProperty("query", queryStr); out.writeProperty("contents", b.getContents()); out.addSubSection("BAYES-PROPERTIES"); out.addProperties(b.getProperties()); out.addSubSection("BAYES-TABLE"); for (BayesianEvent event : b.getEvents()) { for (TableLine line : event.getTable().getLines()) { if (line == null) continue; StringBuilder str = new StringBuilder(); str.append("P("); str.append(BayesianEvent.formatEventName(event, line.getResult())); if (event.getParents().size() > 0) { str.append("|"); } int index = 0; boolean first = true; for (BayesianEvent parentEvent : event.getParents()) { if (!first) { str.append(","); } first = false; int arg = line.getArguments()[index++]; if (parentEvent.isBoolean()) { if (arg == 0) { str.append("+"); } else { str.append("-"); } } str.append(parentEvent.getLabel()); if (!parentEvent.isBoolean()) { str.append("="); if (arg >= parentEvent.getChoices().size()) { throw new BayesianError( "Argument value " + arg + " is out of range for event " + parentEvent.toString()); } str.append(parentEvent.getChoice(arg)); } } str.append(")="); str.append(line.getProbability()); str.append("\n"); out.write(str.toString()); } } out.flush(); }