mwptoolkit.module.Graph.graph_module

class mwptoolkit.module.Graph.graph_module.Graph_Module(indim, hiddim, outdim, dropout=0.3)[source]

Bases: Module

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

b_normal(adj)[source]
forward(graph_nodes, graph)[source]
Parameters

graph_nodes (torch.Tensor) – input features, shape [batch_size, node_num, in_feat_dim]

Returns

graph_encode_features, shape [batch_size, node_num, out_feat_dim]

Return type

torch.Tensor

get_adj(graph_nodes)[source]
Parameters

graph_nodes (torch.Tensor) – input features, shape [batch_size, node_num, in_feat_dim]

Returns

adjacency matrix, shape [batch_size, node_num, node_num]

Return type

torch.Tensor

normalize(A, symmetric=True)[source]
Parameters

A (torch.Tensor) – adjacency matrix (node_num, node_num)

Returns

adjacency matrix (node_num, node_num)

training: bool
class mwptoolkit.module.Graph.graph_module.Num_Graph_Module(node_dim)[source]

Bases: Module

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

forward(node, graph1, graph2)[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.

normalize(graph, symmetric=True)[source]
training: bool
class mwptoolkit.module.Graph.graph_module.Parse_Graph_Module(hidden_size)[source]

Bases: Module

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

forward(node, graph)[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.

normalize(graph, symmetric=True)[source]
training: bool