BeginEncogObject() public static method

Write the beginning XML for an Encog object.
public static BeginEncogObject ( String objectType, WriteXML xmlOut, IEncogPersistedObject obj, bool top ) : void
objectType String The object type to persist.
xmlOut Encog.Parse.Tags.Write.WriteXML The object that is being persisted.
obj IEncogPersistedObject The XML writer.
top bool Is this a top-level object, that needs a name /// and description?
return void
Example #1
0
 /// <summary>
 /// Save the specified Encog object to an XML writer.
 /// </summary>
 /// <param name="obj">The object to save.</param>
 /// <param name="xmlOut">The XML writer to save to.</param>
 public void Save(IEncogPersistedObject obj, WriteXML xmlOut)
 {
     PersistorUtil.BeginEncogObject(
         EncogPersistedCollection.TYPE_WEIGHTLESS_SYNAPSE, xmlOut, obj,
         false);
     xmlOut.EndTag();
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="xmlOut"></param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlOut)
        {
            PersistorUtil.BeginEncogObject(EncogPersistedCollection.TYPE_TRAINING,
                                           xmlOut, obj, true);
            INeuralDataSet set     = (INeuralDataSet)obj;
            StringBuilder  builder = new StringBuilder();

            foreach (INeuralDataPair pair in set)
            {
                xmlOut.BeginTag(BasicNeuralDataSetPersistor.TAG_ITEM);

                NumberList.ToList(CSVFormat.EG_FORMAT, builder, pair.Input.Data);
                xmlOut.AddProperty(BasicNeuralDataSetPersistor.TAG_INPUT, builder
                                   .ToString());

                if (pair.Ideal != null)
                {
                    NumberList.ToList(CSVFormat.EG_FORMAT, builder, pair.Ideal.Data);
                    xmlOut.AddProperty(BasicNeuralDataSetPersistor.TAG_IDEAL, builder
                                       .ToString());
                }
                xmlOut.EndTag();
            }
            xmlOut.EndTag();
        }
        /// <summary>
        /// Save the specified Encog object to an XML writer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlOut">The XML writer to save to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlOut)
        {
            PersistorUtil.BeginEncogObject(
                EncogPersistedCollection.TYPE_CONTEXT_LAYER, xmlOut, obj, false);
            ContextLayer layer = (ContextLayer)obj;

            xmlOut.AddProperty(BasicLayerPersistor.PROPERTY_NEURONS, layer
                               .NeuronCount);
            xmlOut.AddProperty(BasicLayerPersistor.PROPERTY_X, layer.X);
            xmlOut.AddProperty(BasicLayerPersistor.PROPERTY_Y, layer.Y);

            if (layer.HasBias)
            {
                StringBuilder result = new StringBuilder();
                NumberList.ToList(CSVFormat.EG_FORMAT, result, layer.BiasWeights);
                xmlOut.AddProperty(BasicLayerPersistor.PROPERTY_THRESHOLD, result
                                   .ToString());
            }

            StringBuilder ctx = new StringBuilder();

            NumberList.ToList(CSVFormat.EG_FORMAT, ctx, layer.Context.Data);
            xmlOut.AddProperty(PROPERTY_CONTEXT, ctx.ToString());


            xmlOut.AddProperty(BasicLayerPersistor.PROPERTY_BIAS_ACTIVATION, layer.BiasActivation);
            BasicLayerPersistor.SaveActivationFunction(layer.ActivationFunction, xmlOut);

            xmlOut.EndTag();
        }
        /// <summary>
        /// Save the specified Encog object to an XML writer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlout">The XML writer to save to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlout)
        {
            PersistorUtil.BeginEncogObject(EncogPersistedCollection.TYPE_TEXT, xmlout,
                                           obj, true);
            TextData text = (TextData)obj;

            xmlout.AddCDATA(text.Text);
            xmlout.EndTag();
        }
        /// <summary>
        /// Save the object.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlout">The XML output object.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlout)
        {
            PersistorUtil.BeginEncogObject(
                EncogPersistedCollection.TYPE_TRAINING_CONTINUATION, xmlout, obj,
                true);
            this.current = (TrainingContinuation)obj;

            xmlout.BeginTag(TrainingContinuationPersistor.TAG_ITEMS);
            SaveItems(xmlout);
            xmlout.EndTag();

            xmlout.EndTag();
        }
        /// <summary>
        /// Save the specified Encog object to an XML writer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlOut">The XML writer to save to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlOut)
        {
            PersistorUtil
            .BeginEncogObject(
                EncogPersistedCollection.TYPE_WEIGHTED_SYNAPSE, xmlOut,
                obj, false);
            WeightedSynapse synapse = (WeightedSynapse)obj;

            xmlOut.BeginTag(WeightedSynapsePersistor.TAG_WEIGHTS);
            PersistorUtil.SaveMatrix(synapse.WeightMatrix, xmlOut);
            xmlOut.EndTag();

            xmlOut.EndTag();
        }
Example #7
0
        /// <summary>
        /// Save a RBF layer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlout">XML stream to write to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlout)
        {
            PersistorUtil.BeginEncogObject(
                EncogPersistedCollection.TYPE_RADIAL_BASIS_LAYER, xmlout, obj,
                false);
            RadialBasisFunctionLayer layer = (RadialBasisFunctionLayer)obj;

            xmlout.AddProperty(BasicLayerPersistor.PROPERTY_NEURONS, layer.NeuronCount);
            xmlout.AddProperty(BasicLayerPersistor.PROPERTY_X, layer.X);
            xmlout.AddProperty(BasicLayerPersistor.PROPERTY_Y, layer.Y);

            SaveRBF(xmlout, layer);

            xmlout.EndTag();
        }
Example #8
0
        /// <summary>
        /// Save a SVMNetwork.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlout">Where to save it to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlout)
        {
            PersistorUtil.BeginEncogObject(EncogPersistedCollection.TYPE_SVM, xmlout,
                                           obj, true);
            SVMNetwork net = (SVMNetwork)obj;

            xmlout.AddProperty(SVMNetworkPersistor.TAG_INPUT, net.InputCount);
            xmlout.AddProperty(SVMNetworkPersistor.TAG_OUTPUT, net.OutputCount);
            xmlout.BeginTag(SVMNetworkPersistor.TAG_MODELS);
            for (int i = 0; i < net.Models.Length; i++)
            {
                SaveModel(xmlout, net.Models[i]);
            }
            xmlout.EndTag();
            xmlout.EndTag();
        }
Example #9
0
        /// <summary>
        /// Save the specified Encog object to an XML writer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlout">The XML writer to save to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlout)
        {
            PropertyData pData = (PropertyData)obj;

            PersistorUtil.BeginEncogObject(EncogPersistedCollection.TYPE_PROPERTY,
                                           xmlout, obj, true);
            xmlout.BeginTag(PropertyDataPersistor.TAG_PROPERTIES);
            foreach (String key in pData.Data.Keys)
            {
                xmlout.AddAttribute(PropertyDataPersistor.ATTRIBUTE_NAME, key);
                xmlout.AddAttribute(PropertyDataPersistor.ATTRIBUTE_VALUE, pData
                                    [key]);
                xmlout.BeginTag(PropertyDataPersistor.TAG_PROPERTY);
                xmlout.EndTag();
            }
            xmlout.EndTag();
            xmlout.EndTag();
        }
        /// <summary>
        /// Save the specified Encog object to an XML writer.
        /// </summary>
        /// <param name="obj">The object to save.</param>
        /// <param name="xmlOut">The XML writer to save to.</param>
        public void Save(IEncogPersistedObject obj, WriteXML xmlOut)
        {
            PersistorUtil.BeginEncogObject(EncogPersistedCollection.TYPE_BASIC_NET,
                                           xmlOut, obj, true);
            this.currentNetwork = (BasicNetwork)obj;

            this.currentNetwork.Structure.FinalizeStructure();

            // save the layers
            xmlOut.BeginTag(BasicNetworkPersistor.TAG_LAYERS);
            SaveLayers(xmlOut);
            xmlOut.EndTag();

            // save the structure of these layers
            xmlOut.BeginTag(BasicNetworkPersistor.TAG_SYNAPSES);
            SaveSynapses(xmlOut);
            xmlOut.EndTag();

            SaveProperties(xmlOut);
            SaveTags(xmlOut);
            SaveLogic(xmlOut);

            xmlOut.EndTag();
        }