【问题标题】:Runtime error on during execution of cnn model for image recognition with fastai library使用 fastai 库执行用于图像识别的 cnn 模型时出现运行时错误
【发布时间】:2020-08-28 14:12:40
【问题描述】:

我正在训练一个 cnn 模型来识别图像。但是,运行此代码时出现错误:

from fastai.vision.all import *
path = untar_data(URLs.PETS)/‘images’

def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
path, get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat, item_tfms=Resize(224))

learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)

错误:

During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
in
----> 1 learn.fine_tune(1)

RuntimeError: DataLoader worker (pid(s) 12456, 4440, 3268, 448) exited unexpectedly

错误发生在最后一行(是一个更长的错误,但我不允许我提交所有这些)。 我没有在 GPU 上运行(如互联网上所建议的那样),因为我真的不知道如何告诉 jupiter notebook 这样做。

你能帮忙吗? 谢谢,路易吉

【问题讨论】:

    标签: python-3.x neural-network conv-neural-network fast-ai dataloader


    【解决方案1】:

    您可以添加num_workers=0 示例

    ImageDataLoaders.from_name_func(path, files, label_func, item_tfms=Resize(224),**num_workers=0**)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-25
      • 1970-01-01
      • 2022-01-25
      • 2018-12-03
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      相关资源
      最近更新 更多