Module flowcon.nn.nets.nets_util
Functions
def first_layer_sine_init(m)
def gen_sine_init(SINE_FREQUENCY=7)
def init_weights_elu(m)
def init_weights_normal(m)
def init_weights_selu(m)
def init_weights_trunc_normal(m)
def init_weights_xavier(m)
Classes
class Sine (sine_frequency=4.0)
-
Base class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing to nest them 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): 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 have their parameters converted too 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
:param sine_frequency: :return:
Expand source code
class Sine(nn.Module): def __init__(self, sine_frequency=4.): """ :param sine_frequency: :return: """ super().__init__() self.SINE_FREQUENCY = sine_frequency def forward(self, input): # See paper sec. 3.2, final paragraph, and supplement Sec. 1.5 for discussion of factor 30 return torch.sin(self.SINE_FREQUENCY * input)
Ancestors
- torch.nn.modules.module.Module
Class variables
var call_super_init : bool
var dump_patches : bool
var training : bool
Methods
def forward(self, input) ‑> Callable[..., Any]
-
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.