From b59efc524827d62ec46f8c85c19849c30fadb652 Mon Sep 17 00:00:00 2001 From: ay27 Date: Thu, 1 Feb 2018 22:06:59 +0800 Subject: [PATCH] 1. fix requirements 2. make compatible with pytorch 0.3.0 --- MessageFunction.py | 2 +- ReadoutFunction.py | 2 +- models/MPNN.py | 2 +- requirements.txt | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MessageFunction.py b/MessageFunction.py index 9619523..38007ff 100644 --- a/MessageFunction.py +++ b/MessageFunction.py @@ -171,7 +171,7 @@ def m_mpnn(self, h_v, h_w, e_vw, opt={}): edge_output = self.learn_modules[0](e_vw) edge_output = edge_output.view(-1, self.args['out'], self.args['in']) - h_w_rows = h_w[..., None].expand(h_w.size(0), h_v.size(1), h_w.size(1)).contiguous() + h_w_rows = h_w[..., None].expand(h_w.size(0), h_w.size(1), h_v.size(1)).contiguous() h_w_rows = h_w_rows.view(-1, self.args['in']) diff --git a/ReadoutFunction.py b/ReadoutFunction.py index 3ea55a5..a3a18ba 100644 --- a/ReadoutFunction.py +++ b/ReadoutFunction.py @@ -165,7 +165,7 @@ def r_mpnn(self, h): nn_res = nn.Sigmoid()(self.learn_modules[0](torch.cat([h[0][i,:,:], h[-1][i,:,:]], 1)))*self.learn_modules[1](h[-1][i,:,:]) # Delete virtual nodes - nn_res = (torch.sum(h[0][i,:,:],1).expand_as(nn_res)>0).type_as(nn_res)* nn_res + nn_res = (torch.sum(h[0][i,:,:],1)[...,None].expand_as(nn_res)>0).type_as(nn_res)* nn_res aux[i,:] = torch.sum(nn_res,0) diff --git a/models/MPNN.py b/models/MPNN.py index a609db2..13bf002 100644 --- a/models/MPNN.py +++ b/models/MPNN.py @@ -86,7 +86,7 @@ def forward(self, g, h_in, e): h_t = self.u[0].forward(h[t], m) # Delete virtual nodes - h_t = (torch.sum(h_in, 2).expand_as(h_t) > 0).type_as(h_t) * h_t + h_t = (torch.sum(h_in, 2)[..., None].expand_as(h_t) > 0).type_as(h_t) * h_t h.append(h_t) # Readout diff --git a/requirements.txt b/requirements.txt index 6313d4c..9321e1a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ torch torchvision numpy wget -networkx +networkx=1.11 joblib tensorboard +tensorboard_logger \ No newline at end of file