/// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            var result = new TrainingContinuation();
            var ins0 = new EncogReadHelper(mask0);
            EncogFileSection section;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("CONT")
                    && section.SubSectionName.Equals("PARAMS"))
                {
                    IDictionary<String, String> paras = section.ParseParams();

                    foreach (String key  in  paras.Keys)
                    {
                        if (key.Equals("type", StringComparison.InvariantCultureIgnoreCase))
                        {
                            result.TrainingType = paras[key];
                        }
                        else
                        {
                            double[] list = EncogFileSection
                                .ParseDoubleArray(paras, key);
                            result.Put(key, list);
                        }
                    }
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            var result = new TrainingContinuation();
            var ins0   = new EncogReadHelper(mask0);
            EncogFileSection section;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("CONT") &&
                    section.SubSectionName.Equals("PARAMS"))
                {
                    IDictionary <String, String> paras = section.ParseParams();

                    foreach (String key  in  paras.Keys)
                    {
                        if (key.Equals("type", StringComparison.InvariantCultureIgnoreCase))
                        {
                            result.TrainingType = paras[key];
                        }
                        else
                        {
                            double[] list = section.ParseDoubleArray(paras, key);
                            result.Put(key, list);
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
 public override sealed TrainingContinuation Pause()
 {
     TrainingContinuation continuation = new TrainingContinuation {
         TrainingType = base.GetType().Name
     };
     continuation.Set("LAST_GRADIENTS", ((TrainFlatNetworkResilient) base.FlatTraining).LastGradient);
     continuation.Set("UPDATE_VALUES", ((TrainFlatNetworkResilient) base.FlatTraining).UpdateValues);
     return continuation;
 }
Ejemplo n.º 4
0
 public bool IsValidResume(TrainingContinuation state)
 {
     if (!state.Contents.ContainsKey("LAST_DELTA"))
     {
         return false;
     }
     if (!state.TrainingType.Equals(base.GetType().Name))
     {
         return false;
     }
     double[] numArray = (double[]) state.Get("LAST_DELTA");
     return (numArray.Length == ((IContainsFlat) this.Method).Flat.Weights.Length);
 }
Ejemplo n.º 5
0
 public override sealed void Resume(TrainingContinuation state)
 {
     if (!this.IsValidResume(state))
     {
         throw new TrainingError("Invalid training resume data length");
     }
     double[] src = (double[]) state.Get("LAST_GRADIENTS");
     double[] numArray2 = (double[]) state.Get("UPDATE_VALUES");
     EngineArray.ArrayCopy(src, ((TrainFlatNetworkResilient) base.FlatTraining).LastGradient);
     if (8 != 0)
     {
     }
     EngineArray.ArrayCopy(numArray2, ((TrainFlatNetworkResilient) base.FlatTraining).UpdateValues);
 }
Ejemplo n.º 6
0
 public bool IsValidResume(TrainingContinuation state)
 {
     if (state.Contents.ContainsKey("LAST_GRADIENTS"))
     {
         if (0 == 0)
         {
             if (0x7fffffff != 0)
             {
             }
             if (!state.Contents.ContainsKey("UPDATE_VALUES"))
             {
                 goto Label_004B;
             }
         }
         if (state.TrainingType.Equals(base.GetType().Name))
         {
             double[] numArray = (double[]) state.Get("LAST_GRADIENTS");
             return (numArray.Length == ((IContainsFlat) this.Method).Flat.Weights.Length);
         }
         return false;
     }
     Label_004B:
     return false;
 }
 /// <summary>
 /// from Encog.ml.train.MLTrain
 /// </summary>
 ///
 public abstract void Resume(
     TrainingContinuation state);
Ejemplo n.º 8
0
 /// <inheritdoc/>
 public void Resume(TrainingContinuation state)
 {
 }
Ejemplo n.º 9
0
 public override void Resume(TrainingContinuation state)
 {
     if (!this.IsValidResume(state))
     {
         throw new TrainingError("Invalid training resume data length");
     }
     double[] src = (double[]) state.Contents["LAST_GRADIENTS"];
     EngineArray.ArrayCopy(src, ((TrainFlatNetworkQPROP) base.FlatTraining).LastGradient);
 }
Ejemplo n.º 10
0
 public override TrainingContinuation Pause()
 {
     TrainingContinuation continuation;
     TrainingContinuation continuation2 = new TrainingContinuation();
     do
     {
         continuation2.TrainingType = base.GetType().Name;
         continuation = continuation2;
         TrainFlatNetworkQPROP flatTraining = (TrainFlatNetworkQPROP) base.FlatTraining;
         double[] lastGradient = flatTraining.LastGradient;
         continuation.Contents["LAST_GRADIENTS"] = lastGradient;
     }
     while (0x7fffffff == 0);
     return continuation;
 }
        /// <summary>
        /// Load the object.
        /// </summary>
        /// <param name="xmlin">The XML object to load from.</param>
        /// <returns>The loaded object.</returns>
        public IEncogPersistedObject Load(ReadXML xmlin)
        {
            this.current = new TrainingContinuation();

            String name = xmlin.LastTag.Attributes[
                    EncogPersistedCollection.ATTRIBUTE_NAME];
            String description = xmlin.LastTag.Attributes[
                    EncogPersistedCollection.ATTRIBUTE_DESCRIPTION];

            this.current.Name = name;
            this.current.Description = description;

            while (xmlin.ReadToTag())
            {
                if (xmlin.IsIt(TrainingContinuationPersistor.TAG_ITEMS, true))
                {
                    HandleItems(xmlin);
                }
                else if (xmlin.IsIt(
                    EncogPersistedCollection.TYPE_TRAINING_CONTINUATION, false))
                {
                    break;
                }
            }

            return this.current;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Determine if this specified training continuation object is valid for
 /// this training method.
 /// </summary>
 /// <param name="state">The training continuation object to check.</param>
 /// <returns>True if the continuation object is valid.</returns>
 public virtual bool IsValidResume(TrainingContinuation state)
 {
     return(false);
 }
Ejemplo n.º 13
0
 public object Read(Stream mask0)
 {
     EncogReadHelper helper;
     EncogFileSection section;
     IDictionary<string, string> dictionary;
     TrainingContinuation continuation = new TrainingContinuation();
     if (3 != 0)
     {
         helper = new EncogReadHelper(mask0);
         goto Label_001E;
     }
     Label_0010:
     if ((-2 == 0) || (4 == 0))
     {
         goto Label_005C;
     }
     Label_001E:
     if ((section = helper.ReadNextSection()) == null)
     {
         return continuation;
     }
     if (!section.SectionName.Equals("CONT"))
     {
         if (1 != 0)
         {
             if (0xff == 0)
             {
                 return continuation;
             }
             goto Label_0010;
         }
         if (0 == 0)
         {
             goto Label_0077;
         }
         goto Label_001E;
     }
     Label_005C:
     if (section.SubSectionName.Equals("PARAMS"))
     {
         dictionary = section.ParseParams();
     }
     else if ((0 == 0) && ((0 != 0) || (3 != 0)))
     {
         goto Label_001E;
     }
     Label_0077:
     using (IEnumerator<string> enumerator = dictionary.Keys.GetEnumerator())
     {
         string current;
         double[] numArray;
         goto Label_0090;
     Label_0086:
         continuation.Put(current, numArray);
     Label_0090:
         if (enumerator.MoveNext())
         {
             current = enumerator.Current;
             if (current.Equals("type", StringComparison.InvariantCultureIgnoreCase))
             {
                 continuation.TrainingType = dictionary[current];
                 goto Label_0090;
             }
             numArray = EncogFileSection.ParseDoubleArray(dictionary, current);
             if (0xff != 0)
             {
             }
             goto Label_0086;
         }
     }
     goto Label_001E;
 }
Ejemplo n.º 14
0
 public override sealed TrainingContinuation Pause()
 {
     TrainingContinuation continuation;
     TrainingContinuation continuation2 = new TrainingContinuation {
         TrainingType = base.GetType().Name
     };
     if (0 == 0)
     {
         continuation = continuation2;
         TrainFlatNetworkBackPropagation flatTraining = (TrainFlatNetworkBackPropagation) base.FlatTraining;
         double[] lastDelta = flatTraining.LastDelta;
         continuation.Set("LAST_DELTA", lastDelta);
     }
     return continuation;
 }
Ejemplo n.º 15
0
 /// <inheritdoc/>
 public override void Resume(TrainingContinuation state)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Resume training.
 /// </summary>
 /// <param name="state">The training continuation object to use to continue.</param>
 public virtual void Resume(TrainingContinuation state)
 {
     throw new TrainingError("This training type does not support resume.");
 }
 /// <inheritdoc/>
 public override void Resume(TrainingContinuation state)
 {
     // TODO Auto-generated method stub
 }
        /// <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();
        }
Ejemplo n.º 19
0
 public override sealed void Resume(TrainingContinuation state)
 {
     if (!this.IsValidResume(state))
     {
         throw new TrainingError("Invalid training resume data length");
     }
     ((TrainFlatNetworkBackPropagation) base.FlatTraining).LastDelta = (double[]) state.Get("LAST_DELTA");
 }