Introduction

To support interactive computing, fastai provides easy access to commonly-used external modules. A star import such as:

from fastai.basics import *

will populate the current namespace with these external modules in addition to fastai-specific functions and variables. This page documents these convenience imports, which are defined in fastai.imports.

Note: since this document was manually created, it could be outdated by the time you read it. To get the up-to-date listing of imports, use:

python -c 'a = set([*vars().keys(), "a"]); from fastai.basics import *; print(*sorted(set(vars().keys())-a), sep="\n")'

Names in bold are modules. If an object was aliased during its import, the original name is listed in parentheses.

Name Description
csv CSV file reading and writing
gc Garbage collector interface
gzip Support for gzip files
os Miscellaneous operating system interfaces
pickle Python object serialization
shutil High level file operations
sys System-specific parameters and functions
warnings, warn Warning control
yaml YAML parser and emitter
io, BufferedWriter, BytesIO Core tools for working with streams
subprocess Subprocess management
math Mathematical functions
plt (matplotlib.pyplot) MATLAB-like plotting framework
np (numpy) , array, cos, exp,
log, sin, tan, tanh
Multi-dimensional arrays, mathematical functions
pd (pandas), Series, DataFrame Data structures and tools for data analysis
random Generate pseudo-random numbers
scipy.stats Statistical functions
scipy.special Special functions
abstractmethod, abstractproperty Abstract base classes
collections, Counter, defaultdict,
namedtuple, OrderedDict
Container datatypes
abc (collections.abc), Iterable Abstract base classes for containers
hashlib Secure hashes and message digests
itertools Functions creating iterators for efficient looping
json JSON encoder and decoder
operator, attrgetter, itemgetter Standard operators as functions
pathlib, Path Object-oriented filesystem paths
mimetypes Map filenames to MIME types
inspect Inspect live objects
typing, Any, AnyStr, Callable,
Collection, Dict, Hashable, Iterator,
List, Mapping, NewType, Optional,
Sequence, Tuple, TypeVar, Union
Support for type hints
functools, partial, reduce Higher-order functions and operations on callable objects
importlib The implementatin of import
weakref Weak references
html HyperText Markup Language support
re Regular expression operations
requests HTTP for Humans™
tarfile Read and write tar archive files
numbers, Number Numeric abstract base classes
tempfile Generate temporary files and directories
concurrent, ProcessPoolExecutor,
ThreadPoolExecutor
Launch parallel tasks
copy, deepcopy Shallow and deep copy operation
dataclass, field, InitVar Data Classes
Enum, IntEnum Support for enumerations
set_trace The Python debugger
patches (matplotlib.patches), Patch ?
patheffects (matplotlib.patheffects) ?
contextmanager Utilities for with-statement contexts
MasterBar, master_bar, ProgressBar,
progress_bar
Simple and flexible progress bar for Jupyter Notebook and console
pkg_resources Package discovery and resource access
SimpleNamespace Dynamic type creation and names for built-in types
torch, as_tensor, ByteTensor,
DoubleTensor, FloatTensor, HalfTensor,
LongTensor, ShortTensor, Tensor
Tensor computation and deep learning
nn (torch.nn), weight_norm, spectral_norm Neural networks with PyTorch
F (torch.nn.functional) PyTorch functional interface
optim (torch.optim) Optimization algorithms in PyTorch
BatchSampler, DataLoader, Dataset,
Sampler, TensorDataset
PyTorch data utils