Пример #1
0
        /// <summary>
        /// Internal constructor for custom training hook derivatives with additional requirements.
        /// </summary>
        /// <param name="timeStep"></param>
        protected StopTrainingHook(TimeStep timeStep) : base(timeStep)
        {
            DefaultTargetMode = TargetMode.Global;
            InvokePriority    = 10000;          // typically the training should be stopped after all other hooks have been invoked
            //  (hooks would be invoked anyway, it just looks cleaner)

            ParameterRegistry.Set("requested_stop", false, typeof(bool));
        }
Пример #2
0
        public ApplyModifierHook(string parameter, IValueModifier modifier, TimeStep timeStep) : base(timeStep, parameter)
        {
            if (modifier == null)
            {
                throw new ArgumentNullException(nameof(modifier));
            }

            ParameterRegistry.Set("parameter_identifier", parameter, typeof(string));
            ParameterRegistry.Set("modifier", modifier, typeof(string));
        }
Пример #3
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="timeStep">The time step.</param>
        /// <param name="averageSpan">The interval span to average over.</param>
        public RunningTimeReporter(ITimeStep timeStep, int averageSpan = 4) : base(timeStep)
        {
            DefaultTargetMode = TargetMode.Global;

            string baseResultKey = $"shared.time_{timeStep.TimeScale}";

            RequireHook(new RunningTimeProcessorHook(timeStep.TimeScale, averageSpan, baseResultKey));

            ParameterRegistry.Set("base_result_key", baseResultKey, typeof(string));
        }
Пример #4
0
        /// <summary>
        /// Create a hook with a certain time step and a set of required global registry entries.
        /// </summary>
        /// <param name="timeScale">The time scale.</param>
        /// <param name="averageSpan">The interval span to average over.</param>
        /// <param name="sharedResultBaseKey">The shared result base key (under which results will be available).</param>
        /// <param name="removeExtremas"></param>
        public RunningTimeProcessorHook(TimeScale timeScale, int averageSpan, string sharedResultBaseKey, bool removeExtremas = true) : base(Utils.TimeStep.Every(1, timeScale))
        {
            if (sharedResultBaseKey == null)
            {
                throw new ArgumentNullException(nameof(sharedResultBaseKey));
            }

            DefaultTargetMode = TargetMode.Global;

            ParameterRegistry.Set("average_span", averageSpan, typeof(int));
            ParameterRegistry.Set("shared_result_base_key", sharedResultBaseKey, typeof(string));
            ParameterRegistry.Set("last_running_times", new LinkedList <long>());
            ParameterRegistry.Set("remove_extremas", removeExtremas, typeof(bool));
        }