示例#1
0
        /// <inheritdoc />
        public ISelector <TTrainer> Keep(params TrainerComponent[] components)
        {
            TTrainer trainer = CreateTrainer(Result.Name);

            // TODO also check by id flags, maybe write extension method for dictionary that also checks for selector component ids

            if (components.ContainsFlag(TrainerComponent.DataIterators))
            {
                trainer.TrainingDataIterator = Result.TrainingDataIterator;

                foreach (var namedIterator in Result.AdditionalNameDataIterators)
                {
                    trainer.AddNamedDataIterator(namedIterator.Key, namedIterator.Value);
                }
            }

            if (components.ContainsFlag(TrainerComponent.DataProvider))
            {
                trainer.DataProvider = Result.DataProvider;
            }

            if (components.ContainsFlag(TrainerComponent.Hooks))
            {
                foreach (IHook hook in Result.LocalHooks)
                {
                    trainer.AddLocalHook(hook);
                }

                foreach (IHook hook in Result.GlobalHooks)
                {
                    trainer.AddGlobalHook(hook);
                }
            }

            if (components.ContainsFlag(TrainerComponent.Initialisers))
            {
                foreach (var identifierInitialiser in Result.Initialisers)
                {
                    trainer.AddInitialiser(identifierInitialiser.Key, identifierInitialiser.Value);
                }
            }

            if (components.ContainsFlag(TrainerComponent.ValueModifiers))
            {
                foreach (var identifierModifiers in Result.ValueModifiers)
                {
                    foreach (IValueModifier modifier in identifierModifiers.Value)
                    {
                        trainer.AddValueModifier(identifierModifiers.Key, modifier);
                    }
                }
            }

            if (components.ContainsFlag(TrainerComponent.Optimiser))
            {
                trainer.Optimiser = Result.Optimiser;
            }

            var networkComponent = TrainerComponent.Network();

            if (components.ContainsFlag(networkComponent))
            {
                trainer.Network = Result.Network.Select().Keep((NetworkComponent[])components.First(c => networkComponent.Equals(c)).SubComponents).Result;
            }

            var operatorComponent = TrainerComponent.Operator();

            if (components.ContainsFlag(operatorComponent))
            {
                trainer.Operator = Result.Operator.Select().Keep((OperatorComponent[])components.First(c => operatorComponent.Equals(c)).SubComponents).Result;
            }

            return(CreateSelector(trainer));
        }
示例#2
0
 /// <inheritdoc />
 public ISelector <TTrainer> Uninitialised()
 {
     return(Keep(TrainerComponent.DataIterators, TrainerComponent.DataProvider, TrainerComponent.Hooks, TrainerComponent.Initialisers,
                 TrainerComponent.Network(NetworkComponent.Architecture), TrainerComponent.Optimiser, TrainerComponent.ValueModifiers, TrainerComponent.Operator(OperatorComponent.None)));
 }