/// <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;
        }
Пример #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);
        }
Пример #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;
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
Пример #8
0
 /// <inheritdoc/>
 public void Resume(TrainingContinuation state)
 {
 }
Пример #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);
 }
Пример #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;
        }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }
Пример #15
0
 /// <inheritdoc/>
 public override void Resume(TrainingContinuation state)
 {
 }
Пример #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();
        }
Пример #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");
 }