コード例 #1
0
ファイル: discrete_cosine.py プロジェクト: youisbaby/pyro
 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
コード例 #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
コード例 #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)
コード例 #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)