-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add abstract class for transferability metrics
- Loading branch information
1 parent
7edf0e4
commit 654ea83
Showing
7 changed files
with
113 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from .hscore import HScore | ||
from .logme import LogME | ||
from .nearestneighbors import KNN | ||
from .nearestneighbors import NearestNeighbors | ||
|
||
__all__ = ["HScore", "LogME", "NearestNeighbors"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Optional | ||
|
||
import torch | ||
|
||
|
||
class Estimator(ABC): | ||
"""Abstract base class for transferability metrics.""" | ||
def __init__(self, regression: bool, **kwargs): | ||
self.regression: bool = regression | ||
self.score: Optional[float] = None | ||
|
||
@abstractmethod | ||
def fit(self, *, embeddings: torch.tensor, labels: torch.tensor, **kwargs) -> float: | ||
"""Compute score given embeddings and labels. | ||
:param embeddings: Embedding tensor (num_samples, num_features) | ||
:param labels: label tensor (num_samples,) | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.