/// <summary> /// Initialize a region/sensor and its lower regions. /// </summary> public void InitializeRegion(TreeNode parentNode, TreeNode node) { switch (node.Params.Type) { case NetConfig.Type.Region: { var regionParams = (NetConfig.RegionParams)node.Params; // Percentage calculations: var percentageInput = (float)(regionParams.PercentageInputCol * 0.01); var percentageLocalActivity = (float)(regionParams.PercentageLocalActivity * 0.01); var percentageMinOverlap = (float)(regionParams.PercentageMinOverlap * 0.01); // Initalize region with params Region parentRegion = null; if (parentNode != null) { parentRegion = parentNode.Region; } var newRegion = new Region(0, parentRegion, regionParams.Size, percentageInput, percentageMinOverlap, regionParams.LocalityRadius, percentageLocalActivity, regionParams.CellsPerColumn, regionParams.SegmentActivateThreshold, regionParams.NewNumberSynapses); node.Region = newRegion; // If this region is parent of lower regions/sensors in the hierarchy then initialize them too. foreach (var childNode in node.Children) { this.InitializeRegion(node, childNode); } } break; case NetConfig.Type.FileSensor: { var fileSensorParams = (NetConfig.FileSensorParams)node.Params; // Initalize file sensor with params var newFileSensor = new FileSensor(parentNode.Region, fileSensorParams.GetInputFilePath()); node.FileSensor = newFileSensor; } break; } }
/// <summary> /// Initialize a region/sensor and its lower regions. /// </summary> public void InitializeRegion(TreeNode parentNode, TreeNode node) { switch (node.Params.Type) { case NetConfig.Type.Region: { var regionParams = (NetConfig.RegionParams) node.Params; // Percentage calculations: var percentageInput = (float) (regionParams.PercentageInputCol * 0.01); var percentageLocalActivity = (float) (regionParams.PercentageLocalActivity * 0.01); var percentageMinOverlap = (float) (regionParams.PercentageMinOverlap * 0.01); // Initalize region with params Region parentRegion = null; if (parentNode != null) { parentRegion = parentNode.Region; } var newRegion = new Region(0, parentRegion, regionParams.Size, percentageInput, percentageMinOverlap, regionParams.LocalityRadius, percentageLocalActivity, regionParams.CellsPerColumn, regionParams.SegmentActivateThreshold, regionParams.NewNumberSynapses); node.Region = newRegion; // If this region is parent of lower regions/sensors in the hierarchy then initialize them too. foreach (var childNode in node.Children) { this.InitializeRegion(node, childNode); } } break; case NetConfig.Type.FileSensor: { var fileSensorParams = (NetConfig.FileSensorParams) node.Params; // Initalize file sensor with params var newFileSensor = new FileSensor(parentNode.Region, fileSensorParams.GetInputFilePath()); node.FileSensor = newFileSensor; } break; } }