Miscellaneous Networks#

Classes#

class MultiNetwork(name, *nets, save_outputs=False, suppress_warning=False, root='', config='', in_shape=None, out_shapes=None, defaults=None)[source]#

Bases: BaseNetwork[TypedModuleList[CompatibleNetwork | Network]]

Network class to hold multiple networks and train them together.

Attributes:
namestr

Name of the network, used for saving

versionstr

NetLoader version string

checkpointslist[TensorListLike]

Outputs from each checkpoint with each Tensor having shape (N,…) and type float, where N is the batch size

kl_lossTensor

KL divergence loss on the latent space of shape (1) and type float, if using a sample layer

layersTypedModuleList[CompatibleNetwork | Network]

Network construction

Overloads:

class MultiNetwork(self, name: str, *nets: torch.nn.modules.module.Module | torch.nn.modules.container.ModuleList | CompatibleNetwork | Network, save_outputs: bool = ...) None
class MultiNetwork(self, name: str, *nets: str | torch.nn.modules.module.Module | torch.nn.modules.container.ModuleList | CompatibleNetwork | Network | Config, save_outputs: bool = ..., suppress_warning: bool = ..., root: str = ..., config: str = ..., in_shape: list[int] | list[list[int]] | tuple[int, ...] | None = ..., out_shapes: list[list[int]] | None = ..., defaults: list[dict[str, Any]] | dict[str, Any] | None = ...) None
Parameters:
namestr

Name of the network, used for saving

*nets: str | nn.Module | nn.ModuleList | CompatibleNetwork | Network | Config

Networks to combine sequentially

save_outputsbool, Optional

If outputs from each network should be saved, default = False

suppress_warningbool, Optional

If output shape mismatch warning should be suppressed, default = False

rootstr, Optional

Root directory to prepend to config file path if any network is a string or Config

configstr, Optional

Path to the network config directory if any network is a string

in_shapelist[int] | list[list[int]] | tuple[int, …], Optional

Input shape for the first network in the MultiNetwork if any network is a string or Config

out_shapeslist[list[int]], Optional

Output shapes for each network in the MultiNetwork if any network is a string or Config

defaultslist[dict[str, Any]] | dict[str, Any] | NoneType, Optional

Default values for the parameters for each type of layer for all or each network

forward(x)[source]#

Forward pass through all networks in the MultiNetwork.

Parameters:
xTensorListLike

Input tensor(s) with shape (N,…) and type float, where N is the batch size

Returns:
TensorListLike

Output tensor from the network with shape (N,…) and type float

get_config(dict_=True)[source]#

Returns the network configuration.

Overloads:

get_config(self, dict_: Literal[True] = ...) dict[str, Any]
get_config(self, dict_: Literal[False] = ...) Config
Parameters:
dict_bool, Optional

If configuration should be returned as a dictionary, default = True

Returns:
dict[str, Any] | Config

Network configuration

to(*args, **kwargs)[source]#

See torch.nn.Module.to().