def read_examples(filename, sparm): """Reads and returns x,y example pairs from a file. This reads the examples contained at the file at path filename and returns them as a sequence. Each element of the sequence should be an object 'e' where e[0] and e[1] is the pattern (x) and label (y) respectively. Specifically, the intention is that the element be a two-element tuple containing an x-y pair.""" # We actually ignore the filename passed to us print '\n' # Check that we're not about to overwrite a previous experiment if os.path.exists(OutputPath): print 'Error: Experiment dir already exists: ', OutputPath exit(-1) # Load the dataset training_instances,test_instances = \ training_helpers.load_dataset(Mgr, Dataset.TrainingSet, Dataset.TestSet) assert (Mgr.NumInstances() == len(training_instances) + len(test_instances)) # Compute features for inst in itertools.chain(training_instances, test_instances): compute_features(inst, FtrMgr, FeatureSet) FtrMgr.CommitFeatures() Mgr.NormalizeFeatures(FtrMgr) # Compute loss terms for inst in itertools.chain(training_instances, test_instances): configure_loss(inst, LossFunction) # Set up the reporter global Reporter Reporter = training_helpers.Reporter(training_instances, test_instances, FtrMgr, OutputPath) # Create a structure suitable for SVM-struct return training_helpers.prepare_svm_data(training_instances)
def read_examples(filename, sparm): """Reads and returns x,y example pairs from a file. This reads the examples contained at the file at path filename and returns them as a sequence. Each element of the sequence should be an object 'e' where e[0] and e[1] is the pattern (x) and label (y) respectively. Specifically, the intention is that the element be a two-element tuple containing an x-y pair.""" # We actually ignore the filename passed to us print "\n" # Check that we're not about to overwrite a previous experiment if os.path.exists(OutputPath): print "Error: Experiment dir already exists: ", OutputPath exit(-1) # Load the dataset training_instances, test_instances = training_helpers.load_dataset(Mgr, Dataset.TrainingSet, Dataset.TestSet) assert Mgr.NumInstances() == len(training_instances) + len(test_instances) # Compute features for inst in itertools.chain(training_instances, test_instances): compute_features(inst, FtrMgr, FeatureSet) FtrMgr.CommitFeatures() Mgr.NormalizeFeatures(FtrMgr) # Compute loss terms for inst in itertools.chain(training_instances, test_instances): configure_loss(inst, LossFunction) # Set up the reporter global Reporter Reporter = training_helpers.Reporter(training_instances, test_instances, FtrMgr, OutputPath) # Create a structure suitable for SVM-struct return training_helpers.prepare_svm_data(training_instances)
# Compute the average per-sequence performance import sys import py_indoor_context import training_params import training_helpers dataset = training_params.Datasets.Large.TestSet mgr = py_indoor_context.TrainingManager() a,instances = training_helpers.load_dataset(mgr, [], dataset) pattern = 'out/%s_frame%03d_gt.png' for inst in instances: inst.OutputGroundTruthViz(pattern % (inst.GetSequenceName(),inst.GetFrameId()))