utils.py 文件源码

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

项目:pytorch-arda 作者: corenel 项目源码 文件源码
def init_model(net, restore):
    """Init models with cuda and weights."""
    # init weights of model
    net.apply(init_weights)

    # restore model weights
    if restore is not None and os.path.exists(restore):
        net.load_state_dict(torch.load(restore))
        net.restored = True
        print("Restore model from: {}".format(os.path.abspath(restore)))

    # check if cuda is available
    if torch.cuda.is_available():
        cudnn.benchmark = True
        net.cuda()

    return net
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号