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

[DeepLiftShap] Callable background data #161

Open
ghkim9213 opened this issue Dec 17, 2024 · 0 comments
Open

[DeepLiftShap] Callable background data #161

ghkim9213 opened this issue Dec 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ghkim9213
Copy link
Collaborator

          What do you think of also supporting `callable` methods as a parameter? In such case, we would be able to provide a default random generator based on input with something like:
class DeepLiftShap(Explainer):
    SUPPORTED_MODULES = [Convolution]
    
    def __init__(
        self,
        model: Module,
        background_data: Optional[Tensor, Callable[[Tensor, Tensor], Tensor]] = None,
    ):
        if background_data is None:
            background_data = lambda x, y: torch.rand_like(x)
        if torch.is_tensor(background_data):
            background_data = lambda x, y: background_data

        self.background_data = background_data

Originally posted by @enver1323 in #151 (comment)

@ghkim9213 ghkim9213 added the enhancement New feature or request label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant