Skip to content

Instantly share code, notes, and snippets.

@Outsiders17711
Last active June 15, 2022 09:16
Show Gist options
  • Save Outsiders17711/99954e5f15e3f91701c83d96a10c053d to your computer and use it in GitHub Desktop.
Save Outsiders17711/99954e5f15e3f91701c83d96a10c053d to your computer and use it in GitHub Desktop.
Testing fastai's lr_find with accelerate.
from fastai.vision.all import *
from fastai.distributed import *
from fastai.vision.models.xresnet import *
path = rank0_first(untar_data, URLs.PETS)
def get_y(o): return o[0].isupper()
dls = ImageDataLoaders.from_name_func(
path=path,
fnames=get_image_files(path),
valid_pct=0.2, label_func=get_y,
item_tfms=Resize(448),
)
learn = vision_learner(dls, resnet34, metrics=[error_rate, accuracy]).to_fp16()
with learn.distrib_ctx(sync_bn=False, in_notebook=False):
lrs = learn.lr_find(suggest_funcs=(valley, slide), show_plot=False)
print(f"{lrs.valley = } | {lrs.slide = }")
from fastai.vision.all import *
from fastai.distributed import *
from fastai.vision.models.xresnet import *
from accelerate import Accelerator
accelerate = Accelerator()
path = rank0_first(untar_data, URLs.PETS)
def get_y(o): return o[0].isupper()
dls = ImageDataLoaders.from_name_func(
path=path,
fnames=get_image_files(path),
valid_pct=0.2, label_func=get_y,
item_tfms=Resize(448),
)
learn = vision_learner(dls, resnet34, metrics=[error_rate, accuracy]).to_fp16()
with learn.distrib_ctx(sync_bn=False, in_notebook=False):
lrs = learn.lr_find(suggest_funcs=(valley, slide), show_plot=False)
print(f"{lrs.valley = } | {lrs.slide = }")
accelerate.wait_for_everyone()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment