Disable use of cdist on Transe for now
@@ -21,10 +21,16 @@ class TransEScorer(RelationalScorer):
out = -F.pairwise_distance(s_emb + p_emb, o_emb, p=self._norm)
elif combine == "sp*":
sp_emb = s_emb + p_emb
- out = -torch.cdist(sp_emb[None, :, :], o_emb[None, :, :], p=self._norm)
+ #out = -torch.cdist(sp_emb[None,:,:], o_emb[None,:,:], p=self._norm)
+ out = torch.zeros(n, o_emb.size(0)).to(self.config.get("job.device"))
+ for i in range(n):
+ out[i, :] = -F.pairwise_distance(sp_emb[i, :], o_emb, p=self._norm)
elif combine == "*po":
po_emb = o_emb - p_emb
- out = -torch.cdist(po_emb[None, :, :], s_emb[None, :, :], p=self._norm)
+ #out = -torch.cdist(po_emb[None,:,:], s_emb[None,:,:], p=self._norm)
+ out = torch.zeros(n, s_emb.size(0)).to(self.config.get("job.device"))
+ for i in range(n):
+ out[i, :] = -F.pairwise_distance(po_emb[i, :], s_emb, p=self._norm)
else:
raise ValueError('cannot handle combine="{}".format(combine)')
return out.view(n, -1)
