0

我正在尝试在不打开 Internet 的情况下在 Kaggle 内核中加载一个 densenet121 模型。我已经完成了所需的步骤,例如将预训练的权重添加到我的输入目录并将其移动到“.cache/torch/checkpoints/”。它仍然无法正常工作并引发 gaierror。

以下是代码片段:

!mkdir -p /tmp/.cache/torch/checkpoints
!cp ../input/fastai-pretrained-models/densenet121-a639ec97.pth /tmp/.cache/torch/checkpoints/densenet121-a639ec97.pth

learn_cd = create_cnn(data_cd, models.densenet121, metrics=[error_rate, accuracy],model_dir = Path('../kaggle/working/models'),path=Path('.'),).to_fp16()

我已经为此苦苦挣扎了很长时间。任何帮助都会非常有帮助

4

1 回答 1

0

所以 kaggle 内核中的输入路径“../input/”是只读的。在“kaggle/working”中创建一个文件夹,然后将模型权重复制到那里。下面的例子

if not os.path.exists('/root/.cache/torch/hub/checkpoints/'):
        os.makedirs('/root/.cache/torch/hub/checkpoints/')

!mkdir '/kaggle/working/resnet34'
!cp '/root/.cache/torch/hub/checkpoints/resnet34-333f7ec4.pth' '/kaggle/working/resnet34/resnet34.pth' 
于 2020-11-28T20:21:09.350 回答