I am working with a massive NDArray and am trying to recurse over each individual integer within this nested array. The NDArray, called box_ids, looks like this:
[[[-1.]
[-1.]
[-1.]
...
[-1.]
[-1.]
[-1.]]]
and when I write
for ids in box_ids[0]:
print(ids)
I am returned:
<NDArray 1 @cpu(0)>,
[0.]
<NDArray 1 @cpu(0)>,
[0.]
<NDArray 1 @cpu(0)>,
[0.]
<NDArray 1 @cpu(0)>,
[1.]
<NDArray 1 @cpu(0)>,
[1.]
...over and over again.
I have tried box_ids.flatten() and this has yielded the same result. So, I went on to try .tolist() and .ravel(), but then I got the Attribute Error saying Numpy does not have these objects.
Basically, I want a list of all the individual integers in the array so that I can recurse over them. Ideally, a final list might look like [0, 0, 0, 1, 1, ...]. The fact that each element when I print(ids) has the newline and , is really confusing and I can't figure out how to get rid of this. When I print(ids), I simply want something that would look like: 0 0 1 1...
I hope this makes sense. Thanks so much for the help if you can!!