问题描述
我正在尝试在Windows 10中安装fastai。
我的笔记本电脑没有GPU,我在cmd中使用pip来安装fastai。
在点子页面(https://pypi.org/project/fastai/)中,他们提到在安装fastai之前先安装pytroch。
我遵循了这一步,
对于pytorch(https://pytorch.org/get-started/locally/)-
pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
然后,为了法式-
pip install fastai
这些python软件包已成功安装。
from fastai.vision import *
此语句已成功导入fastai.vision,
但是当我使用ImageDataBunch函数时,
data = ImageDataBunch.from_folder(path,train=".",valid_pct=0.2,size=512,bs=4,seed=24)
显示错误NameError: name 'ImageDataBunch' is not defined
解决方法
from fastai.vision.data import ImageDataLoaders
代替使用ImageDataBunch
,请使用data = ImageDataLoaders.from_folder(path,valid_pct=0.2)
,在此处查看更多fastai vision documentation
忘记使用 from fastbook import *
时出现此错误