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

flip kernel when do the convolution. #4

Closed
tuvovan opened this issue Nov 11, 2023 · 4 comments
Closed

flip kernel when do the convolution. #4

tuvovan opened this issue Nov 11, 2023 · 4 comments

Comments

@tuvovan
Copy link

tuvovan commented Nov 11, 2023

Hello,

I just noticed that you flip the blur kernel in the convolve_tensor function and do not do that in cross_correlate_tensor. May I know the reason behind this?

Thank you!

@claroche-r
Copy link
Owner

claroche-r commented Nov 12, 2023

Hello,

In PyTorch, the function torch.nn.functional.conv2d() implements a cross correlation between the input and the kernel not a convolution as the name would suggest. To implement a convolution, one just need to flip the blur kernel.

I also need to have a cross-correlation function in the code since I need both the operator H (a convolution) and its transpose $H^T$ (a cross correlation) to implement the model.

@tuvovan
Copy link
Author

tuvovan commented Nov 12, 2023

then the main difference between cross-correlation and convolution is flip and not flip right?

@claroche-r
Copy link
Owner

Yes, the operation is the same but the filter is flipped.

@tuvovan
Copy link
Author

tuvovan commented Nov 13, 2023

thanks!

@tuvovan tuvovan closed this as completed Nov 13, 2023
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