コード例 #1
0
def main():

    config = get_config_from_json('config.json')
    # create an instance of the model
    model = DEC(config)
    # create trainer instance
    trainer = Trainer(config, model)
    # train the model
    trainer.train()
コード例 #2
0
def main():

    config = get_config_from_json('config.json')
    # create an instance of the model
    model = VAE(config)
    # create experiments instance
    experiments = Experiments(config, model)
    # create trainer instance
    trainer = Trainer(config, model, experiments)
    # train the model
    trainer.train()
コード例 #3
0
    utils.save_dict_to_json(params, json_path)

    # Launch training with this config
    cmd = "{python} train.py --model_dir {model_dir} --data_dir {data_dir}".format(
        python=PYTHON, model_dir=model_dir, data_dir=data_dir)
    print(cmd)
    subprocess.check_call(cmd, shell=True)


if __name__ == "__main__":
    # Load the "reference" parameters from parent_dir json file
    args = parser.parse_args()
    json_path = os.path.join(args.parent_dir, 'params.json')
    assert os.path.isfile(
        json_path), "No json configuration file found at {}".format(json_path)
    params = utils.get_config_from_json(json_path)

    # Perform hypersearch over one parameter
    # image_size = [128, 224, 512, 1024]
    # batch_size = [64, 32, 16, 8]
    image_size = [1024]
    batch_size = [4]
    for sz, bz in zip(image_size, batch_size):
        # Modify the relevant parameter in params
        params.image_size = sz
        params.batch_size = bz

        # Launch job (name has to be unique)
        job_name = "image_size_{}_bz{}".format(sz, bz)
        launch_training_job(args.parent_dir, args.data_dir, job_name, params)