daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Mar 8th, 2019 81 in 13 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     def reduce_func(self, nodes):
  2.         global LocalTimeCounter_1
  3.         LocalTimeCounter_1.start()
  4.  
  5.         # check the device that the model is running on
  6.         device = next(self.parameters()).device
  7.         self.device = device
  8.         LocalTimeCounter_1.record("Device Time")
  9.  
  10.         edge_labels = nodes.mailbox['edge_label'] # edge types  (batch_size, in_degree)
  11.         h_mailbox = nodes.mailbox['h']
  12.         c_mailbox = nodes.mailbox['c']
  13.         LocalTimeCounter_1.record("Mailbox Time")
  14.  
  15.         edge_labels = edge_labels.repeat(1, 1, self.h_size) # mask for Type 1 edges
  16.         LocalTimeCounter_1.record("Edge Label Repeat Time")
  17.  
  18.         #edge_labels_reverse = (-1 * edge_labels) + 1 # mask for Type 0 edges
  19.         edge_labels_reverse = 1 - edge_labels # mask for Type 0 edges
  20.         LocalTimeCounter_1.record("Edge Label Reverse Time")
  21.  
  22.         h_t1 = edge_labels * h_mailbox
  23.         h_t0 = edge_labels_reverse * h_mailbox
  24.         LocalTimeCounter_1.record("Sum Time 1")
  25.  
  26.         h_two_type = torch.cat((h_t0, h_t1), 2) # (batch_size, in_degree, 2*h_size)
  27.         LocalTimeCounter_1.record("Sum Time 2")
  28.  
  29.         iou_mid = torch.sum(self.U_iou(h_two_type), 1) # (batch_size, 3 * h_size)
  30.         LocalTimeCounter_1.record("Sum Time 3")
  31.  
  32.         f_mid = self.U_f(h_two_type) # (batch_size, in_degree, h_size)
  33.         LocalTimeCounter_1.record("Sum Time 4")
  34.  
  35.         in_degree = f_mid.size(1)
  36.         f = torch.sigmoid(nodes.data['wf_x'].unsqueeze(1).repeat(1, in_degree, 1) + f_mid + self.b_f)
  37.         LocalTimeCounter_1.record("Post Time 1")
  38.  
  39.         c = torch.sum(f * c_mailbox, 1)
  40.         LocalTimeCounter_1.record("Post Time 2")
  41.  
  42.         return {'iou_mid': iou_mid,  'c': c}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top