args.max_examples_per_epoch = args.num_training

    print("Executing " + args.checkpoint_key)

    with open("args-{}".format(args.checkpoint_key), "w") as args_file:
        args_file.write(" ".join(sys.argv + ["--seed ", str(args.seed)]))

    use_cuda = torch.cuda.is_available() and not args.no_cuda
    device = torch.device("cuda" if use_cuda else "cpu")
    is_parallel = False
    best_acc = 0  # best test accuracy
    start_epoch = 0  # start from epoch 0 or last checkpoint epoch
    problem = None
    if args.problem.startswith("genotyping:"):
        problem = SbiGenotypingProblem(args.mini_batch_size,
                                       code=args.problem,
                                       num_workers=args.num_workers)
    elif args.problem.startswith("struct_genotyping:"):
        # struct_genotyping does not support multiprocessing data loading:
        problem = StructuredSbiGenotypingProblem(args.mini_batch_size,
                                                 code=args.problem,
                                                 num_workers=1)
    elif args.problem.startswith("somatic:"):
        problem = SbiSomaticProblem(args.mini_batch_size,
                                    code=args.problem,
                                    num_workers=args.num_workers)
    else:
        print("Unsupported problem: " + args.problem)
        exit(1)

    def get_metric_value(all_perfs, query_metric_name):
Пример #2
0
                        default=512)
    parser.add_argument("--num-workers",
                        type=int,
                        default=0,
                        help='Number of workers to feed data to the GPUs.')
    parser.add_argument("-n",
                        type=int,
                        default=sys.maxsize,
                        help='Maximum number of examples to sample from each '
                        'dataset.')

    args = parser.parse_args()
    problem = None
    if args.problem.startswith("genotyping:"):
        problem = SbiGenotypingProblem(args.mini_batch_size,
                                       code=args.problem,
                                       num_workers=args.num_workers)
    elif args.problem.startswith("somatic:"):
        problem = SbiSomaticProblem(args.mini_batch_size,
                                    code=args.problem,
                                    num_workers=args.num_workers)
    else:
        print("Unsupported problem: " + args.problem)
        exit(1)

    sum_n = None
    n = 0
    mean = None
    sum_sdm_n = None
    std = None
Пример #3
0
try:

    checkpoint_filename = '{}/models/pytorch_{}_{}.t7'.format(
        args.model_path, args.checkpoint_key, args.model_label)
    checkpoint = torch.load(checkpoint_filename)
except FileNotFoundError:
    print("Unable to load model {} from checkpoint".format(
        args.checkpoint_key))
    exit(1)

if checkpoint is not None:
    model = checkpoint['model']
problem = None
if args.problem.startswith("genotyping:"):
    problem = SbiGenotypingProblem(args.mini_batch_size,
                                   code=args.problem,
                                   drop_last_batch=False,
                                   num_workers=args.num_workers)
elif args.problem.startswith("somatic:"):
    problem = SbiSomaticProblem(args.mini_batch_size,
                                code=args.problem,
                                drop_last_batch=False,
                                num_workers=args.num_workers)
elif args.problem.startswith("struct_genotyping:"):
    problem = StructuredSbiGenotypingProblem(args.mini_batch_size,
                                             code=args.problem,
                                             drop_last_batch=False,
                                             num_workers=args.num_workers)
else:
    print("Unsupported problem: " + args.problem)
    exit(1)
Пример #4
0
                        default=0)
    parser.add_argument('--num-gpus', type=int, help='Number of GPUs to use for search.',
                        default=1)
    parser.add_argument('--num-estimate-class-frequencies', type=int, help='Number of examples to look at to estimate '
                                                                           'class frequencies.',
                        default=sys.maxsize)
    parser.add_argument('--debug', action='store_true', help='Used to debug some code.')
    parser.add_argument('--num-debug',  type=int,
                        help='Maximum number of debug iterations.',
                        default=sys.maxsize)

    args = parser.parse_args()

    problem = None
    if args.problem.startswith("genotyping:"):
        problem = SbiGenotypingProblem(args.mini_batch_size, code=args.problem, num_workers=args.num_workers)
    elif args.problem.startswith("somatic:"):
        problem = SbiSomaticProblem(args.mini_batch_size, code=args.problem, num_workers=args.num_workers)
    else:
        print("Unsupported problem: " + args.problem)
        exit(1)
    args.num_training = min(args.num_training, len(problem.train_set()))
    args.num_estimate_class_frequencies = min(args.num_estimate_class_frequencies, len(problem.train_set()))
    args.num_validation = min(args.num_validation, len(problem.validation_set()))
    trainers = []
    count = 0
    with open(args.commands, "r") as command_file:

        trainer_arguments = command_file.readlines()
        count = len(trainer_arguments)
        i = 0