Ejemplo n.º 1
0
def pick_parameters(args, trial, counter):
    margs = copy.deepcopy(args)

    margs.modelname = "{}_{}".format(args.paramscanstudyname, counter)

    margs.outerlayers = trial.suggest_categorical("outerlayers",
                                                  [4, 8, 12, 16, 20, 24])
    margs.innerlayers = trial.suggest_int("innerlayers", 3, 10)
    margs.linlayers = trial.suggest_int("linlayers", 1, 3)
    margs.linchannelfactor = trial.suggest_int("linchannelfactor", 1, 2)
    margs.lineartransform = trial.suggest_categorical(
        "lineartransform", ["permutation", "lu", "svd"])
    margs.dropout = trial.suggest_categorical("dropout", [0.0, 0.20])
    margs.splinerange = trial.suggest_categorical("splinerange",
                                                  [6.0, 8.0, 10.0])
    margs.splinebins = trial.suggest_int("splinebins", 3, 20)
    margs.batchnorm = trial.suggest_categorical("batchnorm", [False, True])
    margs.actnorm = trial.suggest_categorical("actnorm", [False, True])

    margs.batchsize = trial.suggest_categorical("batchsize", [
        50,
    ])
    margs.msefactor = trial.suggest_loguniform("msefactor", 1.0e-3, 10.0)
    margs.uvl2reg = trial.suggest_loguniform("uvl2reg", 1.0e-9, 0.1)
    margs.weightdecay = trial.suggest_loguniform("weightdecay", 1.0e-9, 0.1)
    margs.clip = trial.suggest_loguniform("clip", 1.0, 100.0)

    create_modelname(margs)

    return margs
Ejemplo n.º 2
0
def pick_parameters(args, trial, counter):
    margs = copy.deepcopy(args)

    margs.modelname = "paramscan_{}".format(counter)

    margs.outerlayers = trial.suggest_categorical("outerlayers", [3, 5, 10])
    margs.innerlayers = trial.suggest_categorical("innerlayers", [3, 5, 10])
    margs.outercouplingmlp = trial.suggest_categorical("outercouplingmlp",
                                                       [False, True])
    margs.outercouplinglayers = trial.suggest_categorical(
        "outercouplinglayers", [1, 2, 3])
    margs.dropout = trial.suggest_categorical("dropout", [0.0, 0.20])
    margs.splinerange = trial.suggest_categorical("splinerange",
                                                  [5.0, 6.0, 8.0])
    margs.splinebins = trial.suggest_categorical("splinebins", [5, 10, 20])

    margs.batchsize = trial.suggest_categorical("batchsize",
                                                [50, 100, 200, 500])
    margs.lr = trial.suggest_loguniform("lr", 1.0e-5, 1.0e-2)
    margs.msefactor = trial.suggest_loguniform("msefactor", 1.0e2, 1.0e4)
    margs.weightdecay = trial.suggest_loguniform("weightdecay", 1.0e-8, 1.0e-4)
    margs.clip = trial.suggest_loguniform("clip", 1.0, 100.0)

    create_modelname(margs)

    return margs
Ejemplo n.º 3
0
if __name__ == "__main__":
    # Parse args
    args = parse_args()
    logging.basicConfig(format="%(asctime)-5.5s %(name)-20.20s %(levelname)-7.7s %(message)s", datefmt="%H:%M", level=logging.DEBUG if args.debug else logging.INFO)
    # Silence PIL
    for key in logging.Logger.manager.loggerDict:
        if "PIL" in key:
            logging.getLogger(key).setLevel(logging.WARNING)

    logger.info("Hi!")
    logger.debug("Starting evaluate.py with arguments %s", args)

    # Model name
    if args.truth:
        create_modelname(args)
        logger.info("Evaluating simulator truth")
    else:
        create_modelname(args)
        logger.info("Evaluating model %s", args.modelname)

    # Bug fix related to some num_workers > 1 and CUDA. Bad things happen otherwise!
    torch.multiprocessing.set_start_method("spawn", force=True)

    # Data set
    simulator = load_simulator(args)

    # Load model
    if not args.truth:
        model = create_model(args, simulator=simulator)
        model.load_state_dict(torch.load(create_filename("model", None, args), map_location=torch.device("cpu")))