MCPcopy Create free account
hub / github.com/TPCD/DCCL / create_compositional_graph

Method create_compositional_graph

model/attribute_transformer.py:828–841  ·  view source on GitHub ↗
(self, attribute_label)

Source from the content-addressed store, hash-verified

826 return a_t_ab
827
828 def create_compositional_graph(self, attribute_label):
829 att_num = attribute_label.size(1)
830 copy_attribute_label = attribute_label.detach()
831 adj_list = []
832 for row in copy_attribute_label:
833 adj = torch.zeros((att_num + 1, att_num + 1))
834 non_zero_positions = torch.nonzero(row)
835 for p in non_zero_positions:
836 adj[p, att_num] = 1
837 adj[att_num, p] = 1
838 adj_list.append(adj)
839 adj_matrix = torch.stack(adj_list, dim=0).to(device=self.device)
840
841 return adj_matrix
842
843
844class Meta_Attribute_Generator1(nn.Module):

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected