Skip to content
Permalink
Browse files

py 2.7

  • Loading branch information...
rusty1s committed May 13, 2019
1 parent c3eeb36 commit 3af3aea9b25fae8064a47d60ea3b462f73545764
@@ -24,6 +24,7 @@ install:
- pip install flake8
- pip install torch-scatter torch-sparse torch-cluster torch-spline-conv
- pip install codecov
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; pip install scikit-learn=0.20; fi
script:
- pycodestyle .
- flake8 .
@@ -28,9 +28,9 @@ def random_planetoid_splits(data, num_classes):
index = index[torch.randperm(index.size(0))]
indices.append(index)

train_index = torch.cat([index[:20] for index in indices], dim=0)
train_index = torch.cat([i[:20] for i in indices], dim=0)

rest_index = torch.cat([index[20:] for index in indices], dim=0)
rest_index = torch.cat([i[20:] for i in indices], dim=0)
rest_index = rest_index[torch.randperm(rest_index.size(0))]

data.train_mask = index_to_mask(train_index, size=data.num_nodes)
@@ -96,7 +96,7 @@ def process(self):

if self.pre_transform is not None:
data_list = [self.get(idx) for idx in range(len(self))]
data_list = [self.pre_transform(data) for data in data_list]
data_list = [self.pre_transform(d) for d in data_list]
self.data, self.slices = self.collate(data_list)

if self.pre_transform is not None:
@@ -44,7 +44,7 @@ def forward(self, src):
src = src.transpose(0, 1).contiguous()
out = torch.matmul(src, self.weight)
out = out.transpose(1, 0).contiguous()
out = out.view(*size, self.out_channels)
out = out.view(*(size + [self.out_channels]))
else:
out = torch.matmul(src, self.weight.squeeze(0))

@@ -146,19 +146,21 @@ def forward(self, query, key, value):
size = list(query.size())[:-2]
out_channels_per_head = self.out_channels // self.heads

query = query.view(*size, query.size(-2), self.heads,
out_channels_per_head).transpose(-2, -3)
key = key.view(*size, key.size(-2), self.heads,
out_channels_per_head).transpose(-2, -3)
value = value.view(*size, value.size(-2), self.heads,
out_channels_per_head).transpose(-2, -3)
query_size = size + [query.size(-2), self.heads, out_channels_per_head]
query = query.view(*query_size).transpose(-2, -3)

key_size = size + [key.size(-2), self.heads, out_channels_per_head]
key = key.view(*key_size).transpose(-2, -3)

value_size = size + [value.size(-2), self.heads, out_channels_per_head]
value = value.view(*value_size).transpose(-2, -3)

# Output: [*, heads, query_entries, out_channels // heads]
out = super(MultiHead, self).forward(query, key, value)
# Output: [*, query_entries, heads, out_channels // heads]
out = out.transpose(-3, -2).contiguous()
# Output: [*, query_entries, out_channels]
out = out.view(*size, query.size(-2), self.out_channels)
out = out.view(*(size + [query.size(-2), self.out_channels]))

return out

@@ -13,7 +13,7 @@ def read_ply(path):
face = None
if 'face' in data:
faces = data['face']['vertex_indices']
faces = [torch.tensor(face, dtype=torch.long) for face in faces]
faces = [torch.tensor(f, dtype=torch.long) for f in faces]
face = torch.stack(faces, dim=-1)

data = Data(pos=pos)
@@ -23,10 +23,11 @@ def __call__(self, data):
deg = degree(row, N, dtype=torch.float)
deg_col = deg[col]

value = 1e16
value = 1e9
min_deg, _ = scatter_min(deg_col, row, dim_size=N, fill_value=value)
min_deg[min_deg == value] = 0
max_deg, _ = scatter_max(deg_col, row, dim_size=N)
max_deg, _ = scatter_max(deg_col, row, dim_size=N, fill_value=-value)
max_deg[max_deg == -value] = 0
mean_deg = scatter_mean(deg_col, row, dim_size=N)
std_deg = scatter_std(deg_col, row, dim_size=N)

0 comments on commit 3af3aea

Please sign in to comment.
You can’t perform that action at this time.