MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / apply

Method apply

utils.py:669–685  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

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
688def compute_ap(ranks, nres):

Callers 4

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
init_weightsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected