This module contains all the basic functions we need in other modules of the fastai library (split with torch_core that contains the ones requiring pytorch). Its documentation can easily be skipped at a first read, unless you want to know what a given function does.
from fastai.gen_doc.nbdoc import *
from fastai.core import *
default_cpus = min(16, num_cpus())
show_doc(ifnone)
show_doc(is_listy)
is_listy[source]
is_listy(x:Any) →bool
Check if x is a Collection.
show_doc(is_tuple)
is_tuple[source]
is_tuple(x:Any) →bool
Check if x is a tuple.
show_doc(arrays_split)
arrays_split[source]
arrays_split(mask:ndarray,arrs:NPArrayableList) →SplitArrayList
Given arrs is [a,b,...] and maskindex - return[(a[mask],a[~mask]),(b[mask],b[~mask]),...].
show_doc(extract_kwargs)
extract_kwargs[source]
extract_kwargs(names:StrList,kwargs:KWArgs)
Extract the keys in names from the kwargs.
show_doc(get_chunk_length, doc_string=False)
get_chunk_length[source]
get_chunk_length(data:Union[Path,str,DataFrame,TextFileReader],chunksize:Optional[int]=None) →int
Return the number of chunks we will have when opening the DataFrame in csv_name with chunksize.
show_doc(get_total_length, doc_string=False)
get_total_length[source]
get_total_length(csv_name:PathOrStr,chunksize:int) →int
Return the total length we will have when opening the DataFrame in csv_name with chunksize.
show_doc(idx_dict)
idx_dict[source]
idx_dict(a)
Create a dictionary value to index from a.
idx_dict(['a','b','c'])
{'a': 0, 'b': 1, 'c': 2}
show_doc(listify)
show_doc(random_split)
random_split[source]
random_split(valid_pct:float,arrs:NPArrayableList) →SplitArrayList
Randomly split arrs with valid_pct ratio. good for creating validation set.
show_doc(series2cat)
show_doc(uniqueify)
Return the unique elements in x.
show_doc(download_url)
download_url[source]
download_url(url:str,dest:str,overwrite:bool=False,pbar:ProgressBar=None,show_progress=True)
Download url to dest unless it exists and not overwrite.
show_doc(find_classes)
find_classes[source]
find_classes(folder:Path) →FilePathList
List of label subdirectories in imagenet-style folder.
show_doc(join_path)
join_path[source]
join_path(fname:PathOrStr,path:PathOrStr='.') →Path
Return Path(path)/Path(fname), path defaults to current dir.
show_doc(join_paths)
join_paths[source]
join_paths(fnames:FilePathList,path:PathOrStr='.') →FilePathList
Join path to every file name in fnames.
show_doc(loadtxt_str)
loadtxt_str[source]
loadtxt_str(path:PathOrStr) →ndarray
Return ndarray of str of lines of text from path.
show_doc(maybe_copy)
maybe_copy[source]
maybe_copy(old_fnames:Collection[PathOrStr],new_fnames:Collection[PathOrStr])
Copy the old_fnames to new_fnames location if new_fnames don't exist or are less recent.
show_doc(ItemBase, title_level=3)
show_doc(camel2snake)
camel2snake[source]
camel2snake(name:str) →str
Format name by removing capital letters from a class-style name and separates the subwords with underscores.
camel2snake('DeviceDataLoader')
'device_data_loader'
show_doc(even_mults)
even_mults[source]
even_mults(start:float,stop:float,n:int) →ndarray
Build evenly stepped schedule from start to stop in n steps.
show_doc(noop)
noop[source]
noop(x)
Return x.
show_doc(num_cpus)
show_doc(partition)
partition[source]
partition(a:Collection,sz:int) →List[Collection]
Split iterables a in equal parts of size sz
show_doc(partition_by_cores)
partition_by_cores[source]
partition_by_cores(a:Collection,n_cpus:int) →List[Collection]
Split data in a equally among n_cpus cores
show_doc(range_of)
range_of[source]
range_of(x)
show_doc(to_int)
show_doc(arange_of)
arange_of[source]
arange_of(x)