Skip to content

Instantly share code, notes, and snippets.

@ctralie
Last active January 3, 2024 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctralie/6c1dad3ac4f661d997025b2fe5ebd507 to your computer and use it in GitHub Desktop.
Save ctralie/6c1dad3ac4f661d997025b2fe5ebd507 to your computer and use it in GitHub Desktop.
SSMTorchGradientDescent.ipynb
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctralie
Copy link
Author

ctralie commented Jan 3, 2024

out

@ctralie
Copy link
Author

ctralie commented Jan 3, 2024

Man, I love autograd in pytorch! And I've always loved self-similarity matrix (SSM) representations of point clouds.

I was messing around today combining the two for fun. I started with a random point cloud and used a loss function penalizing the difference between that point cloud's SSM and a target SSM (a 3-4 Lissajous curve in this case). The code is so short!

I'm continually blown away by how well gradient descent works on nonconvex problems like this. I never would have tried this or many other things had the code not been so easy, so hats off to the neural nets community I guess!

Of course, in the case of specifying an SSM like this, classic multidimensional scaling would be much more straightforward. But I'm curious if this examples inspires anyone anyway. This could certainly be combined with other loss terms, and one could get away with only a partial specification of an SSM. I'm imagining, for example, some differentiable audio synthesis where, in addition to other specifications, one supplies an SSM like this to specify similarity at different times. No idea if it's useful, but I thought it was cool!

Finally, I should note in this particular example that it's cool to watch the curve go through a slight global rotation during gradient descent (since one can obtain zero loss up to an isometry), and this one straggling point that falls into place at the very end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment