PyFlatten: A package for flattening nested data structures

Yesterday, I released PyFlatten to PyPI – it’s a utility that can flatten nested data structures (e.g. list of lists; dictionaries of lists of tuples) into a single 1-by-N vector, while also returning an ‘unflattener’ function that can restore the original data structure from the flattened version.

The source code are available on GitHub, where I make clear that I can’t take credit for writing the code – I can only credit myself for factoring it out of autograd for others to use. The real heroes are David Duvenaud, Dougal Maclaurin, and Matt Johnson of the Harvard Intelligent & Probabilistic Systems group. With David’s permission I am releasing it for public use.

Hope it comes in handy for whatever your project is!

Leave a Reply