I have an array that looks as follows:
array([
[[[0.08467145],
[0.0846905 ]]],
[[[0.08470057],
[0.08483638]]],
[[[0.0846846 ],
[0.08471105]]],
[[[0.08469571],
[0.08472978]]]], dtype=float32)
I want to extract the first element from each pair and store in a list and also extract the second element and store it in another list. How can I do this?
>Solution :
You can use array indexing with np.ndarray.flatten:
print(a[:,:,0].flatten())
print(a[:,:,1].flatten())
This outputs:
[0.08467145 0.08470057 0.0846846 0.08469571]
[0.0846905 0.08483638 0.08471105 0.08472978]