Exemplo n.º 1
0
 def _call(self, x):
     dim = -self.event_dim
     if dim != -1:
         x = x.transpose(dim, -1)
     y = dct(x)
     if dim != -1:
         y = y.transpose(dim, -1)
     return y
Exemplo n.º 2
0
 def _call(self, x):
     dim = self.dim
     if dim != -1:
         x = x.transpose(dim, -1)
     y = dct(x)
     if self.smooth:
         y = y * self._weight(y)
     if dim != -1:
         y = y.transpose(dim, -1)
     return y
Exemplo n.º 3
0
def _transform_forward(x, dim, duration):
    assert not x.requires_grad
    assert dim < 0
    assert duration == x.size(dim)
    time_domain = x
    new_size = next_fast_len(duration)
    if new_size == duration:
        freq_domain = x
    else:
        freq_domain = pad(x, (0, 0) * (-1 - dim) + (0, new_size - duration))
    freq_domain = dct(freq_domain, dim)
    return torch.cat([time_domain, freq_domain], dim=dim)
Exemplo n.º 4
0
def test_dct(shape):
    x = torch.randn(shape)
    actual = dct(x)
    expected = torch.from_numpy(fftpack.dct(x.numpy(), norm='ortho'))
    assert_close(actual, expected)