I have the example data below, which is a default dictionary. I’m trying to transform it in to a dictionary like the desired output below, but I’m having trouble getting the keys to match the keys from the original dictionary. I can get the values using the code below. Any tips are greatly appreciated.
Code:
res[0].item()
Output:
-1.613331913948059
Example data:
res
defaultdict(<function __main__.<lambda>>,
{0: array([-1.6133319], dtype=float32),
1: array([-1.278326], dtype=float32),
2: array([-0.68584293], dtype=float32),
3: array([-1.2741858], dtype=float32),
4: array([-0.81194735], dtype=float32)})
Desired output:
{0: -1.6133319,
1: -1.278326,
2: -0.68584293,
3: -1.2741858,
4: -0.81194735}