In
tensor = {{ {0.00350361663652802, 0.001969775251872901}, {0.00182446396280031, 0.001170563161973650} },{ {0.00293044432963058, 0.0011301989150090416}, {0.00200206664944458, 0.0045369413588220095} }}
Out
numpyArray = array([[ [0.00350361663652802, 0.001969775251872901], [0.00182446396280031, 0.001170563161973650] ],[ [0.00293044432963058, 0.0011301989150090416], [0.00200206664944458, 0.0045369413588220095] ]])
I want to export the above (2,2,2) tensor out of Mathematica into python and convert it into a numpy array.
Edit: I actually want to export ten thousand (20, 288, 288) tensors. The above one is a minimalist example.


StringTemplate["`` = array(``)"][HoldForm[tensor], ExportString[tensor, "RawJSON", "Compact" -> True]]? $\endgroup$