Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HELP: fourier transform conversion from onnx error #1838

Closed
Alanjunhao opened this issue Jun 12, 2020 · 3 comments
Closed

HELP: fourier transform conversion from onnx error #1838

Alanjunhao opened this issue Jun 12, 2020 · 3 comments

Comments

@Alanjunhao
Copy link

ncnn error: load_model error at layer 18, parameter file has inconsistent content
Corresponding Pytorch Code:

def forward(self, input):
    """input: (batch_size, 1, time_steps, n_fft // 2 + 1)
    Returns:
      spectrogram: (batch_size, 1, time_steps, n_fft // 2 + 1)
    """
    (real, imag) = self.stft.forward(input)

    # spectrogram = real ** 2 + imag ** 2
    spectrogram = real * real + imag * imag

    if self.power == 2.0:
        pass
    else:
        spectrogram = spectrogram ** (power / 2.0)

    return spectrogram

After checking, it turns out that the power of imagination part returned by short term fourtier transform went wrong during conversion from onnx to ncnn. Specifically, the line "spectrogram = real ** 2 + imag ** 2"
Tried using workaround such as "spectrogram = real * real + imag * imag", to replace pow OP with Mul, but it's not working.

Could you provide some solution please?

@nihui
Copy link
Member

nihui commented Aug 5, 2024

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn
In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档
Detailed reference documentation
https://github.com/pnnx/pnnx
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx

@nihui
Copy link
Member

nihui commented Nov 19, 2024

#5779

@nihui
Copy link
Member

nihui commented Nov 28, 2024

implemented

@nihui nihui closed this as completed Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants