fastai:

A deep learning library
    for fast implementation
   & research

What is fastai?

What is fastai?

PyTorch

  • Very Pythonic.
  • Widely used in research.

fastai


fastai is a deep learning library that builds on top of PyTorch, adding a higher level of functionality.

[It] is organized around two main design goals: to be approachable and rapidly productive, while also being deeply hackable and configurable.

Resources

Documentation

Manual
Tutorials
Peer-reviewed paper

Book

Paperback version
Free MOOC version of part 1 of the book
Jupyter notebooks version of the book

Getting help

Discourse forum

Load domain specific library

Four domains available

Load only the one relevant to your model:

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

Note that import * is not recommended in Python outside the context of fastai

Basic workflow

- DataLoaders

Create iterators with the training and validation data

- Learner

Train the model

- Predict or visualize

Get predictions from our model

An easy introduction

Create model

from fastai.vision.all import *
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)
learn.fine_tune(1)

Try out model

img = 'lion.jpg'
is_cat,_,probs = learn.predict(img)

print(f"Is this a cat?: {is_cat}.")
print(f"Probability it's a cat: {probs[1].item():.6f}")

Questions?