예제 #1
0
  def start(self):
    """Get data from rabbitMQ and classify input data"""

    if self._network is None:
      self._network = Network(self.trained_network_path)

    regionNames = self._get_all_regions_names()
    setNetworkLearningMode(self._network, regionNames, False)
    _LOGGER.info("[Module %s] Starting Motor Imagery module. Routing keys: %s"
                 % (self.module_id, self.routing_keys))

    self.input_metric_subscriber.subscribe(
        self.routing_keys[self.input_metric],
        self._tag_and_classify)
예제 #2
0
_CONFIG = simplejson.load(open(_CONFIG_JSON, "rb"))

_REGION_CONFIG_KEYS = ("spRegionConfig", "tmRegionConfig",
                       "tpRegionConfig",
                       "classifierRegionConfig")

_REGION_NAMES = []
for region in _REGION_CONFIG_KEYS:
  if _CONFIG[region].get("regionEnabled"):
    _REGION_NAMES.append(_CONFIG[region]["regionName"])

if __name__ == "__main__":

  dataSource = FileRecordStream(streamID="backup/training-data-attention.csv")
  network = configureNetwork(dataSource, _CONFIG)
  setNetworkLearningMode(network, _REGION_NAMES, True)

  sensorRegion = network.regions[
  _CONFIG["sensorRegionConfig"].get("regionName")]
  classifierRegion = network.regions[
  _CONFIG["classifierRegionConfig"].get("regionName")]

  headers = ["x", "y", "label"]

  num_correct = 0
  for category in range(_NUM_CATEGORIES):
    csvFile = open(_INPUT_FILES[category], "rb")
    reader = csv.reader(csvFile)
    # skip 3 header rows
    reader.next()
    reader.next()