Module ml4opf.models.pca_nn.pca_nn
Classes
class ACPCANN (opfmodel: OPFModel,
slices: list[slice],
pca_w: torch.Tensor,
pca_mu: torch.Tensor,
optimizer: str = 'adam',
loss: str = 'mse',
hidden_sizes: list[int] = [100, 100],
activation: str = 'relu',
boundrepair: str = 'none',
learning_rate: float = 0.001,
weight_init_seed: int = 42)-
Hooks to be used in LightningModule.
Ancestors
- PCANN
- ACBasicNN
- BasicNN
- pytorch_lightning.core.module.LightningModule
- lightning_fabric.utilities.device_dtype_mixin._DeviceDtypeModuleMixin
- pytorch_lightning.core.mixins.hparams_mixin.HyperparametersMixin
- pytorch_lightning.core.hooks.ModelHooks
- pytorch_lightning.core.hooks.DataHooks
- pytorch_lightning.core.hooks.CheckpointHooks
- torch.nn.modules.module.Module
Inherited members
class ACPCANeuralNet (config: dict,
problem: OPFProblem)-
A feed-forward neural network with a PCA layer at the end. The PCA is computed on initialization using the training set.
Ancestors
Class variables
var model : ACPCANN
Inherited members
class DCPCANN (opfmodel: OPFModel,
slices: list[slice],
pca_w: torch.Tensor,
pca_mu: torch.Tensor,
optimizer: str = 'adam',
loss: str = 'mse',
hidden_sizes: list[int] = [100, 100],
activation: str = 'relu',
boundrepair: str = 'none',
learning_rate: float = 0.001,
weight_init_seed: int = 42)-
Hooks to be used in LightningModule.
Ancestors
- PCANN
- DCBasicNN
- BasicNN
- pytorch_lightning.core.module.LightningModule
- lightning_fabric.utilities.device_dtype_mixin._DeviceDtypeModuleMixin
- pytorch_lightning.core.mixins.hparams_mixin.HyperparametersMixin
- pytorch_lightning.core.hooks.ModelHooks
- pytorch_lightning.core.hooks.DataHooks
- pytorch_lightning.core.hooks.CheckpointHooks
- torch.nn.modules.module.Module
Inherited members
class DCPCANeuralNet (config: dict,
problem: OPFProblem)-
A feed-forward neural network with a PCA layer at the end. The PCA is computed on initialization using the training set.
Ancestors
Class variables
var model : DCPCANN
Inherited members
class EDPCANN (opfmodel: OPFModel,
slices: list[slice],
pca_w: torch.Tensor,
pca_mu: torch.Tensor,
optimizer: str = 'adam',
loss: str = 'mse',
hidden_sizes: list[int] = [100, 100],
activation: str = 'relu',
boundrepair: str = 'none',
learning_rate: float = 0.001,
weight_init_seed: int = 42)-
Hooks to be used in LightningModule.
Ancestors
- PCANN
- EDBasicNN
- BasicNN
- pytorch_lightning.core.module.LightningModule
- lightning_fabric.utilities.device_dtype_mixin._DeviceDtypeModuleMixin
- pytorch_lightning.core.mixins.hparams_mixin.HyperparametersMixin
- pytorch_lightning.core.hooks.ModelHooks
- pytorch_lightning.core.hooks.DataHooks
- pytorch_lightning.core.hooks.CheckpointHooks
- torch.nn.modules.module.Module
Inherited members
class EDPCANeuralNet (config: dict,
problem: OPFProblem)-
A feed-forward neural network with a PCA layer at the end. The PCA is computed on initialization using the training set.
Ancestors
Class variables
var model : EDPCANN
Inherited members
class InversePCALayer (pca_w: torch.Tensor, pca_mu: torch.Tensor)
-
Base class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes::
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:
to
, etc.Note
As per the example above, an
__init__()
call to the parent class must be made before assignment on the child.:ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Ancestors
- torch.nn.modules.module.Module
Methods
def forward(self, x: torch.Tensor) ‑> torch.Tensor
-
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the :class:
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
class PCANN (opfmodel: OPFModel,
slices: list[slice],
pca_w: torch.Tensor,
pca_mu: torch.Tensor,
optimizer: str = 'adam',
loss: str = 'mse',
hidden_sizes: list[int] = [100, 100],
activation: str = 'relu',
boundrepair: str = 'none',
learning_rate: float = 0.001,
weight_init_seed: int = 42)-
Hooks to be used in LightningModule.
Ancestors
- BasicNN
- pytorch_lightning.core.module.LightningModule
- lightning_fabric.utilities.device_dtype_mixin._DeviceDtypeModuleMixin
- pytorch_lightning.core.mixins.hparams_mixin.HyperparametersMixin
- pytorch_lightning.core.hooks.ModelHooks
- pytorch_lightning.core.hooks.DataHooks
- pytorch_lightning.core.hooks.CheckpointHooks
- torch.nn.modules.module.Module
Subclasses
Methods
def make_network(self, pca_w: torch.Tensor, pca_mu: torch.Tensor)
Inherited members
class PCANeuralNet (config: dict,
problem: OPFProblem)-
A feed-forward neural network with a PCA layer at the end. The PCA is computed on initialization using the training set.
Ancestors
- BasicNeuralNet
- OPFModel
- abc.ABC
Subclasses
Class variables
var model : PCANN
Methods
def make_training_model(self, force_new_model=False)
Inherited members
class SOCPCANN (opfmodel: OPFModel,
slices: list[slice],
pca_w: torch.Tensor,
pca_mu: torch.Tensor,
optimizer: str = 'adam',
loss: str = 'mse',
hidden_sizes: list[int] = [100, 100],
activation: str = 'relu',
boundrepair: str = 'none',
learning_rate: float = 0.001,
weight_init_seed: int = 42)-
Hooks to be used in LightningModule.
Ancestors
- PCANN
- SOCBasicNN
- BasicNN
- pytorch_lightning.core.module.LightningModule
- lightning_fabric.utilities.device_dtype_mixin._DeviceDtypeModuleMixin
- pytorch_lightning.core.mixins.hparams_mixin.HyperparametersMixin
- pytorch_lightning.core.hooks.ModelHooks
- pytorch_lightning.core.hooks.DataHooks
- pytorch_lightning.core.hooks.CheckpointHooks
- torch.nn.modules.module.Module
Inherited members
class SOCPCANeuralNet (config: dict,
problem: OPFProblem)-
A feed-forward neural network with a PCA layer at the end. The PCA is computed on initialization using the training set.
Ancestors
Class variables
var model : SOCPCANN
Inherited members