python - Fast.ai:ModuleAttributeError: 'Sequential' 对象没有属性 'fine_tune'
问题描述
当我使用fast.ai时,T遇到这个问题,下面是我的代码:
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)
它显示:“ModuleAttributeError:'Sequential' 对象没有属性 'fine_tune'”
解决方案
如果可用,fastai 将为您选择 GPU。
我重现了您的问题,并摆脱.to(device)
了 Learner 中的呼叫,从而消除了错误:
learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)
推荐阅读
- javascript - 自定义 CSV 文件的 Wordpress 下载
- java - macOS High Sierra v10.13.6 中的 Java v1.8
- powershell - 统计 Invoke-Command 的结果
- javascript - 如何使用 vue-i18n 翻译渲染项目列表?
- mongodb - Mongodb - 每天自动增加一个字段
- excel - 使用 excel 从 Word 创建 pdf:document.exportasfixedformat 未创建文件的扩展名
- java - java.io.File.isFile() 在不同的线程中返回不同的值
- javascript - KnockoutJS:ko.mapping.toJS,但不要忽略计算属性
- java - Logcat 中的错误
- php - 是否使用外键?