Hi,
I have some trouble navigating the fastai2 codebase. I tried to do this using a simple editor instead of nbdev so I wonder if nbdev is required. For example I wanted to know which loss function is used for simple image classification (X-entropy loss with weights for unbalanced classes I guess, but how are the weights calculated)?
Started with cnn_learner(...)
from vision/learner.py
. This function has an argument called loss_func
which is set to None
by default and passed to Learner
. In the constructor I find the following code:
if loss_func is None:
loss_func = getattr(dls.train_ds, 'loss_func', None)
So dls
has to have it by default. After some more digging I find that the type of dls
is DataLoaders
but I could neither find it in DataLoaders
or in DataSet
itself. I also found the class CrossEntropyLossFlat
in layers.py
but could not figure out if and this is instantiated when calling cnn_learner(...)
.
Please enlighten me!