dicee.models.ultra
Pure PyTorch ULTRA, compatible with DeepGraphLearning/ULTRA link predictors.
Architecture and graph construction adapted from https://github.com/DeepGraphLearning/ULTRA at commit 427966ad8ed60420eef034063d44f3153addff90. Reference fixtures and the grouped sampling and adversarial loss implementations also follow this upstream work. Graphs are runtime context, excluded from the transferable state dictionary.
MIT License
Copyright (c) 2023 MilaGraph
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Attributes
Classes
ULTRA's DistMult/sum convolution, including the boundary message. |
|
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Pure PyTorch ULTRA with the official state dictionary and DICE triple order. |
Functions
|
Binary support of the hh, tt, ht, th incidence products, in upstream order. |
Module Contents
- dicee.models.ultra.UPSTREAM_COMMIT = '427966ad8ed60420eef034063d44f3153addff90'
- class dicee.models.ultra.RelationalConv(dim, project_relations=False)[source]
Bases:
torch.nn.ModuleULTRA’s DistMult/sum convolution, including the boundary message.
- inference_backend = 'auto'
- inference_compile = False
- layer_norm
- linear
- class dicee.models.ultra.RelNBFNet(dim=64, num_layers=6)[source]
Bases:
torch.nn.ModuleBase 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
to(), etc.Note
As per the example above, an
__init__()call to the parent class must be made before assignment on the child.- Variables:
training (bool) – Boolean represents whether this module is in training or evaluation mode.
- layers
- dim = 64
- class dicee.models.ultra.EntityNBFNet(dim=64, num_layers=6)[source]
Bases:
torch.nn.ModuleBase 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
to(), etc.Note
As per the example above, an
__init__()call to the parent class must be made before assignment on the child.- Variables:
training (bool) – Boolean represents whether this module is in training or evaluation mode.
- layers
- mlp
- dicee.models.ultra.build_relation_graph(edge_index, edge_type, num_entities, num_relations)[source]
Binary support of the hh, tt, ht, th incidence products, in upstream order.
- class dicee.models.ultra.ULTRA(args)[source]
Bases:
dicee.models.graph_model.GraphKGEPure PyTorch ULTRA with the official state dictionary and DICE triple order.
- name = 'ULTRA'
- config_prefix = 'ultra'
- graph_filename = 'ultra_graph.pt'
- checkpoint_hint = 'official ULTRA requires ultra_dim=64, ultra_num_layers=6; all keys and shapes must match'
- deterministic_inference = True
- dim
- num_layers
- relation_model
- entity_model
- relation_cache_mb
- projection_cache_mb