Advertisement

Bug解决:RuntimeError: Error loading state_dict for LadderNetv6: Missing keys in state_dict.

阅读量:

在执行网络操作过程中遭遇了这一错误,尽管此前已成功处理过类似情况,但该问题仍再度显现。

在这里插入图片描述

以下为原始代码内容:
有建议指出,在加载该checkpoint之前应插入如下代码段落:
net = torch.nn.DataParallel(net, device_ids=range(torch.cuda.device_count()))
同时需设置cudnn.benchmark = True以优化性能。

复制代码
    if resume:
    # Load checkpoint.
    print('==> Resuming from checkpoint..')
    assert os.path.isdir('checkpoint'), 'Error: no checkpoint directory found!'
    checkpoint = torch.load('./checkpoint/' + check_path, map_location='cpu')
    net.load_state_dict(checkpoint['net'])

全部评论 (0)

还没有任何评论哟~