10000 make core algorithm a self.variable. · Issue #818 · kymatio/kymatio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

make core algorithm a self.variable. #818

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

Open
MuawizChaudhary opened this issue May 30, 2022 · 7 comments
Open

make core algorithm a self.variable. #818

MuawizChaudhary opened this issue May 30, 2022 · 7 comments

Comments

@MuawizChaudhary
Copy link
Collaborator

Currently in each specific deep learning framework's frontend we import from core the ScatteringnD algorithm and call it.

It would be a nice change for power users if we instead imported the algorithm in the base frontend and defined a variable to contain the call i.e. self.scatteringalgo = scatteringnd. then in each specific frontend, the call to the algorithm would be given by self.scatteringalgo. This would allow power users to define a breadth first search algorithm #798 , or define their own scattering implementation where they can retrieve coefficients #445 (tho, these futures should be one day in our code base, please see #735).

@lostanlen
Copy link
Collaborator

customizing the algorithm is nice but i don't see why it should be stored as a mutable field of self?

@MuawizChaudhary
Copy link
Collaborator Author
MuawizChaudhary commented May 30, 2022

@lostanlen so then I could do

from kymatio.torch import Scattering2D
S = Scattering2D()
S.scatteringalgo = scattering2d_breadthfirstsearch
S(x)

without having to redefine scattering function.

@lostanlen
Copy link
Collaborator
from kymatio.torch import Scattering2D
S = Scattering2D()
scattering2d_breadthfirstsearch(S, x)

saved you one line ☺️

@MuawizChaudhary
Copy link
Collaborator Author

Is there a big software no no against storing the algorithm as a mutable field?

@MuawizChaudhary
Copy link
Collaborator Author
MuawizChaudhary commented May 30, 2022
from kymatio.torch import Scattering2D
S = Scattering2D()
scattering2d_breadthfirstsearch(S, x)

saved you one line relaxed

Actually, Im not quite sure this is the solution i want. you need to redefine some logic present in the scattering function.

@lostanlen
Copy link
Collaborator
< 956B a class="author Link--primary text-bold css-overflow-wrap-anywhere " show_full_name="false" data-hovercard-type="user" data-hovercard-url="/users/lostanlen/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/lostanlen">lostanlen commented May 31, 2022

Hm, i don't know. Then yes, a field for the algorithm is needed: (just like for out_type)

Maybe refactor scattering this way?

def scattering(self, input, sc_algorithm):
    self.check_input(input)
    phi, psi = self.load_filters()
    x = self.pad(input)
    S = sc_algorithm(x,  self.pad, self.unpad, self.backend ... )
    return self.format(S) 

in this way, we'd be exposing new utility functions (check_input, pad, format ...) to potential future core modules (wavelets, phase harmonics ...)

@janden
Copy link
Collaborator
janden commented Jun 7, 2022

Are you saying we store a function as an attribute (a sort of callback)? I'm not convinced this is a good idea. The way we currently extend the classes is using inheritance. Adding another way of modifying the core behavior of the classes would just cause confusion, I think.

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

No branches or pull requests

3 participants
0