//Constructors /// <summary> /// Creates an initialized instance. /// </summary> /// <param name="spikesCoderCfg">The configuration of the input spikes coder.</param> /// <param name="externalFieldsCfg">The configuration of the external input fields.</param> /// <param name="transformedFieldsCfg">The configuration of the transformed input fields.</param> /// <param name="generatedFieldsCfg">The configuration of the generated input fields.</param> /// <param name="routeToReadout">Specifies whether to route the varying input fields to the readout layer.</param> public VaryingFieldsSettings(InputSpikesCoderSettings spikesCoderCfg, ExternalFieldsSettings externalFieldsCfg, TransformedFieldsSettings transformedFieldsCfg = null, GeneratedFieldsSettings generatedFieldsCfg = null, bool routeToReadout = DefaultRouteToReadout ) { InputSpikesCoderCfg = (InputSpikesCoderSettings)spikesCoderCfg.DeepClone(); ExternalFieldsCfg = (ExternalFieldsSettings)externalFieldsCfg.DeepClone(); TransformedFieldsCfg = transformedFieldsCfg == null ? null : (TransformedFieldsSettings)transformedFieldsCfg.DeepClone(); GeneratedFieldsCfg = generatedFieldsCfg == null ? null : (GeneratedFieldsSettings)generatedFieldsCfg.DeepClone(); RouteToReadout = routeToReadout; Check(); return; }
//Constructor /// <summary> /// Creates an initialized instance. /// </summary> /// <param name="cfg">The configuration of the coder.</param> public InputSpikesCoder(InputSpikesCoderSettings cfg) { _encodingCfg = (InputSpikesCoderSettings)cfg.DeepClone(); _coderCollection = new List <A2SCoderBase>(_encodingCfg.CoderCfgCollection.Count); _numOfComponents = 0; LargestComponentLength = 0; foreach (RCNetBaseSettings coderCfg in _encodingCfg.CoderCfgCollection) { A2SCoderBase coder = A2SCoderFactory.Create(coderCfg); _coderCollection.Add(coder); _numOfComponents += coder.NumOfComponents; LargestComponentLength = Math.Max(LargestComponentLength, coder.BaseCodeLength); } ComponentSpikesCollection = new byte[_numOfComponents][]; switch (_encodingCfg.Regime) { case InputEncoder.InputSpikesCoding.Forbidden: { AllSpikesFlatCollection = new byte[0]; } break; case InputEncoder.InputSpikesCoding.Horizontal: { int idx = 0; int allSpikesLength = 0; foreach (A2SCoderBase coder in _coderCollection) { for (int i = 0; i < coder.NumOfComponents; i++) { ComponentSpikesCollection[idx] = new byte[coder.BaseCodeLength]; ComponentSpikesCollection[idx].Populate((byte)0); allSpikesLength += coder.BaseCodeLength; ++idx; } } AllSpikesFlatCollection = new byte[allSpikesLength]; AllSpikesFlatCollection.Populate((byte)0); } break; case InputEncoder.InputSpikesCoding.Vertical: { int idx = 0; int allSpikesLength = 0; foreach (A2SCoderBase coder in _coderCollection) { for (int i = 0; i < coder.NumOfComponents; i++) { ComponentSpikesCollection[idx] = new byte[LargestComponentLength]; ComponentSpikesCollection[idx].Populate((byte)0); allSpikesLength += coder.BaseCodeLength; ++idx; } } AllSpikesFlatCollection = new byte[allSpikesLength]; AllSpikesFlatCollection.Populate((byte)0); } break; } return; }