//Methods /// <summary> /// Checks consistency /// </summary> protected override void Check() { if (!IsAllowedActivation(OutputActivationCfg, out _)) { throw new ArgumentException($"Specified OutputActivationCfg can't be used in FF network. Activation function has to be stateless and has to support derivative calculation.", "OutputActivationCfg"); } if (TrainerCfg == null) { throw new ArgumentNullException("TrainerCfg", "TrainerCfg can not be null."); } Type trainerType = TrainerCfg.GetType(); if (trainerType != typeof(QRDRegrTrainerSettings) && trainerType != typeof(RidgeRegrTrainerSettings) && trainerType != typeof(ElasticRegrTrainerSettings) && trainerType != typeof(RPropTrainerSettings) ) { throw new ArgumentException($"Unsupported TrainerCfg {trainerType.Name}.", "TrainerCfg"); } if ((HiddenLayersCfg.HiddenLayerCfgCollection.Count > 0 || OutputActivationCfg.GetType() != typeof(IdentitySettings)) && trainerType != typeof(RPropTrainerSettings) ) { throw new ArgumentException($"Improper type of trainer {trainerType.Name}. For FF having other than Identity output activation or containing hidden layers can be used only Resilient back propagation trainer.", "TrainerCfg"); } return; }
/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName); rootElem.Add(OutputActivationCfg.GetXml(suppressDefaults)); if (!HiddenLayersCfg.ContainsOnlyDefaults) { rootElem.Add(HiddenLayersCfg.GetXml(suppressDefaults)); } rootElem.Add(TrainerCfg.GetXml(suppressDefaults)); Validate(rootElem, XsdTypeName); return(rootElem); }