示例#1
0
def test_shape():
    print("Testing shape...")

    # Test Shape inference. Output shape should be
    # the same as input shape
    input_pl = tf.placeholder(tf.complex64, [1000, 16000])
    output_fft = sequential_batch_fft(input_pl)
    output_ifft = sequential_batch_ifft(input_pl)
    g_fft = tf.gradients(output_fft, input_pl, g_out)[0]
    g_ifft = tf.gradients(output_ifft, input_pl, g_out)[0]
    assert (output_fft.get_shape() == input_pl.get_shape())
    assert (output_ifft.get_shape() == input_pl.get_shape())
    assert (g_fft.get_shape() == input_pl.get_shape())
    assert (g_ifft.get_shape() == input_pl.get_shape())

    print("Passed.")
示例#2
0
import tensorflow as tf
import numpy as np

from sequential_batch_fft_ops import sequential_batch_fft, sequential_batch_ifft

compute_size = 128

x = tf.placeholder(tf.complex64, [None, None])
x_128 = tf.placeholder(tf.complex128, [None, None])
# FFT
x_fft = sequential_batch_fft(x, compute_size)
x_fft_128 = sequential_batch_fft(x_128, compute_size)
x_fft_tf = tf.fft(x)
# IFFT
x_ifft = sequential_batch_ifft(x, compute_size)
x_ifft_128 = sequential_batch_ifft(x_128, compute_size)
x_ifft_tf = tf.ifft(x)
# Grads
gx_fft = tf.gradients(x_fft, x, grad_ys=[tf.identity(x)])[0]
gx_fft_128 = tf.gradients(x_fft_128, x_128, grad_ys=[tf.identity(x_128)])[0]
gx_fft_tf = tf.gradients(x_fft_tf, x, grad_ys=[tf.identity(x)])[0]
gx_ifft = tf.gradients(x_ifft, x, grad_ys=[tf.identity(x)])[0]
gx_ifft_128 = tf.gradients(x_ifft_128, x_128, grad_ys=[tf.identity(x_128)])[0]
gx_ifft_tf = tf.gradients(x_ifft_tf, x, grad_ys=[tf.identity(x)])[0]


def test_shape():
    print("Testing shape...")

    # Test Shape inference. Output shape should be