Basic Jupyter note book command and fast.ai library functions
To auto reload
%reload_ext autoreload %autoreload 2 %matplotlib inline
?function-name: Shows the definition and docstring for that function
??function-name: Shows the source code for that function
help(fn_name) fast.ai helper fn like man
doc(fn_name) gives the details informations and links to docs
Line magic star with
‘%’%timeit [i+1 for i in range(1000)] : Runs a line ten thousand times and displays the average time it took to run it.
%debug: Allows to inspect a function which is showing an error using the Python debugger.
path.ls() Helper to do ‘ls’ on Path(python data type) object
You can append to path object like path/’images’
data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=bs).normalize(imagenet_stats)
size=224 : standard image size because of GPU limitation
Return a data bunch object which will used in most of fast.ai course
Tranforms the image to square and also does centre cropping and a lot more
Normalises the color RGB so that model can train well, if model is not working well try to normalise.
data.classes = lists all the classes (ex different breeds) of data
data.c = lists the number of classes = len(data.classes)
learn = cnn_learner(data, models.resnet34, metrics=error_rate)
cnn_learner = a type of convolution neural network
Resnet34 is type of model/architecture. Works almost every time two major ones resnet_34 and resnet_50 number denotes the layer size metrics = things to print can be error_rate or accuracy Tab to auto complete