def init_config(): parser = argparse.ArgumentParser() parser.add_argument('--config', type=str, required=True) args = parser.parse_args() config = process_config(args.config) return config
def init_config(): parser = argparse.ArgumentParser() parser.add_argument('--config', type=str, required=True) parser.add_argument('--run', type=str, default='') args = parser.parse_args() runs = None if len(args.run) > 0: runs = args.run config = process_config(args.config, runs) return config
def init_config(): parser = argparse.ArgumentParser() parser.add_argument('--config', type=str, required=True) parser.add_argument('--run', type=str, default='') parser.add_argument('--seed', default=0, type=int, help='seed for initializing training. ') args = parser.parse_args() runs = None if len(args.run) > 0: runs = args.run seed = args.seed config = process_config(args.config, runs, seed) return config, seed
def init_config(): parser = argparse.ArgumentParser() parser.add_argument('--config', type=str, required=False) parser.add_argument('--run', type=str, default='') args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = '3' args.config = '/home/wzn/PycharmProjects/GraSP/configs/tiny_imagenet/resnet32/GraSP_90.json' runs = None if len(args.run) > 0: runs = args.run config = process_config(args.config, runs) return config
def init_config(): parser = argparse.ArgumentParser() parser.add_argument('--config', type=str, required=True) parser.add_argument('--run', type=str, default='') parser.add_argument('--init', type=str, default='kaiming_xavier') parser.add_argument('--target_ratio', type=float, default=None) parser.add_argument('--gpu', type=int, default=0) parser.add_argument('--seed_tiny', type=int, default=0) parser.add_argument('--scaled_init', action='store_true') parser.add_argument('--bn', action='store_true') parser.add_argument('--act', type=str, default='relu') parser.add_argument('--sigma_w2', type=float, default=None, help='This is only for ordered init') args = parser.parse_args() runs = None if len(args.run) > 0: runs = args.run config = process_config(args.config, runs) #os.environ['CUDA_VISIBLE_DEVICES'] = "{}".format(args.gpu) return config, args
stats[it] = stat if prune_mode == 'one_pass': del net del pruner net, bottleneck_net = init_network(config, logger, device) pruner = init_pruner(net, bottleneck_net, config, writer, logger) pruner.iter = it with open(os.path.join(config.summary_dir, 'stats.json'), 'w') as f: json.dump(stats, f) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--tmp_config', type=str, default='', required=False) parser.add_argument('--config', type=str, default='', required=False) args = parser.parse_args() if len(args.tmp_config) > 1: print('Using tmp config!') config, _ = get_config_from_json(args.tmp_config) makedirs(config.summary_dir) sys.stdout = open(os.path.join(config.summary_dir, 'stdout.txt'), 'w+') sys.stderr = open(os.path.join(config.summary_dir, 'stderr.txt'), 'w+') main(config) else: print('Using config!') config = process_config(args.config) main(config)