gigl.src.common.models.layers.task#
Attributes#
Classes#
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head and BGRL loss |
|
DirectAU (https://arxiv.org/pdf/2206.12811.pdf) optimizes for representation quality in Collaborative Filtering from the |
|
Masks out percentage of anchor nodes' features before attempting to recreate these embeddings |
|
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GBT loss |
|
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GRACE Loss |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Creates 3 augmented views of input graph with positive augmentations 1, 2 and negative augmentation 3 and defines task-specific linear head and TBGRL loss |
|
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for Whitening Decorrelation Loss |
Module Contents#
- class gigl.src.common.models.layers.task.BGRL(encoder, feat_drop_1=0.8, edge_drop_1=0.8, feat_drop_2=0.1, edge_drop_2=0.8)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head and BGRL loss
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
feat_drop_1 (float)
edge_drop_1 (float)
feat_drop_2 (float)
edge_drop_2 (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.DirectAU(gamma=1.0, alpha=2.0, temperature=2.0)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
DirectAU (https://arxiv.org/pdf/2206.12811.pdf) optimizes for representation quality in Collaborative Filtering from the perspective of alignment and uniformity on the hypersphere. It does so without the use of negative sampling and only uses the embeddings generated from the encoder.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
gamma (float)
alpha (float)
temperature (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.FeatureReconstruction(encoder, alpha=3.0, edge_drop=0.3)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Masks out percentage of anchor nodes’ features before attempting to recreate these embeddings
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
alpha (float)
edge_drop (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.GBT(encoder, feat_drop_1=0.2, edge_drop_1=0.2, feat_drop_2=0.2, edge_drop_2=0.2)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GBT loss
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
feat_drop_1 (float)
edge_drop_1 (float)
feat_drop_2 (float)
edge_drop_2 (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.GRACE(encoder, temperature=0.001, feat_drop_1=0.3, edge_drop_1=0.3, feat_drop_2=0.3, edge_drop_2=0.3)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GRACE Loss
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
temperature (float)
feat_drop_1 (float)
edge_drop_1 (float)
feat_drop_2 (float)
edge_drop_2 (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.Margin(margin=0.5)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Helper class that provides a standard way to create an ABC using inheritance.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
margin (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.NodeAnchorBasedLinkPredictionBaseTask(*args, **kwargs)[source]#
Bases:
abc.ABC
,torch.nn.Module
Helper class that provides a standard way to create an ABC using inheritance.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- abstract forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Abstractmethod:
- Return type:
- class gigl.src.common.models.layers.task.NodeAnchorBasedLinkPredictionTasks[source]#
-
- calculate_losses(batch_results, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
batch_results (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, Dict[str, float]]
- property result_types: Set[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.Retrieval(loss=None, temperature=0.07, remove_accidental_hits=True, should_enable_candidate_sampling_correction=False, count_min_sketch_width=10000, count_min_sketch_depth=10)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Helper class that provides a standard way to create an ABC using inheritance.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
loss (Optional[torch.nn.Module])
temperature (float)
remove_accidental_hits (bool)
should_enable_candidate_sampling_correction (bool)
count_min_sketch_width (int)
count_min_sketch_depth (int)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.Softmax(softmax_temperature=0.07)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Helper class that provides a standard way to create an ABC using inheritance.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
softmax_temperature (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.TBGRL(encoder, neg_lambda=0.12, feat_drop_1=0.8, edge_drop_1=0.8, feat_drop_2=0.1, edge_drop_2=0.8, feat_drop_neg=0.95, edge_drop_neg=0.95)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Creates 3 augmented views of input graph with positive augmentations 1, 2 and negative augmentation 3 and defines task-specific linear head and TBGRL loss
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
neg_lambda (float)
feat_drop_1 (float)
edge_drop_1 (float)
feat_drop_2 (float)
edge_drop_2 (float)
feat_drop_neg (float)
edge_drop_neg (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type:
- class gigl.src.common.models.layers.task.WhiteningDecorrelation(encoder, lambd=0.001, feat_drop_1=0.2, edge_drop_1=0.2, feat_drop_2=0.2, edge_drop_2=0.2)[source]#
Bases:
NodeAnchorBasedLinkPredictionBaseTask
Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for Whitening Decorrelation Loss
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
encoder (torch.nn.Module)
lambd (float)
feat_drop_1 (float)
edge_drop_1 (float)
feat_drop_2 (float)
edge_drop_2 (float)
- forward(task_input, gbml_config_pb_wrapper, should_eval, device)[source]#
- Parameters:
task_input (gigl.src.common.types.task_inputs.NodeAnchorBasedLinkPredictionTaskInputs)
gbml_config_pb_wrapper (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
should_eval (bool)
device (torch.device)
- Return type:
Tuple[torch.Tensor, int]
- property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
- Return type: