jax.scipy.fft.idct#

jax.scipy.fft.idct(x, type=2, n=None, axis=-1, norm=None)[源代码]#

计算输入的离散余弦逆变换

JAX实现的 scipy.fft.idct()

参数:
  • x (Array) – 数组

  • type (int) – 整数,默认值为 2。目前仅支持类型 2。

  • n (int | None | None) – 整数,默认值为 x.shape[axis]。变换的长度。如果大于 x.shape[axis],则输入将用零填充;如果小于,则输入将被截断。

  • axis (int) – 整数,默认值为 -1。执行 DCT 的轴。

  • norm (str | None | None) – 字符串。归一化模式:[None, "backward", "ortho"] 之一。 默认值为 None,等效于 "backward"

返回:

包含 x 的离散余弦逆变换的数组

返回类型:

Array

参见

示例

>>> x = jax.random.normal(jax.random.key(0), (3, 3))
>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x))
[[ 0.78  0.41 -0.39]
 [-0.12  0.31 -0.23]
 [ 0.17 -0.3  -0.11]]

n 小于 x.shape[axis]

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=2))
[[ 1.12 -0.31]
 [ 0.04 -0.08]
 [ 0.05 -0.3 ]]

n 小于 x.shape[axis] 并且 axis=0

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=2, axis=0))
[[ 0.38  0.57 -0.45]
 [ 0.43  0.44  0.24]]

n 大于 x.shape[axis] 并且 axis=0

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=4, axis=0))
[[ 0.1   0.38 -0.16]
 [ 0.28  0.18 -0.26]
 [ 0.3   0.15 -0.08]
 [ 0.13  0.3   0.29]]

jax.scipy.fft.idct 可用于从 jax.scipy.fft.dct 的结果中重建 x

>>> x_dct = jax.scipy.fft.dct(x)
>>> jnp.allclose(x, jax.scipy.fft.idct(x_dct))
Array(True, dtype=bool)