(self, x)
| 667 | self.dvt = np.dot(d, v.T) |
| 668 | |
| 669 | def apply(self, x): |
| 670 | # input is from numpy |
| 671 | if isinstance(x, np.ndarray): |
| 672 | if self.mean is not None: |
| 673 | x -= self.mean |
| 674 | return np.dot(self.dvt, x.T).T |
| 675 | |
| 676 | # input is from torch and is on GPU |
| 677 | if x.is_cuda: |
| 678 | if self.mean is not None: |
| 679 | x -= torch.cuda.FloatTensor(self.mean) |
| 680 | return torch.mm(torch.cuda.FloatTensor(self.dvt), x.transpose(0, 1)).transpose(0, 1) |
| 681 | |
| 682 | # input if from torch, on CPU |
| 683 | if self.mean is not None: |
| 684 | x -= torch.FloatTensor(self.mean) |
| 685 | return torch.mm(torch.FloatTensor(self.dvt), x.transpose(0, 1)).transpose(0, 1) |
| 686 | |
| 687 | |
| 688 | def compute_ap(ranks, nres): |
no outgoing calls
no test coverage detected