使用Fastai库执行CNN模型以进行图像识别时出现运行时错误

问题描述

我正在训练一个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

错误发生在最后一行(是一个较长的错误,但是SO不允许我提交所有错误)。 我没有在GPU上运行(如互联网上的建议),因为我还没有真正知道如何告诉木星笔记本这样做。

可以帮忙吗? 谢谢,路易吉

解决方法

您可以添加0 例子

num_workers=0