Exemplo n.º 1
0
def runExperiment(experimentDirectory, experimentOptions):
  o = experimentOptions
  # Clean aggregation datasets if needed
  #if o['clearAggregationDatasets']:
  #helpers.cleanAggregationDatasets()
      
  global experiment

  experiment = Experiment(path=experimentDirectory, runtimeOptions=experimentOptions)
  
  
  
  # Create GUIs as needed
  if not experimentOptions['postProcessOnly']:
    if o['runGUI']:
      # Only import these if the gui is requested, because
      # they import further modules that require a console
      # and exit if there is no console (as in the autobuild)
      from nupic.frameworks.prediction.GUIs import TrainingGUI, InferenceGUI
      if not (o['createNetworkOnly'] or o['runInferenceOnly']):
        gui.append(TrainingGUI(experiment))
      gui.append(InferenceGUI(experiment))
      for i, g in enumerate(gui):
        g.start()
    else:
      experiment.run()

  if experimentOptions['postProcess']:
    from nupic.frameworks.prediction.postprocess import postProcess
    try:
      postProcess(experiment)
      experiment.writeResults()
      if os.environ.has_key('NTA_AMAZON_SYNC_DATA'):
        print "Deleting log files"
        inferenceDir = os.path.join(experimentDirectory,"inference")
        logFiles = glob.glob(os.path.join(inferenceDir,"*.txt"))
        for f in logFiles:
          try:
            os.remove(f)
          except:
            print "Couldn't remove log file:",f
    except Exception, e:
      message = "Post processing has failed, %s" % str(e.args)
      e.args = (message,) +e.args[1:]
      #traceback.print_exc(file=sys.stdout)
      raise 
Exemplo n.º 2
0
def runExperiment(experimentDirectory, experimentOptions):
    o = experimentOptions
    # Clean aggregation datasets if needed
    #if o['clearAggregationDatasets']:
    #helpers.cleanAggregationDatasets()

    global experiment

    experiment = Experiment(path=experimentDirectory,
                            runtimeOptions=experimentOptions)

    # Create GUIs as needed
    if not experimentOptions['postProcessOnly']:
        if o['runGUI']:
            # Only import these if the gui is requested, because
            # they import further modules that require a console
            # and exit if there is no console (as in the autobuild)
            from nupic.frameworks.prediction.GUIs import TrainingGUI, InferenceGUI
            if not (o['createNetworkOnly'] or o['runInferenceOnly']):
                gui.append(TrainingGUI(experiment))
            gui.append(InferenceGUI(experiment))
            for i, g in enumerate(gui):
                g.start()
        else:
            experiment.run()

    if experimentOptions['postProcess']:
        from nupic.frameworks.prediction.postprocess import postProcess
        try:
            postProcess(experiment)
            experiment.writeResults()
            if os.environ.has_key('NTA_AMAZON_SYNC_DATA'):
                print "Deleting log files"
                inferenceDir = os.path.join(experimentDirectory, "inference")
                logFiles = glob.glob(os.path.join(inferenceDir, "*.txt"))
                for f in logFiles:
                    try:
                        os.remove(f)
                    except:
                        print "Couldn't remove log file:", f
        except Exception, e:
            message = "Post processing has failed, %s" % str(e.args)
            e.args = (message, ) + e.args[1:]
            #traceback.print_exc(file=sys.stdout)
            raise