Пример #1
0
        "config": config,
        "updates": updates,
        "optim": optim_state_dict,
    }
    torch.save(checkpoints, path)


if __name__ == "__main__":
    # Combine command-line arguments and yaml file arguments
    opt = opts.model_opts()
    config = yaml.load(open(opt.config, "r"))
    config = Namespace(**config, **vars(opt))

    writer = misc_utils.set_tensorboard(config)
    device, devices_id = misc_utils.set_cuda(config)
    misc_utils.set_seed(config.seed)

    if config.label_dict_file:
        with open(config.label_dict_file, "r") as f:
            label_dict = json.load(f)

    if config.restore:
        print("loading checkpoint...\n")
        checkpoints = torch.load(config.restore,
                                 map_location=lambda storage, loc: storage)
    else:
        checkpoints = None

    data = load_data(config)
    print('data: ', data.keys())
    # exit()
Пример #2
0
        "config": config,
        "updates": updates,
        "optim": optim_state_dict,
    }
    torch.save(checkpoints, path)


if __name__ == "__main__":
    # Combine command-line arguments and yaml file arguments
    opt = opts.model_opts()  # opt=options
    config = yaml.load(open(opt.config, "r"))  # yaml对象
    config = Namespace(**config, **vars(opt))  # 转换成Namespace对象

    writer = misc_utils.set_tensorboard(config)
    device, devices_id = misc_utils.set_cuda(config)
    misc_utils.set_seed(config.seed)  # 可重复的随机性

    if config.label_dict_file:
        with open(config.label_dict_file, "r") as f:
            label_dict = json.load(f)
    # 还不确定label_dict_file是什么文件,是一个json文件

    if config.restore:  # 模型的位置
        print("loading checkpoint...\n")
        checkpoints = torch.load(config.restore,
                                 map_location=lambda storage, loc: storage)
    else:
        checkpoints = None

    data = load_data(config)
    model, optim = build_model(checkpoints, config, device)