Ejemplo n.º 1
0
 def filterbank_matrices(self, a, mu_x, sigma2, epsilon=1e-9):
     t_a, t_mu_x = align(a, mu_x)
     temp = t_a - t_mu_x
     temp, t_sigma = align(temp, sigma2)
     temp = temp / (t_sigma * 2)
     F = torch.exp(-torch.pow(temp, 2))
     F = F / (F.sum(2, True).expand_as(F) + epsilon)
     return F
Ejemplo n.º 2
0
 def filterbank_matrices(self,a,mu_x,sigma2,epsilon=1e-9):
     t_a,t_mu_x = align(a,mu_x)
     temp = t_a - t_mu_x
     temp,t_sigma = align(temp,sigma2)
     temp = temp / (t_sigma * 2)
     F = torch.exp(-torch.pow(temp,2))
     # print 'F size:',F.size()
     # F = F / (F.sum(2).expand_as(F) + epsilon)
     Z=torch.unsqueeze(torch.unsqueeze(F.sum(2).sum(1),1),2).expand_as(F)
     # print Z
     F=F/Z
     # print torch.sum(F)
     # for batch in range(F.size()[0]):
     #     Z=torch.sum(F[batch,:,:])
     #     F[batch,:,:]=F[batch,:,:].clone()/Z
     return F
Ejemplo n.º 3
0
 def _filterbank_matrices(self, a, mu, sigma2, epsilon=1e-9):
     """Genrate filterbank matrix, call by function filterbank
     
     Args:
         a: x or y coordinates [0, self.A or self.B), size (1, 1, size.A or size.B)
         mu_x: single-dimension mu of gaussian kernel, size (self.batch_size, self.N, 1)
         sigma2: variance of gaussian kernel, size (self.batch_size, self.N, 1)
         epsilon: minimun value to keep out 0-divisor
     """
     t_a, t_mu = align(a, mu)
     temp = t_a - t_mu
     temp, t_sigma = align(temp, sigma2)
     temp = temp / (t_sigma * 2)
     F = torch.exp(-torch.pow(temp, 2))
     # normalize for each kernel
     F = F / (F.sum(2, True).expand_as(F) + epsilon)
     return F