I am building a cnn learner using resnet18 with the following code:
from fastai.vision import *
data = (ImageList.from_df(train_df, path='/working/')
.split_by_rand_pct(0.2)
.label_from_df(label_delim=','))
learner = cnn_learner(data, models.resnet18, metrics=[accuracy])
I get the following error:
AttributeError Traceback (most recent call last)
AttributeError: device
How can I resolve this?
Try this:
First convert the data into databunch
data = (ImageList.from_df(train_df, path='/working/').split_by_rand_pct(0.2).label_from_df(label_delim=',').databunch()))
Depending on the hardware. (I am using using cpu for processing).
import torch data.device = torch.device('cpu')
Call the learner.
learner = cnn_learner(data, models.resnet18, metrics=[accuracy])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.