model_dir + "/" + weights_fname, ".\nThese are to be used as input for party which owns the model\n", ) DumpTFMtData.save_weights(optimized_graph_def, sess, feed_dict, weights_fname, scaling_factor) weights_path = os.path.join(model_dir, weights_fname) os.chdir(cwd) return weights_path def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--config", required=True, type=str, help="Path to the config file") args = parser.parse_args() return args if __name__ == "__main__": args = parse_args() params = parse_config.get_params(args.config) compile( params["model_name"], params["input_tensors"], params["output_tensors"], params["scale"], params["save_weights"], )
with open(filename, "r") as f: for line in f: match = matcher.fullmatch(line.rstrip()) if match: unsigned_number = int(match.group(0)) number = (unsigned_number if (unsigned_number < 2**(bitlength - 1)) else unsigned_number - 2**bitlength) scaled_array.append(float(number) / (2**scale)) return np.array(scaled_array) if __name__ == "__main__": if len(sys.argv) < 3: print("Usage: python get_output.py mpc_output.txt config.json") output_fname = sys.argv[1] config_name = sys.argv[2] params = parse_config.get_params(config_name) scale = 12 if params["scale"] is None else params["scale"] if params["bitlength"] is None: if target == "SCI": bitlength = 63 else: bitlength = 64 else: bitlength = params["bitlength"] model_name = os.path.splitext(params["model_name"])[0] np_arr = convert_raw_output_to_np(output_fname, bitlength, scale) np.save(model_name + "_output", np_arr) print("Output dumped as np array in " + model_name + "_output.npy")