Co-Tuning
-
class
ftlib.finetune.co_tuning.
CoTuningLoss
[source] The Co-Tuning loss in Co-Tuning for Transfer Learning (NIPS 2020).
- Inputs:
input: p(y_s) predicted by source classifier.
target: p(y_s|y_t), where y_t is the ground truth class label in target dataset.
- Shape:
input: (b, N_p), where b is the batch size and N_p is the number of classes in source dataset
target: (b, N_p), where b is the batch size and N_p is the number of classes in source dataset
Outputs: scalar.
-
class
ftlib.finetune.co_tuning.
Relationship
(data_loader, classifier, device, cache=None)[source] Learns the category relationship p(y_s|y_t) between source dataset and target dataset.
- Parameters
data_loader (torch.utils.data.DataLoader) – A data loader of target dataset.
classifier (torch.nn.Module) – A classifier for Co-Tuning.
device (torch.nn.Module) – The device to run classifier.
cache (str, optional) – Path to find and save the relationship file.