AttributeError: 'ImmutableDenseNDimArray' object has no attribute 'expand'

vin: <p>Need help to compute the integrate equation of <code>∫x(t)*e^(-st) dt</code> where <code>x(t)</code>  is my original signal after <code>ifft calculation</code>. The result shows the follwing error <code>AttributeError: 'ImmutableDenseNDimArray' object has no attribute 'expand'</code>. How can I resolve this issue?<br>
Here is my code:</p>
<pre><code class="lang-auto">import torch
import numpy as np
import matplotlib.pyplot as plt
import os
from scipy import signal
import math
import scipy
import sympy as sym

os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"

f_s = 48000
f_c = 16000
f_l = 19000
f_r = 17000
b = f_l - f_r
n_order = 5
cut_off = 10


def high_pass_filter():
    # generate a random signal
    array_list = np.random.randn(1, 100, 1000)

    tensor_array = torch.from_numpy(array_list)

    reshape_tensor = tensor_array.reshape(2, 10, -1)

    reshape_img = reshape_tensor.reshape(-1)

    # compute the fft
    fft_signal = torch.fft.fft(reshape_tensor)
    print(fft_signal)
    reshape_fft_signal = fft_signal.reshape(-1)
    normalize_cutoff = (((f_c - b)/cut_off) / 2) / (f_s/2)  # normalize cut_off
    print("normalize : ", normalize_cutoff)
    down = math.sqrt(1 + ((f_c / normalize_cutoff)**(2*n_order)))
    print("down reponse : ", down)

    butterworth = torch.tensor(1 / down)

    G = torch.mul(butterworth, fft_signal)
    G_reshape = G.reshape(-1)
    output_filter = torch.fft.ifft2(G)
    print(output_filter)
    output_filter_reshape = output_filter.reshape(-1)

    plt.figure()
    plt.plot(reshape_img)
    plt.figure()
    plt.plot(reshape_fft_signal)
    plt.figure()
    plt.plot(G_reshape)
    plt.figure()
    plt.plot(output_filter_reshape)
    # plt.show()
    return output_filter


def pole_zero_plot(poles, zeros, ax=None):
    for pole in poles:
        plt.plot(complex(pole).real, complex(pole).imag, 'rx', markersize=10)
    for zero in zeros:
        plt.plot(complex(zero).real, complex(zero).imag, 'bo', markersize=10)

    if ax is None:
        ax = plt.gca()
    ax.set_aspect(1)

    plt.axis([-2, 2, -2, 2])
    plt.xlabel(r'$\Re\{s\}')
    plt.ylabel(r'$\Im\{s\}')
    plt.grid()


if __name__ == '__main__':
    sym.init_printing()

    signal = high_pass_filter()
    signal_numpy = signal.detach().numpy()

    t = sym.symbols('t', real=True)
    s = sym.symbols('s', complex=True)

    X = sym.integrate(signal_numpy * sym.exp(-s * t), (t, -sym.oo, sym.oo))
    print(X)

</code></pre>
<p>Error:   <code>X = sym.integrate(signal_numpy * sym.exp(-s * t), (t, -sym.oo, sym.oo))</code></p>
<p>Thanks…</p>

ptrblck: <p>The issue seems to be raised by <code>sympy</code> or are you only seeing it when PyTorch tensors are used?<br>
In the former case, you might want to post in a <code>sympy</code>-specific discussion board or in their GitHub repository to get a faster answer from the devs.</p>

vin: <p>The error claim is after converted datas from tensor to numpy <code>signal_numpy = signal.detach().numpy()</code>. While using tensors here the problem <code>TypeError: unsupported operand type(s) for *: 'Tensor' and 'exp'</code>. You are right, the main issue pointed on <code>sympy</code>, but how to match my data to this module. What the difference while using real data or random data, instead of using the simple equation?</p>