-
I would like to train_loader = DataLoader(train_dataset, batch_size=128, shuffle=True)
test_loader = DataLoader(test_dataset, batch_size=128)
d = train_dataset
def normalized_cut_2d(edge_index, pos):
row, col = edge_index
edge_attr = torch.norm(pos[row] - pos[col], p=2, dim=1)
return normalized_cut(edge_index, edge_attr, num_nodes=pos.size(0))
class Net(torch.nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = SplineConv(1, 32, dim=2, kernel_size=5)
self.conv2 = SplineConv(32, 64, dim=2, kernel_size=5)
self.fc1 = torch.nn.Linear(64, 128)
self.fc2 = torch.nn.Linear(128, 2)
def forward(self, data):
data.x = data.x.to(torch.float32)
data.y = data.y.to(torch.float32)
data.edge_attr = data.edge_attr.to(torch.float32)
data.pos = data.pos.to(torch.float32)
data.x = F.tanh(self.conv1(data.x, data.edge_index, data.edge_attr))
weight = normalized_cut_2d(data.edge_index, data.pos)
cluster = graclus(data.edge_index, weight, data.x.size(0))
data.edge_attr = None
data = max_pool(cluster, data, transform=transform)
data.x = F.tanh(self.conv2(data.x, data.edge_index, data.edge_attr))
weight = normalized_cut_2d(data.edge_index, data.pos)
cluster = graclus(data.edge_index, weight, data.x.size(0))
x, batch = max_pool_x(cluster, data.x, data.batch)
x = global_mean_pool(x, batch)
x = F.tanh(self.fc1(x))
x = self.fc2(x)
x = x.view(-1)
return x.to(torch.float32) I saw your previous posting about |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
May 27, 2021
Replies: 1 comment 4 replies
-
You can upsample using x = ...
x_unpooled = x[cluster] |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
hkim716
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can upsample using
cluster
, e.g.: