Suggestion-Box icon indicating copy to clipboard operation
Suggestion-Box copied to clipboard

Force graph using numerical opimization

Open AlbertoSinigaglia opened this issue 2 years ago • 0 comments

I've seen many videos on NN, and I would like to connect to that topic under the optimization prospective... there are a lot of very nice projects that can be done using optimization, and I've just finished implementing one myself that you can find here: https://github.com/AlbertoSinigaglia/force-graph

It's about "force graph" which are those graphs where you tell the algorithm what is connected and what is not, and it tries to find a nice structure with those connections

You can find more infos here: https://en.wikipedia.org/wiki/Force-directed_graph_drawing

The step to implement it are few and simple:

  1. define an adjacency matrix of your vertexes
  2. define a loss function that describes the "error" of a single configuration
  3. use your favorite optimization algorithm to minimize it, for example (Gradient Descent):
  4. calculate the gradient with respect to the coordinates of the points
  5. take a small step in the opposite direction fo the gradient

And with this you might have some opportunities to explain how NN actually learns, and a super intuitive way to descrive what means to get stuck on a local minima (sometimes a vertex of a graph gets stuck on the other side of the graph, and never reaches its actual neighbors, and from the optimization POV that's a local minima)

AlbertoSinigaglia avatar Jul 09 '22 23:07 AlbertoSinigaglia