|
|
@@ -37,7 +37,9 @@ class DEDICOMDecoder(torch.nn.Module): |
|
|
|
product1 = torch.mm(inputs_row, relation)
|
|
|
|
product2 = torch.mm(product1, self.global_interaction)
|
|
|
|
product3 = torch.mm(product2, relation)
|
|
|
|
rec = torch.mm(product3, torch.transpose(inputs_col, 0, 1))
|
|
|
|
rec = torch.bmm(product3.view(product3.shape[0], 1, product3.shape[1]),
|
|
|
|
inputs_col.view(inputs_col.shape[0], inputs_col.shape[1], 1))
|
|
|
|
rec = torch.flatten(rec)
|
|
|
|
outputs.append(self.activation(rec))
|
|
|
|
return outputs
|
|
|
|
|
|
|
@@ -67,7 +69,9 @@ class DistMultDecoder(torch.nn.Module): |
|
|
|
relation = torch.diag(self.relation[k])
|
|
|
|
|
|
|
|
intermediate_product = torch.mm(inputs_row, relation)
|
|
|
|
rec = torch.mm(intermediate_product, torch.transpose(inputs_col, 0, 1))
|
|
|
|
rec = torch.bmm(intermediate_product.view(intermediate_product.shape[0], 1, intermediate_product.shape[1]),
|
|
|
|
inputs_col.view(inputs_col.shape[0], inputs_col.shape[1], 1))
|
|
|
|
rec = torch.flatten(rec)
|
|
|
|
outputs.append(self.activation(rec))
|
|
|
|
return outputs
|
|
|
|
|
|
|
@@ -95,7 +99,9 @@ class BilinearDecoder(torch.nn.Module): |
|
|
|
inputs_col = dropout(inputs_col, 1.-self.drop_prob)
|
|
|
|
|
|
|
|
intermediate_product = torch.mm(inputs_row, self.relation[k])
|
|
|
|
rec = torch.mm(intermediate_product, torch.transpose(inputs_col, 0, 1))
|
|
|
|
rec = torch.bmm(intermediate_product.view(intermediate_product.shape[0], 1, intermediate_product.shape[1]),
|
|
|
|
inputs_col.view(inputs_col.shape[0], inputs_col.shape[1], 1))
|
|
|
|
rec = torch.flatten(rec)
|
|
|
|
outputs.append(self.activation(rec))
|
|
|
|
return outputs
|
|
|
|
|
|
|
@@ -118,6 +124,8 @@ class InnerProductDecoder(torch.nn.Module): |
|
|
|
inputs_row = dropout(inputs_row, 1.-self.drop_prob)
|
|
|
|
inputs_col = dropout(inputs_col, 1.-self.drop_prob)
|
|
|
|
|
|
|
|
rec = torch.mm(inputs_row, torch.transpose(inputs_col, 0, 1))
|
|
|
|
rec = torch.bmm(inputs_row.view(inputs_row.shape[0], 1, inputs_row.shape[1]),
|
|
|
|
inputs_col.view(inputs_col.shape[0], inputs_col.shape[1], 1))
|
|
|
|
rec = torch.flatten(rec)
|
|
|
|
outputs.append(self.activation(rec))
|
|
|
|
return outputs
|