Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Fix masking with more than one input feature #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jglaser
Copy link
Contributor

@jglaser jglaser commented Aug 14, 2022

This PR fixes an issue where passing inputs x1 and x2 of dimension (..., n_feat) with n_feat > 1 to a kernel_fn generates masks in the Kernel which still carry the original feature dimension.

This creates a problem for layers such as GlobalAvgPool, since for kernels that represent infinitely wide layers it is generally assumed that the channel dimension is one.

I implemented a reduction over the mask's last dimension using np.any(.., keepdims=True), which assumes that it doesn't matter if any or all of the features are masked. A user warning spells this out.

I can create an issue with a reproducer shortly, if more detail is needed. Can also add a unit test.

@romanngg
Copy link
Contributor

Thanks a lot Jens, could you share a code sample that would fail before this change? I think we should support n_feat > 1, so I wonder if this points to a bug that needs to be fixed elsewhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants