/// <summary> /// The deep copy constructor. /// </summary> /// <param name="source">The source instance.</param> public HiddenLayersSettings(HiddenLayersSettings source) : this() { foreach (HiddenLayerSettings hlcfg in source.HiddenLayerCfgCollection) { HiddenLayerCfgCollection.Add((HiddenLayerSettings)hlcfg.DeepClone()); } return; }
//Constructors /// <summary> /// Creates an initialized instance. /// </summary> /// <param name="outputActivationCfg">Configuration of the output layer activation function.</param> /// <param name="hiddenLayersCfg">The configuration of the hidden layers. Hidden layers are optional.</param> /// <param name="trainerCfg">The configuration of the associated trainer.</param> public FeedForwardNetworkSettings(IActivationSettings outputActivationCfg, HiddenLayersSettings hiddenLayersCfg, RCNetBaseSettings trainerCfg ) { OutputActivationCfg = (IActivationSettings)outputActivationCfg.DeepClone(); HiddenLayersCfg = hiddenLayersCfg == null ? new HiddenLayersSettings() : (HiddenLayersSettings)hiddenLayersCfg.DeepClone(); TrainerCfg = trainerCfg.DeepClone(); Check(); return; }
//Constructors /// <summary> /// Creates an initialized instance /// </summary> /// <param name="outputActivationCfg">Output layer activation configuration</param> /// <param name="hiddenLayersCfg">Hidden layers configuration. Hidden layers are optional.</param> /// <param name="trainerCfg">Configuration of associated trainer</param> public FeedForwardNetworkSettings(RCNetBaseSettings outputActivationCfg, HiddenLayersSettings hiddenLayersCfg, RCNetBaseSettings trainerCfg ) { OutputActivationCfg = ActivationFactory.DeepCloneActivationSettings(outputActivationCfg); OutputRange = ActivationFactory.GetInfo(OutputActivationCfg, out _, out _); HiddenLayersCfg = hiddenLayersCfg == null ? new HiddenLayersSettings() : (HiddenLayersSettings)hiddenLayersCfg.DeepClone(); TrainerCfg = trainerCfg.DeepClone(); Check(); return; }
/// <summary> /// Creates an initialized instance. /// </summary> /// <param name="elem">Xml element containing the initialization settings</param> public FeedForwardNetworkSettings(XElement elem) { //Validation XElement settingsElem = Validate(elem, XsdTypeName); //Parsing OutputActivationCfg = ActivationFactory.LoadSettings(settingsElem.Elements().First()); OutputRange = ActivationFactory.GetInfo(OutputActivationCfg, out _, out _); //Hidden layers XElement hiddenLayersElem = settingsElem.Elements("hiddenLayers").FirstOrDefault(); if (hiddenLayersElem != null) { HiddenLayersCfg = new HiddenLayersSettings(hiddenLayersElem); } else { HiddenLayersCfg = new HiddenLayersSettings(); } //Trainer configuration TrainerCfg = null; foreach (XElement candidate in settingsElem.Elements()) { if (candidate.Name.LocalName == "qrdRegrTrainer") { TrainerCfg = new QRDRegrTrainerSettings(candidate); break; } else if (candidate.Name.LocalName == "ridgeRegrTrainer") { TrainerCfg = new RidgeRegrTrainerSettings(candidate); break; } else if (candidate.Name.LocalName == "elasticRegrTrainer") { TrainerCfg = new ElasticRegrTrainerSettings(candidate); break; } else if (candidate.Name.LocalName == "resPropTrainer") { TrainerCfg = new RPropTrainerSettings(candidate); break; } } Check(); return; }