Fast.ai:ModuleAttributeError: 'Sequential' object has no attribute 'fine_tune'

Viewed 579

When I use the fast.ai, T encounter this problem,the follow is my code:

from fastai.vision.all import *
from fastai.text.all import *
from fastai.collab import *
from fastai.tabular.all import *

device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')

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).to(device)

learn.fine_tune(1)

It shows :"ModuleAttributeError: 'Sequential' object has no attribute 'fine_tune'"

1 Answers

fastai will select GPU for you if available.

I reproduced your problem and getting rid of the .to(device) call in the Learner got the error away:

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