Skip to content

AL/math/MaxPooling - #407

Merged
giovannivolpe merged 19 commits into
developfrom
AL/math/maxpooling
Sep 5, 2025
Merged

giovannivolpe merged 19 commits into
developfrom
AL/math/maxpooling

Conversation

@Pwhsky

@Pwhsky Pwhsky commented Jul 30, 2025 •

Copy link
Copy Markdown
Collaborator

Added docs, torch, tests for math.maxpooling.

@Pwhsky
Pwhsky requested review from JChonpca and mirjagranfors July 31, 2025 08:17

@mirjagranfors mirjagranfors left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have written some comments.

When I tried the example from the docs, I don't get the output that is written in the docs. So double check that.

And when I try to run the exact same example, but swapping numpy for torch, it doesn't work. Therefore I think that you should either make it work exactly the same for both cases, or write a clear example on what is different.

Related to that: for the torch version to work, the shapes have to be different from when running it with numpy. I can imagine that it might lead to problems when a pipeline has been created with numpy, and the user wants to run it with torch, and then gets a different result or that it doesn't work at all anymore. Maybe this is something to discuss in our next meeting.

Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/math.py Outdated
Comment thread deeptrack/tests/test_math.py
Comment thread deeptrack/tests/test_math.py Outdated
Comment thread deeptrack/tests/test_math.py
@Pwhsky Pwhsky mentioned this pull request Jul 30, 2025
Comment thread deeptrack/math.py
retaining the most significant features.

If the backend is NumPy, the downsampling is performed using
`skimage.measure.block_reduce`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing line space

Comment thread deeptrack/math.py Outdated
If the backend is NumPy, the downsampling is performed using
`skimage.measure.block_reduce`.
If the backend is PyTorch, the downsampling
is performed using `torch.nn.functional.max_pool2d`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use the full line before new line

Comment thread deeptrack/math.py

Examples
--------
>>> import deeptrack as dt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

space after this

Comment thread deeptrack/math.py
The pooled input as `NDArray` or `torch.Tensor` depending on
the backend.

"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add space after """

Comment thread deeptrack/math.py Outdated
"""
if self.get_backend() == "numpy":
return self._get_numpy(image, ksize, **kwargs)
elif self.get_backend() == "torch":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

restructure like we did for min-pooling

Comment thread deeptrack/math.py Outdated

Parameters
----------
image: NDArray

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should be array

Comment thread deeptrack/math.py
Kernel size of the pooling operation.

Returns
-------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use array and NumPy array

@giovannivolpe
giovannivolpe merged commit 4a79b7a into develop Sep 5, 2025
25 checks passed
@giovannivolpe
giovannivolpe deleted the AL/math/maxpooling branch September 5, 2025 14:35
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

Successfully merging this pull request may close these issues.

3 participants