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

Enforcing number of connected components #17

Open
IssamLaradji opened this issue Dec 22, 2019 · 3 comments
Open

Enforcing number of connected components #17

IssamLaradji opened this issue Dec 22, 2019 · 3 comments
Labels
question Further information is requested

Comments

@IssamLaradji
Copy link

Great work! How do I use this to have the network output $k$ number of connected components?

Thanks.

@bnels bnels added the question Further information is requested label Dec 23, 2019
@bnels
Copy link
Collaborator

bnels commented Dec 23, 2019

@IssamLaradji this package doesn't enforce hard constraints such as exactly $k$ connected components but you can add a penalty on more than $k$ components, which will (hopefully) encourage at most that many components to form during optimization.

Assuming you know which filtration you're using, right now, the easiest function to use on a persistence diagram is PartialSumBarcodeLengths
https://github.com/bruel-gabrielsson/TopologyLayer#partialsumbarcodelengths

Connected components is in dimension zero, and the infinite length bar is automatically ignored, so you would modify the example in the README to be

feat = PartialSumBarcodeLengths(dim=0, skip=(k-1))

If you want a different type of penalty (e.g. L2 type penalty instead of L1) you can always write a custom class that does exactly what you want. To get started, you can see how the PartialSumBarcodeLengths is defined and modify from there: https://github.com/bruel-gabrielsson/TopologyLayer/blob/master/topologylayer/nn/features.py#L153

Does this answer your question?

@IssamLaradji
Copy link
Author

Oh this is great, it's working for me! Another related question, which layer should I use to get dgminfo? I see LevelSetLayer2D, AlphaLayer, RipsLayer, but I don't get how they are different, thanks!

@bruel-gabrielsson
Copy link
Owner

LevelSetLayer2D is for levelset filtration on a 2d grid, like a grayscale image (our paper have several examples). AlphaLayer and RipsLayer are a little bit similar and AlphaLayer can be thought of as the restriction of the Rips complex to the Delaunay Triangulation of the space. For understanding Rips filtration, check out Wikipedia or Google "Rips filtration" to read more. Does this help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants