This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip install -Uqq fastbook | |
import fastbook | |
fastbook.setup_book() | |
from fastai.vision.all import * | |
path = untar_data(URLs.PETS)/'images' | |
def is_cat(x): return x[0].isupper() | |
dls = ImageDataLoaders.from_name_func( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = untar_data(URLs.CAMVID_TINY) | |
dls = SegmentationDataLoaders.from_label_func( | |
path, bs=8, fnames = get_image_files(path/"images"), | |
label_func = lambda o: path/'labels'/f'{o.stem}_P{o.suffix}', | |
codes = np.loadtxt(path/'codes.txt', dtype=str) | |
) | |
learn = unet_learner(dls, resnet34) | |
learn.fine_tune(8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastai.text.all import * | |
dls = TextDataLoaders.from_folder(untar_data(URLs.IMDB), valid='test') | |
learn = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy) | |
learn.fine_tune(4, 1e-2) | |
learn.predict("I really liked that movie!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastai.tabular.all import * | |
path = untar_data(URLs.ADULT_SAMPLE) | |
dls = TabularDataLoaders.from_csv(path/'adult.csv', path=path, y_names="salary", | |
cat_names = ['workclass', 'education', 'marital-status', 'occupation', | |
'relationship', 'race'], | |
cont_names = ['age', 'fnlwgt', 'education-num'], | |
procs = [Categorify, FillMissing, Normalize]) | |
learn = tabular_learner(dls, metrics=accuracy) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.