← Questions
Turn dotted keys into a nested dictionary
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A model's weights come as a flat mapping from dotted names such as layer1.attention.query.weight to values. Convert it into a nested dictionary ({"layer1": {"attention": {"query": {"weight": ...}}}}). Handle numeric segments (list indices or keys), conflicts where a name is both a leaf and a prefix, and write the reverse conversion too.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
