Git Product home page Git Product logo

self_attention_alignment's Introduction

Deep model with built-in self-attention alignment for acoustic echo cancellation


align block demo

python attention_align_block.py
 

Reference

self_attention_alignment's People

Contributors

lhwcv avatar teapoly avatar

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

Watchers

 avatar  avatar

self_attention_alignment's Issues

index 1 does not match the shape of the indexed tensor

Thank you for open-sourcing the code for the align block module. This is very helpful for research on delayed alignment AEC. There seems to be an issue where an error occurs when t is less than max_delay_blocks in this code line.

corr[:, :self.max_delay_blocks][mask] = self.neg_inf

Here is example:

def toy_train():
    import matplotlib.pyplot as plt

    C = 1
    F = 64
    T = 7
    shift = 2
    ref = torch.randn(1, C, F, T)
    echo = torch.roll(ref, shifts=shift, dims=-1)
    echo[:, :, :, :shift] = 0
    mic = echo

    layer = Attention_Align_Block(channels=C, fdim=F, pdim=64, max_delay_blocks=8)

    optimizer = torch.optim.Adam(layer.parameters(), lr=0.01)
    loss_fn = torch.nn.MSELoss()
    for i in range(1000):
        pred,_ = layer(mic, ref)
        loss = loss_fn(pred, echo)
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

        if i %100 ==0:
            print('loss: ', loss.item())

    with torch.no_grad():
        out, corr = layer(mic, ref)
        plt.imshow(corr[0].detach().cpu().numpy().T)
        plt.show()

Error information is here:

    corr[:, :self.max_delay_blocks][mask] = self.neg_inf
IndexError: The shape of the mask [1, 8, 8] at index 1 does not match the shape of the indexed tensor [1, 7, 8] at index 1

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.