Skip to content

Instantly share code, notes, and snippets.

@tomonori-masui
Last active September 16, 2022 04:58
Show Gist options
  • Save tomonori-masui/74938b7d96f41c30ed4463828bc4a708 to your computer and use it in GitHub Desktop.
Save tomonori-masui/74938b7d96f41c30ed4463828bc4a708 to your computer and use it in GitHub Desktop.
MLP on PyG graph data
import torch.nn as nn
class MLP(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.Sequential(
nn.Linear(dataset.num_node_features, 64),
nn.ReLU(),
nn.Linear(64, 32),
nn.ReLU(),
nn.Linear(32, dataset.num_classes)
)
def forward(self, data):
x = data.x # only using node features (x)
output = self.layers(x)
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment