I'm using Python 3.7.7. to work with Numpy.
I have absolutely no idea about Numpy array's indexing and I want to loop over the elements of a numpy array with shape (960, 2, 200, 200, 1)
. In words this array is:
960 pairs of images of 200x200x1.
I know how to get the first element in the pair, and the second element:
first_pair = dataset[:, 0, :]
second_pair = dataset[:, 1, :]
But now I want to loop all the elements in first_pair
and I don't know how to do it.
first_pair
and second_pair
shapes are (960, 200, 200, 1)
.
I have this code to access an element in the first_pair
:
img = dataset[:, 0, :][28][:, :, 0]
I want to get all the images (arrays with shape (200, 200, 1)
in first_pair
array. Something like:
for image in first_pair:
# ...
But I'm confuse because I don't understand what [:, :, 0]
means and I don't know if it is necessary to loop the elements.
How can I loop the elements (images) in first_pair
?