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

Inhibition #26

Merged
merged 27 commits into from May 27, 2021
Merged

Inhibition #26

merged 27 commits into from May 27, 2021

Conversation

dasmy
Copy link
Collaborator

@dasmy dasmy commented May 24, 2021

Hi @AdrianSosic,
This PR adds inhibition essentially identical to how it was done in the old implementation (except for that this one is supporting different inhibition kernel sizes in the different directions, which is in line with support for non-square atoms).

What do you think? - Maybe, adding cross-atom inhibition might make sense, but this could also be a follow-up project as parametrization, etc. would still have to be discussed...

tnmf/TransformInvariantNMF.py Outdated Show resolved Hide resolved
self._inhibition_range = tuple(np.ceil(a / 2) for a in atom_shape) if inhibition_range is None else inhibition_range
assert len(self._inhibition_range) == len(atom_shape)
inhibition_kernels_1D = list((1 - ((np.arange(-i, i + 1) / i) ** 2) for i in self._inhibition_range))
self._inhibition_kernel = np.prod(np.array(np.meshgrid(*inhibition_kernels_1D)), axis=0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atom.ndim separate 1D-convolutions are more efficient than this multi-D convolution

# TODO: maybe also add cross-channel/cross-atom inhibition?
convolve_axes = range(-len(self.atom_shape), 0)
inhibition_gradient = convolvend(
self.H, self._inhibition_kernel[np.newaxis, np.newaxis, :], mode='same', axes=convolve_axes)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be moved into the backend.

@dasmy
Copy link
Collaborator Author

dasmy commented May 25, 2021

Fixed all comments we talked about.

Btw.: This fixes #25

@AdrianSosic AdrianSosic merged commit bafda94 into main May 27, 2021
@AdrianSosic AdrianSosic deleted the inhibition branch May 27, 2021 10:00
@dasmy dasmy added this to Done in Create Version 1.0 Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants