Skip to content

adabn

AdaBN

Bases: BaseAdapter

Wraps AdaBNHook.

Container Required keys
models ["G", "C"]
Source code in pytorch_adapt\adapters\adabn.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class AdaBN(BaseAdapter):
    """
    Wraps [AdaBNHook][pytorch_adapt.hooks.AdaBNHook].

    |Container|Required keys|
    |---|---|
    |models|```["G", "C"]```|
    """

    def __init__(self, *args, inference_fn=None, **kwargs):
        """
        Arguments:
            inference_fn: Default is [adabn_fn][pytorch_adapt.inference.adabn_fn]
        """
        inference_fn = c_f.default(inference_fn, adabn_fn)
        super().__init__(*args, inference_fn=inference_fn, **kwargs)

    def init_hook(self, hook_kwargs):
        self.hook = self.hook_cls(**hook_kwargs)

    @property
    def hook_cls(self):
        return AdaBNHook

    def get_key_enforcer(self) -> KeyEnforcer:
        return KeyEnforcer(models=["G", "C"], optimizers=[])

    def get_default_containers(self) -> MultipleContainers:
        return MultipleContainers()

__init__(*args, inference_fn=None, **kwargs)

Parameters:

Name Type Description Default
inference_fn

Default is adabn_fn

None
Source code in pytorch_adapt\adapters\adabn.py
17
18
19
20
21
22
23
def __init__(self, *args, inference_fn=None, **kwargs):
    """
    Arguments:
        inference_fn: Default is [adabn_fn][pytorch_adapt.inference.adabn_fn]
    """
    inference_fn = c_f.default(inference_fn, adabn_fn)
    super().__init__(*args, inference_fn=inference_fn, **kwargs)