gigl.src.common.models.layers.task#

Attributes#

Classes#

BGRL

Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head and BGRL loss

DirectAU

DirectAU (https://arxiv.org/pdf/2206.12811.pdf) optimizes for representation quality in Collaborative Filtering from the

FeatureReconstruction

Masks out percentage of anchor nodes' features before attempting to recreate these embeddings

GBT

Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GBT loss

GRACE

Creates 2 augmented views of input graph with augmentations 1 and 2 and defines task-specific linear head for GRACE Loss

Margin

Helper class that provides a standard way to create an ABC using

NodeAnchorBasedLinkPredictionBaseTask

Helper class that provides a standard way to create an ABC using

NodeAnchorBasedLinkPredictionTasks

Retrieval

Helper class that provides a standard way to create an ABC using

Softmax

Helper class that provides a standard way to create an ABC using

TBGRL

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

WhiteningDecorrelation

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:
Return type:

Tuple[torch.Tensor, int]

update_offline_encoder(mm)[source]#
Parameters:

mm (float)

edge_drop_1 = 0.8[source]#
edge_drop_2 = 0.8[source]#
encoder[source]#
feat_drop_1 = 0.8[source]#
feat_drop_2 = 0.1[source]#
head[source]#
loss[source]#
offline_encoder[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

alignment_loss[source]#
gamma = 1.0[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

uniformity_loss[source]#
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:
Return type:

Tuple[torch.Tensor, int]

edge_drop = 0.3[source]#
encoder[source]#
loss[source]#
reconstruction_decoder[source]#
reconstruction_enc_dec[source]#
reconstruction_mask[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

edge_drop_1 = 0.2[source]#
edge_drop_2 = 0.2[source]#
encoder[source]#
feat_drop_1 = 0.2[source]#
feat_drop_2 = 0.2[source]#
loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

edge_drop_1 = 0.3[source]#
edge_drop_2 = 0.3[source]#
encoder[source]#
feat_drop_1 = 0.3[source]#
feat_drop_2 = 0.3[source]#
head[source]#
loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Abstractmethod:

Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

property task_name: str[source]#
Return type:

str

class gigl.src.common.models.layers.task.NodeAnchorBasedLinkPredictionTasks[source]#
add_task(task, weight)[source]#
Parameters:
Return type:

None

calculate_losses(batch_results, gbml_config_pb_wrapper, should_eval, device)[source]#
Parameters:
Return type:

Tuple[torch.Tensor, Dict[str, float]]

property result_types: Set[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

Set[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

should_enable_candidate_sampling_correction = False[source]#
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:
Return type:

Tuple[torch.Tensor, int]

loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

update_offline_encoder(mm)[source]#
Parameters:

mm (float)

edge_drop_1 = 0.8[source]#
edge_drop_2 = 0.8[source]#
edge_drop_neg = 0.95[source]#
encoder[source]#
feat_drop_1 = 0.8[source]#
feat_drop_2 = 0.1[source]#
feat_drop_neg = 0.95[source]#
head[source]#
loss[source]#
offline_encoder[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

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:
Return type:

Tuple[torch.Tensor, int]

edge_drop_1 = 0.2[source]#
edge_drop_2 = 0.2[source]#
encoder[source]#
feat_drop_1 = 0.2[source]#
feat_drop_2 = 0.2[source]#
head[source]#
loss[source]#
property result_types: List[gigl.src.common.models.layers.loss.ModelResultType][source]#
Return type:

List[gigl.src.common.models.layers.loss.ModelResultType]

gigl.src.common.models.layers.task.logger[source]#