core.bound.AbstractBound
1from abc import ABC, abstractmethod 2 3from torch import Tensor 4 5 6class AbstractBound(ABC): 7 """ 8 Abstract PAC bound class for evaluating risk certificates. 9 10 Args: 11 bound_delta (float): Confidence level over random data samples. 12 It represents the probability that the upper bound of the PAC bound holds. 13 loss_delta (float): Confidence level over random weight samples. 14 It represents the probability that the upper bound of empirical loss holds. 15 16 Overall probability is (1 - loss_bound) - bound_delta. 17 18 Attributes: 19 _bound_delta (float): Confidence level over random data samples. 20 _loss_delta (float): Confidence level over random weight samples. 21 """ 22 23 def __init__(self, bound_delta: float, loss_delta: float): 24 self._bound_delta = bound_delta 25 self._loss_delta = loss_delta 26 27 @abstractmethod 28 def calculate(self, *args, **kwargs) -> tuple[Tensor | float, Tensor | float]: 29 """ 30 Calculates the PAC Bayes bound. 31 32 Args: 33 args: Variable length argument list. 34 kwargs: Arbitrary keyword arguments. 35 36 Returns: 37 Tuple[Union[Tensor, float], Union[Tensor, float]]: 38 A tuple containing the calculated PAC bound and the upper bound of empirical risk. 39 """ 40 pass
class
AbstractBound(abc.ABC):
7class AbstractBound(ABC): 8 """ 9 Abstract PAC bound class for evaluating risk certificates. 10 11 Args: 12 bound_delta (float): Confidence level over random data samples. 13 It represents the probability that the upper bound of the PAC bound holds. 14 loss_delta (float): Confidence level over random weight samples. 15 It represents the probability that the upper bound of empirical loss holds. 16 17 Overall probability is (1 - loss_bound) - bound_delta. 18 19 Attributes: 20 _bound_delta (float): Confidence level over random data samples. 21 _loss_delta (float): Confidence level over random weight samples. 22 """ 23 24 def __init__(self, bound_delta: float, loss_delta: float): 25 self._bound_delta = bound_delta 26 self._loss_delta = loss_delta 27 28 @abstractmethod 29 def calculate(self, *args, **kwargs) -> tuple[Tensor | float, Tensor | float]: 30 """ 31 Calculates the PAC Bayes bound. 32 33 Args: 34 args: Variable length argument list. 35 kwargs: Arbitrary keyword arguments. 36 37 Returns: 38 Tuple[Union[Tensor, float], Union[Tensor, float]]: 39 A tuple containing the calculated PAC bound and the upper bound of empirical risk. 40 """ 41 pass
Abstract PAC bound class for evaluating risk certificates.
Arguments:
- bound_delta (float): Confidence level over random data samples. It represents the probability that the upper bound of the PAC bound holds.
- loss_delta (float): Confidence level over random weight samples. It represents the probability that the upper bound of empirical loss holds.
Overall probability is (1 - loss_bound) - bound_delta.
Attributes:
- _bound_delta (float): Confidence level over random data samples.
- _loss_delta (float): Confidence level over random weight samples.
@abstractmethod
def
calculate( self, *args, **kwargs) -> tuple[torch.Tensor | float, torch.Tensor | float]:
28 @abstractmethod 29 def calculate(self, *args, **kwargs) -> tuple[Tensor | float, Tensor | float]: 30 """ 31 Calculates the PAC Bayes bound. 32 33 Args: 34 args: Variable length argument list. 35 kwargs: Arbitrary keyword arguments. 36 37 Returns: 38 Tuple[Union[Tensor, float], Union[Tensor, float]]: 39 A tuple containing the calculated PAC bound and the upper bound of empirical risk. 40 """ 41 pass
Calculates the PAC Bayes bound.
Arguments:
- args: Variable length argument list.
- kwargs: Arbitrary keyword arguments.
Returns:
Tuple[Union[Tensor, float], Union[Tensor, float]]: A tuple containing the calculated PAC bound and the upper bound of empirical risk.