Esempio n. 1
0
        /// <summary>
        /// Invoke this hook with a certain parameter registry if optional conditional criteria are satisfied.
        /// </summary>
        /// <param name="registry">The registry containing the required values for this hook's execution.</param>
        /// <param name="resolver">A helper resolver for complex registry entries (automatically cached).</param>
        public override void SubInvoke(IRegistry registry, IRegistryResolver resolver)
        {
            string baseResultKey = ParameterRegistry.Get <string>("base_result_key");

            long lastTime    = resolver.ResolveGetSingleWithDefault(baseResultKey + "_last", -1L);
            long averageTime = resolver.ResolveGetSingleWithDefault(baseResultKey + "_average", -1L);

            Report(TimeStep.TimeScale, lastTime, averageTime);
        }
        /// <summary>
        /// Invoke this hook with a certain parameter registry if optional conditional criteria are satisfied.
        /// </summary>
        /// <param name="registry">The registry containing the required values for this hook's execution.</param>
        /// <param name="resolver">A helper resolver for complex registry entries (automatically cached).</param>
        public override void SubInvoke(IRegistry registry, IRegistryResolver resolver)
        {
            INDArray desiredTargets = ParameterRegistry.Get <INDArray>("desired_targets");
            int      uid            = ParameterRegistry.Get <int>("uid");

            bool success = resolver.ResolveGetSingleWithDefault($"shared.target_maximisation_result_{uid}_success", false);

            if (!success)
            {
                _logger.Warn($"Failed target maximisation for {desiredTargets}, nothing to print.");
            }
            else
            {
                IComputationHandler handler = Operator.Handler;
                INDArray            inputs  = resolver.ResolveGetSingle <INDArray>($"shared.target_maximisation_result_{uid}_input");

                OnTargetMaximisationSuccess(handler, inputs, desiredTargets);
            }
        }