//Constructor /// <summary> /// Creates an initialized instance /// </summary> /// <param name="spikeCodeCfg">Spike code configuration</param> public SpikeCode(SpikeCodeSettings spikeCodeCfg) { _spikeCodeCfg = (SpikeCodeSettings)spikeCodeCfg.DeepClone(); //Binary precision _precisionPiece = 1d / Math.Pow(2d, _spikeCodeCfg.ComponentHalfCodeLength); _maxPrecisionBitMask = (uint)Math.Round(Math.Pow(2d, _spikeCodeCfg.ComponentHalfCodeLength) - 1d); //Sensitivity thresholds double exponent = _spikeCodeCfg.ComponentHalfCodeLength > 1 ? Math.Pow(1d / _spikeCodeCfg.LowestThreshold, 1d / (_spikeCodeCfg.ComponentHalfCodeLength - 1d)) : 0d; _thresholdCollection = new double[_spikeCodeCfg.ComponentHalfCodeLength]; double threshold = 1d; for (int i = 0; i < _thresholdCollection.Length - 1; i++) { threshold /= exponent; _thresholdCollection[i] = threshold; } _thresholdCollection[_thresholdCollection.Length - 1] = 0; //Sub-code buffers allocation _subCodes = new byte[_spikeCodeCfg.NumOfComponents * 2][]; for (int i = 0; i < _subCodes.Length; i++) { _subCodes[i] = new byte[_spikeCodeCfg.ComponentHalfCodeLength]; } //Resulting spike-code buffer allocation Code = new byte[_subCodes.Length * _spikeCodeCfg.ComponentHalfCodeLength]; Reset(); return; }
//Constructors /// <summary> /// Creates an initialized instance /// </summary> /// <param name="name">Generated field name</param> /// <param name="generatorCfg">Configuration of associated generator</param> /// <param name="featureFilterCfg">Configuration of real feature filter</param> /// <param name="spikingCodingCfg">Configuration of spiking coding neurons</param> /// <param name="routeToReadout">Specifies whether to route generated field to readout layer together with other predictors</param> public GeneratedFieldSettings(string name, RCNetBaseSettings generatorCfg, bool routeToReadout = DefaultRouteToReadout, RealFeatureFilterSettings featureFilterCfg = null, SpikeCodeSettings spikingCodingCfg = null ) { Name = name; GeneratorCfg = generatorCfg.DeepClone(); RouteToReadout = routeToReadout; FeatureFilterCfg = featureFilterCfg == null ? null : (RealFeatureFilterSettings)featureFilterCfg.DeepClone(); SpikingCodingCfg = spikingCodingCfg == null ? null : (SpikeCodeSettings)spikingCodingCfg.DeepClone(); Check(); return; }
//Constructors /// <summary> /// Creates an unitialized instance /// </summary> /// <param name="name">Input field name</param> /// <param name="featureFilterCfg">Configuration of feature filter associated with the input field</param> /// <param name="routeToReadout">Specifies whether to route input field to readout layer together with other predictors</param> /// <param name="spikeCodeCfg">Configuration of spike code</param> public ExternalFieldSettings(string name, IFeatureFilterSettings featureFilterCfg, bool routeToReadout = DefaultRouteToReadout, SpikeCodeSettings spikeCodeCfg = null ) { Name = name; FeatureFilterCfg = (IFeatureFilterSettings)featureFilterCfg.DeepClone(); RouteToReadout = routeToReadout; SpikeCodeCfg = (SpikeCodeSettings)spikeCodeCfg?.DeepClone(); if (featureFilterCfg.Type == FeatureFilterBase.FeatureType.Real && spikeCodeCfg == null) { SpikeCodeCfg = new SpikeCodeSettings(); } Check(); return; }