【问题标题】:Loading pretrained FastAI models in Kaggle kernels without using internet在不使用互联网的情况下在 Kaggle 内核中加载预训练的 FastAI 模型
【发布时间】:2020-05-27 20:51:11
【问题描述】:

我正在尝试在不打开互联网的情况下在 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()

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

【问题讨论】:

    标签: pytorch kaggle fast-ai densenet


    【解决方案1】:

    所以 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-12-31
      • 2020-08-25
      • 1970-01-01
      • 2021-02-19
      • 2019-07-19
      • 1970-01-01
      • 2020-02-07
      • 2019-07-17
      • 2020-01-11
      相关资源
      最近更新 更多