lisbet.modeling.modules_extra#

Extra modules for various tasks, such as positional embedding and MLP.

Classes

MLP(in_features, out_features, hid_features)

Multilayer perceptron.

PosEmbedding(max_len, emb_dim[, device, dtype])

Positional embedding.

class lisbet.modeling.modules_extra.PosEmbedding(max_len, emb_dim, device=None, dtype=None)[source]#

Positional embedding.

__init__(max_len, emb_dim, device=None, dtype=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

reset_parameters()[source]#
forward(x)[source]#

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

extra_repr()[source]#

Return the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

class lisbet.modeling.modules_extra.MLP(in_features, out_features, hid_features)[source]#

Multilayer perceptron.

__init__(in_features, out_features, hid_features)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.