def rerunExperimentFromLogfile(logFilename):
    """
    Create an experiment class according to the sequence of operations in
    logFile and return resulting experiment instance. The log file is created
    by setting the 'logCalls' constructor parameter to True
    """
    callLog = LoggingDecorator.load(logFilename)

    # Assume first one is call to constructor
    exp = L246aNetwork(*callLog[0][1]["args"], **callLog[0][1]["kwargs"])

    # Call subsequent methods, using stored parameters
    for call in callLog[1:]:
      method = getattr(exp, call[0])
      method(*call[1]["args"], **call[1]["kwargs"])

    return exp
示例#2
0
def rerunExperimentFromLogfile(logFilename):
    """
  Create an experiment class according to the sequence of operations in logFile
  and return resulting experiment instance.
  """
    callLog = LoggingDecorator.load(logFilename)

    # Assume first one is call to constructor

    exp = L2456Model(*callLog[0][1]["args"], **callLog[0][1]["kwargs"])

    # Call subsequent methods, using stored parameters
    for call in callLog[1:]:
        method = getattr(exp, call[0])
        method(*call[1]["args"], **call[1]["kwargs"])

    return exp
def createExperiment(logFilename):
    # Typically this would be done by Thing
    exp = L4L2Experiment("shared_features", logCalls=True)
    exp.learnObjects(thingObjects)

    LoggingDecorator.save(exp.callLog, logFilename)
        {
            0: getObjectPair("Cube", 2)
        },
    ]
    exp.infer(sensationList, reset=False)
    print "Output for cube:", exp.getL2Representations()
    print "Intersection with sphere:", len(exp.getL2Representations()[0]
                                           & L2Representations["Sphere"][0])
    print "Intersection with Capsule:", len(exp.getL2Representations()[0]
                                            & L2Representations["Capsule"][0])
    print "Intersection with cube:", len(exp.getL2Representations()[0]
                                         & L2Representations["Cube"][0])
    exp.sendReset()


if __name__ == "__main__":

    # Mimic thing, which will create a log file
    createExperiment("callLog.pkl")

    # Print out the log
    print "\n========== CALL LOG ==============="

    for call in LoggingDecorator.load("callLog.pkl"):
        print call
        print
    print "=====================================\n"

    # Recreate class from log and debug experiment
    debugExperiment("callLog.pkl")
示例#5
0
def createExperiment(logFilename):
  # Typically this would be done by Thing
  exp = L4L2Experiment("shared_features", logCalls=True)
  exp.learnObjects(thingObjects)

  LoggingDecorator.save(exp.callLog, logFilename)
示例#6
0
  ]
  exp.infer(sensationList, reset= False)
  print "Output for cube:", exp.getL2Representations()
  print "Intersection with sphere:", len(
    exp.getL2Representations()[0] & L2Representations["Sphere"][0])
  print "Intersection with Capsule:", len(
    exp.getL2Representations()[0] & L2Representations["Capsule"][0])
  print "Intersection with cube:", len(
    exp.getL2Representations()[0] & L2Representations["Cube"][0])
  exp.sendReset()



if __name__ == "__main__":

  # Mimic thing, which will create a log file
  createExperiment("callLog.pkl")

  # Print out the log
  print "\n========== CALL LOG ==============="

  for call in LoggingDecorator.load("callLog.pkl"):
    print call
    print
  print "=====================================\n"

  # Recreate class from log and debug experiment
  debugExperiment("callLog.pkl")