Skip to content

Commit

Permalink
Merge pull request tkipf#15 from amar-iastate/master
Browse files Browse the repository at this point in the history
Small Modifications to make it compatible with python 3.6.3
  • Loading branch information
tkipf authored Aug 5, 2018
2 parents 8d8e0bd + c91f69c commit f437c8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pygcn/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def forward(self, x, adj):
x = F.relu(self.gc1(x, adj))
x = F.dropout(x, self.dropout, training=self.training)
x = self.gc2(x, adj)
return F.log_softmax(x)
return F.log_softmax(x, dim=1)
8 changes: 4 additions & 4 deletions pygcn/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def train(epoch):
loss_val = F.nll_loss(output[idx_val], labels[idx_val])
acc_val = accuracy(output[idx_val], labels[idx_val])
print('Epoch: {:04d}'.format(epoch+1),
'loss_train: {:.4f}'.format(loss_train.data[0]),
'acc_train: {:.4f}'.format(acc_train.data[0]),
'loss_val: {:.4f}'.format(loss_val.data[0]),
'acc_val: {:.4f}'.format(acc_val.data[0]),
'loss_train: {:.4f}'.format(loss_train.item()),
'acc_train: {:.4f}'.format(acc_train.item()),
'loss_val: {:.4f}'.format(loss_val.item()),
'acc_val: {:.4f}'.format(acc_val.item()),
'time: {:.4f}s'.format(time.time() - t))


Expand Down
4 changes: 2 additions & 2 deletions pygcn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def accuracy(output, labels):
def sparse_mx_to_torch_sparse_tensor(sparse_mx):
"""Convert a scipy sparse matrix to a torch sparse tensor."""
sparse_mx = sparse_mx.tocoo().astype(np.float32)
indices = torch.from_numpy(np.vstack((sparse_mx.row,
sparse_mx.col))).long()
indices = torch.from_numpy(
np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))
values = torch.from_numpy(sparse_mx.data)
shape = torch.Size(sparse_mx.shape)
return torch.sparse.FloatTensor(indices, values, shape)

0 comments on commit f437c8c

Please sign in to comment.