Project-MONAI / Project-MONAI/MONAI

Gradients of the existing bilateral filter layers (normal and PHL)

Open
#5,772 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Contribution wanted Feature request
Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Describe the bug
The backward operations of the existing bilateral filter layers (normal and PHL) do not calculate the correct derivative of the filter prediction with respect to the filter input. Currently, they use the exact same filter forward function as the backward operation, which is not the correct derivative as shown in here. This issue is related to #1840 and may be partly fixed by pull-request #5757.

As discussed with @wyli we should think about how to treat the existing bilateral filter implementations (normal and PHL). I believe that their forward operations are fast and valid operators which can be valuable for users. However, their provided gradient is not correct I think. The normal bilateral filter implementation could be replaced by the #5757 version in the medium term as their forward operations are almost identical.

To Reproduce
Steps to reproduce the behavior:

  1. Install BUILD_MONAI=1 pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI#egg=monai
  2. Run the gradcheck
import torch
from monai.networks.layers import BilateralFilter


tensor_in = (torch.randn(2, 1, 10, 10, 10, dtype=torch.double, requires_grad=True))
filter = BilateralFilter.apply
gradcheck(filter, (tensor_in, 1.1, 0.5), eps=1e-6, atol=1e-5)

Expected behavior
Gradcheck passes.

Current behavior
Gradcheck fails as visible in the screenshot.
gradcheck

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided PyTorch gradcheck for BilateralFilter.apply and inspect the existing bilateral filter layer implementation for the normal and PHL variants. Compare the backward behavior with the derivative described in the cited paper and review pull request #5757 for related changes. Done means the relevant gradient checks pass for the existing implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.