I have a txt (string) file looking like:
[[[[0.17262284, 0.95086717, 0.01172171, 0.79262904],
[0.52454078, 0.16740103, 0.32694925, 0.78921072],
[0.77886716, 0.35550488, 0.89272706, 0.36761104]],
[[0.14336841, 0.94488079, 0.83388505, 0.02065268],
[0.31804594, 0.22056339, 0.84088501, 0.94994676],
[0.57845057, 0.12645735, 0.12628646, 0.05526736]]]]
The shape is (1,2,3,4).
How can I easily convert it to a NumPy array that considers the data type and the shape (that may be deduced from the parenthesis)?
Let's say I have the shape in the txt file, will it make it easier?
I have tried using np.loadtxt, seems that it doesn't handle this 4d shape, it loads as a 1D array.
I can parse the shape myself and then convert all members to floats but I believe there is np function that already does that. The file is not created by me - I would just pkl the array.