question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

convolve2D not supporting "boundary=wrap"

See original GitHub issue

Hi JAX developers,

I am trying to filter periodic images with jax.scipy.signal.convolve2d, but it seems that the flag boundary=‘wrap’ is not supported, although it was mentioned in the doc.

Here is a MVE:

from jax.scipy.signal import convolve2d
import jax.numpy as jnp

a1 = jnp.ones((3,3))

a = convolve2d(a1, a1,mode='same',boundary='wrap')

Here is the error: raise NotImplementedError(“convolve2d() only supports boundary=‘fill’, fillvalue=0”) NotImplementedError: convolve2d() only supports boundary=‘fill’, fillvalue=0

Thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hawkinspcommented, Jul 13, 2021

The best way to implement this is probably to explicitly form the padding values as part of the input to the convolution. Note that jnp.pad supports wrapping padding modes, so perhaps the implementation is as simple as composing the two?

1reaction
jakevdpcommented, Jul 13, 2021

One more thing: the reason this has not yet been implemented is because convolutions are computed via XLA’s ConvWithGeneralPadding, and I’m not certain whether it is able to compute the equivalent of scipy’s wrapped convolutions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

signal.convolve2d performs unexpectedly with boundary='wrap'
The signal.convolve2d(sig_1, sig_2, boundary='wrap') function behaves unexpectedly when the input signals match a certain criteria.
Read more >
scipy.signal.convolve2d — SciPy v1.9.3 Manual
Convolve two 2-dimensional arrays. Convolve in1 and in2 with output size determined by mode, and boundary conditions determined by boundary and fillvalue. ...
Read more >
Convolving a periodic image with python - Stack Overflow
convolve2d 's optional boundary='wrap' which gives periodic boundary conditions as padding for the convolution. The mode option here is 'same' ...
Read more >
Comparison between pyFFS and SciPy 2-D convolution. The ...
Comparison between pyFFS and SciPy 2-D convolution. The former uses pyffs.convolve while the latter uses scipy.signal.convolve2d with boundary='wrap'.
Read more >
scipy.signal.convolve2d Example - Program Talk
Learn how to use python api scipy.signal.convolve2d. ... T, np.atleast_2d(mask_even), mode=method, boundary='wrap') odd = signal.convolve2d(coords.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found