Adapted from `KID Score`_
(f1: Tensor, f2: Tensor, degree: int = 3, gamma: Optional[float] = None, coef: float = 1.0)
| 47 | |
| 48 | |
| 49 | def poly_kernel(f1: Tensor, f2: Tensor, degree: int = 3, gamma: Optional[float] = None, coef: float = 1.0) -> Tensor: |
| 50 | """Adapted from `KID Score`_""" |
| 51 | if gamma is None: |
| 52 | gamma = 1.0 / f1.shape[1] |
| 53 | kernel = (f1 @ f2.T * gamma + coef) ** degree |
| 54 | return kernel |
| 55 | |
| 56 | |
| 57 | def poly_mmd( |