Ch6 Other Computer Vision Problems End-of-Chapter Questions Flashcards
What is the difference between a Dataset and DataLoader?
DataLoader divides a Dataset into mini-batches.
What does Datasets object normally contain?
It contains a training Dataset and a validation Dataset.
What does a DataLoaders object normally contain?
It contains a training DataLoader and a validation DataLoader.
What are the methods to customize how the independent and dependent variables are created with the data block API?
get_x and get_y
Why is softmax not an appropriate output activation function when using a one-hot-encoded target for multi-label classification?
I don’t think the problem is that the target is one-hot-encoded. The main issue is that we have a multi-label classification problem and softmax only works when there’s one right answer. This is because softmax requires that all predictions sum to 1 and it pushes one activation to be much larger than the others. This is not ideal when you have more than one right answer.
What is the difference between nn.BCELoss and nn.BCEWithLogitsLoss?
nn.BCELoss calculates cross entropy on a one-hot-encoded target, but does not include the sigmoid function to scale activations between 0 and 1.
nn.BCEWithLogitsLoss does the sigmoid and binary cross entropy in a single function. This is the one you normally want to use.
Why can’t we use regular accuracy in a multi-label problem?
The regular accuracy function assumes that the class predicted was the one with the highest activation, but in a multi-label problem we could have more than one right answer.
When is it okay to tune a hyperparameter on the validation set?
When the relationship between the hyperparameter and the metric you’re using to measure performance is a smooth curve. This gives us confidence that we’re not picking an inappropriate outlier to define the hyperparameter value.
How is y_range implemented in fastai?
y_range is implemented in fastai with the sigmoid_range function:
def sigmoid_range(x, lo, hi):
return torch.sigmoid(x) * (hi-lo) + lo
What do you need to do to make sure the fastai library applies the same data augmentation to your input images and your target point coordinates?
Use PointBlock (in the “blocks=” parameter of the DataBlock) to let fastai know that the labels represent coordinates and it will adjust them according to the data augmentations applied.
Why is nll_loss
not an appropriate loss function when using a one-hot-encoded target (for multilabel classification)?
nll_loss
will return the loss of just one activation, i.e. it assumes there’s only one correct label, so it will not work when multiple labels are possible.
How do we encode the dependent variable in a multi-label classifcation problem?
We use one-hot-encoding