MCPcopy Create free account
hub / github.com/CompVis/zigma / poly_kernel

Function poly_kernel

utils/torchmetric_kid.py:49–54  ·  view source on GitHub ↗

Adapted from `KID Score`_

(f1: Tensor, f2: Tensor, degree: int = 3, gamma: Optional[float] = None, coef: float = 1.0)

Source from the content-addressed store, hash-verified

47
48
49def 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
57def poly_mmd(

Callers 1

poly_mmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected