ISubGVQA.sampling.methods.target_aimle

Attributes

logger

Classes

BaseTargetDistribution

Helper class that provides a standard way to create an ABC using

TargetDistribution

Creates a generator of target distributions parameterized by alpha and beta.

AdaptiveTargetDistribution

Helper class that provides a standard way to create an ABC using

Module Contents

ISubGVQA.sampling.methods.target_aimle.logger
class ISubGVQA.sampling.methods.target_aimle.BaseTargetDistribution

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract params(theta: torch.Tensor, dy: torch.Tensor | None, _is_minimization: bool = False) torch.Tensor
abstract process(theta: torch.Tensor, dy: torch.Tensor, gradient: torch.Tensor) torch.Tensor
class ISubGVQA.sampling.methods.target_aimle.TargetDistribution(alpha: float = 1.0, beta: float = 1.0, do_gradient_scaling: bool = False, eps: float = 1e-07)

Bases: BaseTargetDistribution

Creates a generator of target distributions parameterized by alpha and beta.

Example:

>>> import torch
>>> target_distribution = TargetDistribution(alpha=1.0, beta=1.0)
>>> target_distribution.params(theta=torch.tensor([1.0]), dy=torch.tensor([1.0]))
tensor([2.])
Args:

alpha (float): weight of the initial distribution parameters theta beta (float): weight of the downstream gradient dy do_gradient_scaling (bool): whether to scale the gradient by 1/λ or not

alpha = 1.0
beta = 1.0
do_gradient_scaling = False
eps = 1e-07
params(theta: torch.Tensor, dy: torch.Tensor | None, alpha: float | None = None, beta: float | None = None, _is_minimization: bool = False) torch.Tensor
process(theta: torch.Tensor, dy: torch.Tensor, gradient_3d: torch.Tensor) torch.Tensor
class ISubGVQA.sampling.methods.target_aimle.AdaptiveTargetDistribution(initial_alpha: float = 1.0, initial_beta: float = 1.0, initial_grad_norm: float = 1.0, beta_update_step: float = 0.0001, beta_update_momentum: float = 0.0, grad_norm_decay_rate: float = 0.9, target_norm: float = 1.0)

Bases: BaseTargetDistribution

Helper class that provides a standard way to create an ABC using inheritance.

alpha = 1.0
beta = 1.0
grad_norm = 1.0
beta_update_step = 0.0001
beta_update_momentum = 0.0
previous_beta_update = 0.0
grad_norm_decay_rate = 0.9
target_norm = 1.0
_perturbation_magnitude(theta: torch.Tensor, dy: torch.Tensor | None)
params(theta: torch.Tensor, dy: torch.Tensor | None, _is_minimization: bool = False) torch.Tensor
process(theta: torch.Tensor, dy: torch.Tensor, gradient_3d: torch.Tensor) torch.Tensor