--- title: Utils keywords: fastai sidebar: home_sidebar summary: "Basic utilities with few dependencies." ---
%load_ext autoreload
%autoreload 2
%matplotlib inline

hasarg[source]

hasarg(func, arg)

Checks if a function has a given argument. Works with args and kwargs as well if you exclude the stars. See example below.

Parameters

func: function arg: str Name of argument to look for.

Returns

bool

Example

def foo(a, b=6, *args): return

hasarg(foo, 'b') True

hasarg(foo, 'args') True

hasarg(foo, 'c') False

quick_stats[source]

quick_stats(x, digits=3)

Quick wrapper to get mean and standard deviation of a tensor.

Parameters

x: torch.Tensor digits: int Number of digits to round mean and standard deviation to.

Returns

tuple[float]