-
Notifications
You must be signed in to change notification settings - Fork 32
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
Neuralized K-Means #197
base: master
Are you sure you want to change the base?
Neuralized K-Means #197
Conversation
I just found the contributing guide and converted this to draft for now since I broke every single guideline. @p16i I clicked somewhere and triggered a review request. Please ignore. |
1c64129
to
cbb350e
Compare
- documentation in numpydoc format - pylint + flake8 stuff - KMeansCanonizer - NeuralizedKMeans layer - LogMeanExpPool layer - Distance layer - Distance type
I tried to merge everything into one commit, extended documentation and made sure that all checks pass. |
2bf6f52
to
7047178
Compare
- Explaining Deep Cluster Assignments with Neuralized K-Means on Image Data - I tried to adhere to guidelines - That means: random data, random weights - Code for real data and real weights in comments - Runs on colab, did not test blender - also adds the reference to docs/source/tutorial/index.rst
Checks pass 👍 It's quite challenging to get reproducible tox results for tutorials (e.g. had to manually fiddle with I'm gonna freeze this branch for now, unless something comes up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jackmcrider
thanks a lot for the contribution!
I have looked at your implementation and left a few comments.
I have not yet looked at the tutorial.
Co-authored-by: Christopher <15217558+chr5tphr@users.noreply.github.com>
change `torch.log(torch.tensor(n_dims, dtype=...))` to `math.log(n_dims)` Co-authored-by: Christopher <15217558+chr5tphr@users.noreply.github.com>
change `setattr(parent_module, ...)` to `parent_module.add_module(...)` Co-authored-by: Christopher <15217558+chr5tphr@users.noreply.github.com>
add spaces around binary operators Co-authored-by: Christopher <15217558+chr5tphr@users.noreply.github.com>
- rename Distance to PairwiseCentroidDistance - remove LogMeanExpPool (might become relevant again, but not for now) - add MinPool1d and MinPool2d in layer.py - add MinTakesMost1d, MaxTakesMost1d, MinTakesMost2d, MaxTakesMost2d rules - largely untested. especially kernel_size as int or kernel_size as tuple - in principle, MaxTakesMost2d should also work for MaxPoll2d layers in standard conv nets - but needs some testing - add abstract TakesMostBase class - remove type definition for Distance in types.py - adapt KMeans canonizer: - replace LogMeanExpPool with MinPool1d followed by torch.nn.Flatten - remove beta parameter; beta is now sit in MinTakesMost1d - remove deepcopy and simply return the module itself - update docs/src/tutorials/deep_kmeans.ipynb - doc strings
- merge changes coming from github web interface
- various non-functional changes
I have commited a new version with roughly these changes:
I'm not sure if we want four rules for the *TakesMost* or if one rule with |
Hi chr5tphr!
I started an attempt to implement (deep) neuralized k-means (https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9817459) as more people want to use it and ask for code.
I took the SoftplusCanonizer from the docs as a starting point.
Main changes:
Some things can be optimized:
(out[:,None,:] - out[None,:,:])[mask].reshape(K,K-1,D)
, cf. line 379-384 in canonizers.pySequential(Distance(centroids))
as a trick, but not idealwith Gradient(...) as attributor
; could be a bottleneck if number of clusters is largeCloses #198