def runConverterDriver(self): for iter in product(self.args.algo, self.args.version, self.args.dataset, self.args.datasetType, self.args.target): algo, version, dataset, datasetType, target = iter print("\nGenerating input files for \"" + algo + " " + version + " " + dataset + " " + datasetType + " " + target + "\"...") outputDir = os.path.join( "Converter", "output", algo + "-" + version + "-" + datasetType, dataset) os.makedirs(outputDir, exist_ok=True) datasetDir = os.path.join("..", "datasets", "datasets", dataset) modelDir = os.path.join("..", "model", dataset) if algo == config.Algo.bonsai: modelDir = os.path.join(modelDir, "BonsaiResults", "Params") elif algo == config.Algo.lenet: modelDir = os.path.join(modelDir, "LenetModel") else: modelDir = os.path.join(modelDir, "ProtoNNResults") inputFile = os.path.join(modelDir, "input.sd") trainingInput = os.path.join(datasetDir, "training-full.tsv") testingInput = os.path.join(datasetDir, "testing.tsv") obj = converter.Converter(algo, version, datasetType, target, outputDir, outputDir) obj.setInput(inputFile, modelDir, trainingInput, testingInput) obj.run()
def runPredictorDriver(self): for iter in product(self.args.algo, self.args.version, self.args.dataset, self.args.datasetType): algo, version, dataset, datasetType = iter print("\nGenerating input files for \"" + algo + " " + version + " " + dataset + " " + datasetType + "\"...") #outputDir = os.path.join("..", "Predictor", algo, version + "-testing") #datasetOutputDir = os.path.join("..", "Predictor", algo, version + "-" + datasetType) if version == config.Version.fixed: outputDir = os.path.join( "..", "Predictor", "seedot_fixed", "testing") datasetOutputDir = os.path.join( "..", "Predictor", "seedot_fixed", datasetType) elif version == config.Version.floatt: outputDir = os.path.join( "..", "Predictor", algo + "_float", "testing") datasetOutputDir = os.path.join( "..", "Predictor", algo + "_float", datasetType) os.makedirs(datasetOutputDir, exist_ok=True) os.makedirs(outputDir, exist_ok=True) datasetDir = os.path.join("..", "datasets", "datasets", dataset) modelDir = os.path.join("..", "model", dataset) if algo == config.Algo.bonsai: modelDir = os.path.join(modelDir, "BonsaiResults", "Params") elif algo == config.Algo.lenet: modelDir = os.path.join(modelDir, "LenetModel") else: modelDir = os.path.join(modelDir, "ProtoNNResults") inputFile = os.path.join(modelDir, "input.sd") trainingInput = os.path.join(datasetDir, "training-full.tsv") testingInput = os.path.join(datasetDir, "testing.tsv") obj = converter.Converter(algo, version, datasetType, config.Target.x86, datasetOutputDir, outputDir) obj.setInput(inputFile, modelDir, trainingInput, testingInput) obj.run() print("Building and executing " + algo + " " + version + " " + dataset + " " + datasetType + "...") outputDir = os.path.join( "..", "Predictor", "output", algo + "-" + version) curDir = os.getcwd() os.chdir(os.path.join("..", "Predictor")) obj = predictor.Predictor( algo, version, datasetType, outputDir, self.args.max_scale_factor) acc = obj.run() os.chdir(curDir) if acc != None: print("Accuracy is %.3f" % (acc))