utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:MIL.pytorch 作者: gujiuxiang 项目源码 文件源码
def history_infos(opt):
    infos = {}
    if len(opt.start_from) != 0:  # open old infos and check if models are compatible
        model_id = opt.start_from
        infos_id = model_id.replace('save/', '') + '.infos-best.pkl'
        with open(os.path.join(opt.start_from, infos_id)) as f:
            infos = cPickle.load(f)
            saved_model_opt = infos['opt']

    iteration = infos.get('iter', 0)
    epoch = infos.get('epoch', 0)
    val_result_history = infos.get('val_result_history', {})
    loss_history = infos.get('loss_history', {})
    lr_history = infos.get('lr_history', {})
    best_val_score = infos.get('best_val_score', None) if opt.load_best_score == 1 else 0
    val_loss = 0.0
    val_history = [val_result_history, best_val_score, val_loss]
    train_history = [loss_history, lr_history]
    return opt, infos, iteration, epoch, val_history, train_history
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号