Exemplo n.º 1
0
def test_add_module():
    r = Registry("")

    r.add_from_module(module)

    r.get("foo")

    with pytest.raises(RegistryException):
        r.get_instance("bar")
Exemplo n.º 2
0
def _model_loader(r: Registry):
    from catalyst_rl.contrib import models as m
    r.add_from_module(m)

    try:
        import segmentation_models_pytorch as smp
        r.add_from_module(smp, prefix="smp.")
    except ImportError:
        pass
Exemplo n.º 3
0
def _samplers_loader(r: Registry):
    from torch.utils.data import sampler as s
    factories = {
        k: v
        for k, v in s.__dict__.items() if "Sampler" in k and k != "Sampler"
    }
    r.add(**factories)
    from catalyst_rl.data import sampler
    r.add_from_module(sampler)
Exemplo n.º 4
0
def _transforms_loader(r: Registry):
    try:
        import albumentations as m
        r.add_from_module(m, prefix=["A.", "albu.", "albumentations."])

        from albumentations import pytorch as p
        r.add_from_module(p, prefix=["A.", "albu.", "albumentations."])

        from catalyst_rl.contrib.data.cv import transforms as t
        r.add_from_module(t, prefix=["catalyst_rl.", "C."])
    except ImportError as ex:
        if os.environ.get("USE_ALBUMENTATIONS", "0") == "1":
            logger.warning(
                "albumentations not available, to install albumentations, "
                "run `pip install albumentations`.")
            raise ex
Exemplo n.º 5
0
def _dbs_late_add(r: Registry):
    from . import db as m
    r.add_from_module(m)
Exemplo n.º 6
0
def _exploration_late_add(r: Registry):
    from . import exploration as m
    r.add_from_module(m)
Exemplo n.º 7
0
def _env_late_add(r: Registry):
    from . import environment as m
    r.add_from_module(m)
Exemplo n.º 8
0
def _onpolicy_algorithms_late_add(r: Registry):
    from .onpolicy import algorithms as m
    r.add_from_module(m)
Exemplo n.º 9
0
def _agents_late_add(r: Registry):
    from . import agent as m
    r.add_from_module(m)
Exemplo n.º 10
0
def _callbacks_loader(r: Registry):
    from catalyst_rl.core import callbacks as m
    r.add_from_module(m)
Exemplo n.º 11
0
def _criterion_loader(r: Registry):
    from catalyst_rl.contrib.nn import criterion as m
    r.add_from_module(m)
Exemplo n.º 12
0
def _modules_loader(r: Registry):
    from catalyst_rl.contrib.nn import modules as m
    r.add_from_module(m)
Exemplo n.º 13
0
def _grad_clip_loader(r: Registry):
    from torch.nn.utils import clip_grad as m
    r.add_from_module(m)
Exemplo n.º 14
0
def _optimizers_loader(r: Registry):
    from catalyst_rl.contrib.nn import optimizers as m
    r.add_from_module(m)