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

Investigate using error to signal with pre-emphasis filter and custom dataloader #11

Open
GuitarML opened this issue Feb 5, 2021 · 3 comments

Comments

@GuitarML
Copy link
Owner

GuitarML commented Feb 5, 2021

A new method of loading the data by batch was developed and applied to the Colab notebook. This method caused the original error to signal loss calculation to blow up, so the loss function was changed to MSE. This fixed the out of memory issues by loading the data by batch_size, instead of all at once or in large chunks. However, the original error to signal loss produces more accurate models, especially on highly distorted/complex guitar signals.

Investigate using the original error to signal loss function with the custom Sequence dataloader class from the Colab notebook.

Update: It looks like the pre-emphasis filter is calculated incorrectly, as noted here:
GuitarML/PedalNetRT#16 (comment)
Apply the fix of using [t-1] and see if this fixed the instability issues.

@jmiller656
Copy link
Contributor

@GuitarML I had a look at the paper you sent me and realized that there might be a problem with the way the error_to_signal loss was being used. It looks like in the paper they formulate the problem such that the input is a window of size n over the original signal, and the output is a window of size n over the distorted signal (at the same point in time).

The way the model is trained in this repo, it looks like we're taking a window of size n for input, but providing an output for timestep n+1. I think if we switch to that formulation (I'll start trying tonight and let you know how it goes), then we should hopefully see some better results.

@jmiller656
Copy link
Contributor

Still working on this! Found a pretty big contributor to the problem. As was mentioned in the issue you linked to, there is a problem with how the pre-emphasis filter is being calculated.

Right now, you are concatenating the vector and the coefficient * the filter. Ex:

coeff = 0.95
original = [1 ,1, 1]
output = [1, 1, 1, 0.95, 0.95, 0.95]

What we really want to do is subtract the coefficient * the previous value from the array. For example:

coeff =0.95
original = [1, 2, 3]
output = [1, 2-(1*0.95), 3-(2*0.95)] -> [1, 1.05, 1.1]

Practically, here's how we'd implement this in tensorflow:

def pre_emphasis_filter(x, coeff=0.95):
    return tf.concat([x[:, 0:1, :], x[:, 1:, :] - coeff*x[:, :-1, :]], axis=1)

I'm just starting to test this out, and it's looking good so far! Trying to listen better for audio quality now. I'm going to try and have a PR open for this either tonight or tomorrow. Happy Valentine's day!

@GuitarML
Copy link
Owner Author

Cant wait to try it out, good work!

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