Randomly mixup node embeddings or features with other nodes'. Args: x: The latent embedding or node feature. alpha: The hyperparameter controlling the mixup coefficient. Returns: torch.Tensor: Embeddings or features resulting from mixup.
(x: torch.Tensor, alpha: float)
| 44 | |
| 45 | |
| 46 | def mixup(x: torch.Tensor, alpha: float) -> torch.Tensor: |
| 47 | """ |
| 48 | Randomly mixup node embeddings or features with other nodes'. |
| 49 | |
| 50 | Args: |
| 51 | x: The latent embedding or node feature. |
| 52 | alpha: The hyperparameter controlling the mixup coefficient. |
| 53 | |
| 54 | Returns: |
| 55 | torch.Tensor: Embeddings or features resulting from mixup. |
| 56 | """ |
| 57 | device = x.device |
| 58 | mixup_idx = get_mixup_idx(x).to(device) |
| 59 | lambda_ = Uniform(alpha, 1.).sample([1]).to(device) |
| 60 | x = (1 - lambda_) * x + lambda_ * x[mixup_idx] |
| 61 | return x |
| 62 | |
| 63 | |
| 64 | def multiinstance_mixup(x1: torch.Tensor, x2: torch.Tensor, |
nothing calls this directly
no test coverage detected