Ejemplo n.º 1
0
        //Methods
        //Methods
        /// <summary>
        /// See the base.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            PoolDimensions cmpSettings = obj as PoolDimensions;

            if (!Dimensions.ContainsEqualValues(cmpSettings.Dimensions))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// The deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public PoolSettings(PoolSettings source)
 {
     InstanceName = source.InstanceName;
     Dim          = null;
     if (source.Dim != null)
     {
         Dim = new PoolDimensions(source.Dim.X, source.Dim.Y, source.Dim.Z);
     }
     RouteToReadout         = source.RouteToReadout;
     InputConnectionDensity = source.InputConnectionDensity;
     InputSynapseWeight     = null;
     if (source.InputSynapseWeight != null)
     {
         InputSynapseWeight = source.InputSynapseWeight.DeepClone();
     }
     InhibitoryNeuronsDensity = source.InhibitoryNeuronsDensity;
     InhibitoryActivation     = null;
     if (source.InhibitoryActivation != null)
     {
         InhibitoryActivation = source.InhibitoryActivation.DeepClone();
     }
     InhibitoryBias = null;
     if (source.InhibitoryBias != null)
     {
         InhibitoryBias = source.InhibitoryBias.DeepClone();
     }
     ExcitatoryActivation = null;
     if (source.ExcitatoryActivation != null)
     {
         ExcitatoryActivation = source.ExcitatoryActivation.DeepClone();
     }
     ExcitatoryBias = null;
     if (source.ExcitatoryBias != null)
     {
         ExcitatoryBias = source.ExcitatoryBias.DeepClone();
     }
     InterconnectionDensity       = source.InterconnectionDensity;
     InterconnectionAvgDistance   = source.InterconnectionAvgDistance;
     InterconnectionSynapseWeight = null;
     if (source.InterconnectionSynapseWeight != null)
     {
         InterconnectionSynapseWeight = source.InterconnectionSynapseWeight.DeepClone();
     }
     RetainmentNeuronsFeature = source.RetainmentNeuronsFeature;
     RetainmentNeuronsDensity = source.RetainmentNeuronsDensity;
     RetainmentMinRate        = source.RetainmentMinRate;
     RetainmentMaxRate        = source.RetainmentMaxRate;
     return;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the instance and initialize it from given xml element.
        /// This is the preferred way to instantiate pool settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing pool settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public PoolSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.PoolSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement poolSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            //Name
            InstanceName = poolSettingsElem.Attribute("instanceName").Value;
            //Dimensions
            Dim = new PoolDimensions(int.Parse(poolSettingsElem.Attribute("dimX").Value, CultureInfo.InvariantCulture),
                                     int.Parse(poolSettingsElem.Attribute("dimY").Value, CultureInfo.InvariantCulture),
                                     int.Parse(poolSettingsElem.Attribute("dimZ").Value, CultureInfo.InvariantCulture)
                                     );
            RouteToReadout = bool.Parse(poolSettingsElem.Attribute("routeToReadout").Value);
            //Input
            XElement inputElem = poolSettingsElem.Descendants("input").First();

            InputConnectionDensity = double.Parse(inputElem.Attribute("connectionDensity").Value, CultureInfo.InvariantCulture);
            InputSynapseWeight     = new RandomValueSettings(inputElem.Descendants("weight").First());
            //Excitatory
            XElement excitatoryElem = poolSettingsElem.Descendants("excitatory").First();

            ExcitatoryActivation = new ActivationSettings(excitatoryElem.Descendants("activation").First());
            ExcitatoryBias       = new RandomValueSettings(excitatoryElem.Descendants("bias").First());
            double excitatoryRelShare = double.Parse(excitatoryElem.Attribute("relShare").Value, CultureInfo.InvariantCulture);
            //Inhibitory
            XElement inhibitoryElem = poolSettingsElem.Descendants("inhibitory").First();

            InhibitoryActivation = new ActivationSettings(inhibitoryElem.Descendants("activation").First());
            InhibitoryBias       = new RandomValueSettings(inhibitoryElem.Descendants("bias").First());
            double inhibitoryRelShare = double.Parse(inhibitoryElem.Attribute("relShare").Value, CultureInfo.InvariantCulture);

            InhibitoryNeuronsDensity = inhibitoryRelShare / (inhibitoryRelShare + excitatoryRelShare);
            //Interconnection
            XElement interconnectionElem = poolSettingsElem.Descendants("interconnection").First();

            InterconnectionDensity       = double.Parse(interconnectionElem.Attribute("density").Value, CultureInfo.InvariantCulture);
            InterconnectionAvgDistance   = interconnectionElem.Attribute("avgDistance").Value == "NA" ? 0d : double.Parse(interconnectionElem.Attribute("avgDistance").Value, CultureInfo.InvariantCulture);
            InterconnectionAllowSelfConn = bool.Parse(interconnectionElem.Attribute("allowSelfConnection").Value);
            InterconnectionSynapseWeight = new RandomValueSettings(interconnectionElem.Descendants("weight").First());
            //Retainment neurons
            XElement retainmentElem = poolSettingsElem.Descendants("retainmentNeurons").FirstOrDefault();

            RetainmentNeuronsFeature = (retainmentElem != null);
            if (RetainmentNeuronsFeature)
            {
                RetainmentNeuronsDensity = double.Parse(retainmentElem.Attribute("density").Value, CultureInfo.InvariantCulture);
                RetainmentMinRate        = double.Parse(retainmentElem.Attribute("retainmentMinRate").Value, CultureInfo.InvariantCulture);
                RetainmentMaxRate        = double.Parse(retainmentElem.Attribute("retainmentMaxRate").Value, CultureInfo.InvariantCulture);
                RetainmentNeuronsFeature = (RetainmentNeuronsDensity > 0 &&
                                            RetainmentMaxRate > 0
                                            );
            }
            else
            {
                RetainmentNeuronsDensity = 0;
                RetainmentMinRate        = 0;
                RetainmentMaxRate        = 0;
            }
            return;
        }