mwptoolkit.module.Layer.graph_layers

class mwptoolkit.module.Layer.graph_layers.GraphConvolution(in_features, out_features, bias=True)[source]

Bases: Module

Simple GCN layer, similar to https://arxiv.org/abs/1609.02907

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

forward(input, adj)[source]

Defines 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.

reset_parameters()[source]
training: bool
class mwptoolkit.module.Layer.graph_layers.LayerNorm(features, eps=1e-06)[source]

Bases: Module

Construct a layernorm module (See citation for details).

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

forward(x)[source]
Parameters

x (torch.Tensor) – input variable.

Returns

output variable.

Return type

torch.Tensor

training: bool
class mwptoolkit.module.Layer.graph_layers.MeanAggregator(input_dim, output_dim, activation=<function relu>, concat=False)[source]

Bases: Module

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

forward(inputs)[source]

Defines 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.

training: bool
class mwptoolkit.module.Layer.graph_layers.PositionwiseFeedForward(d_model, d_ff, d_out, dropout=0.1)[source]

Bases: Module

Implements FFN equation.

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

forward(x)[source]
Parameters

x (torch.Tensor) – input variable.

Returns

output variable.

Return type

torch.Tensor

training: bool