Coder Social home page Coder Social logo

nx_signal's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nx_signal's Issues

Difference in performance for STFT vs PyTorch

I've noticed the speed of NxSignal.stft is much slower than in PyTorch (on the order of ~500x). Is this expected? I'm using Exla.Backend, but I feel like I'm missing something. In my tests I see a STFT of zeros with length 480000 taking ~3ms in PyTorch and ~1.5 seconds (after the initial jit compilation) in NxSignal:

import time
import torch


class STFT(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.fft_length = 400
        self.hop_length = 160

        self.window = torch.nn.Parameter(
            torch.hann_window(self.fft_length, periodic=True), requires_grad=False
        )

    def forward(self, sample):
        stft = torch.stft(
            sample,
            self.fft_length,
            self.hop_length,
            window=self.window,
            return_complex=True,
        )

        return stft


if __name__ == "__main__":
    s = STFT().eval()
    i = torch.zeros([480000])

    start = time.time()
    result = s(i)
    print(f"took {(time.time() - start)*1000000}us")

This returns ~ 3000us
And (what I think is) the corresponding Elixir

defmodule StftTest do
  import Nx.Defn

  defn test(sample) do
    fft_length = 400
    sample_rate = 16000
    hop_length = 160

    window = NxSignal.Windows.hann(n: fft_length, is_periodic: true)

    {stft, _, _} =
      NxSignal.stft(sample, window,
        sampling_rate: sample_rate,
        fft_length: fft_length,
        overlap_length: fft_length - hop_length,
        window_padding: :reflect
      )

    stft
  end

  def test_jit() do
    sample = Nx.broadcast(0.0, {480_000})
    {time, _} = :timer.tc(fn -> Nx.Defn.jit(&test/1, compiler: EXLA).(sample) end)
    IO.puts("STFT took #{time}us")
  end
end

This returns 1596447us after the initial run.

Roadmap

The main goal of this library is to mirror the functionality provided by scipy.signal. However, some of those overlap with Scholar.

With that in mind, we still have the following sections to implement:

  • Convolution
  • B-Splines (pertains to Scholar)
  • Filtering
  • Filter Design
  • Matlab-style IIR filter design
  • Continuous-time linear systems
  • Discrete-time linear systems
  • LTI Representations
  • Waveforms
  • Window functions (some of the most common are implemented, others are welcome)
  • Wavelets
  • Peak finding
  • Spectral analysis
  • Chirp Z-Transform and Zoom FFT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.