mipcandy.layer#

Module Contents#

Classes#

Functions#

API#

mipcandy.layer.batch_int_multiply(f: float, *n: int) Generator[int, None, None][source]#
mipcandy.layer.batch_int_divide(f: float, *n: int) Generator[int, None, None][source]#
class mipcandy.layer.LayerT(m: type[torch.nn.Module], **kwargs)[source]#

Bases: object

Initialization

update(*, must_exist: bool = True, inplace: bool = False, **kwargs) Self[source]#
assemble(*args, **kwargs) torch.nn.Module[source]#
copy() Self[source]#
class mipcandy.layer.HasDevice(device: mipcandy.types.Device)[source]#

Bases: object

Initialization

device(*, device: mipcandy.types.Device | None = None) None | mipcandy.types.Device[source]#
mipcandy.layer.auto_device() mipcandy.types.Device[source]#
class mipcandy.layer.WithPaddingModule(device: mipcandy.types.Device)[source]#

Bases: mipcandy.layer.HasDevice

Initialization

build_padding_module() torch.nn.Module | None[source]#
build_restoring_module(padding_module: torch.nn.Module | None) torch.nn.Module | None[source]#
_lazy_load_padding_module() None[source]#
get_padding_module() torch.nn.Module | None[source]#
get_restoring_module() torch.nn.Module | None[source]#
class mipcandy.layer.WithCheckpoint[source]#

Bases: object

abstractmethod load_checkpoint(model: torch.nn.Module, path: str | os.PathLike[str]) torch.nn.Module[source]#
abstractmethod save_checkpoint(model: torch.nn.Module, path: str | os.PathLike[str]) None[source]#
class mipcandy.layer.WithNetwork(device: mipcandy.types.Device)[source]#

Bases: mipcandy.layer.WithCheckpoint, mipcandy.layer.HasDevice

Initialization

load_checkpoint(model: torch.nn.Module, path: str | os.PathLike[str]) torch.nn.Module[source]#
save_checkpoint(model: torch.nn.Module, path: str | os.PathLike[str]) None[source]#
abstractmethod build_network(example_shape: mipcandy.types.AmbiguousShape) torch.nn.Module[source]#
static compile_model(model: torch.nn.Module) torch.nn.Module[source]#
build_network_from_checkpoint(example_shape: mipcandy.types.AmbiguousShape, path: str | os.PathLike[str]) torch.nn.Module[source]#

Internally exposed interface for overriding. Use load_model() instead.

load_model(example_shape: mipcandy.types.AmbiguousShape, compile_model: bool, *, path: str | os.PathLike[str] | None = None) torch.nn.Module[source]#
save_model(model: torch.nn.Module, path: str | os.PathLike[str]) None[source]#