SoFunction
Updated on 2025-03-02

numpy declares an empty array in detail

If you search for this, you will find that many of them are (5, 2), and they are all copied from a foreign post, but there is no translation of the other person's words.

Then you angrily close the page. This is simply a misunderstanding of the title, and this is not empty.

In fact,numpy's array mechanism does not support empty arrays.(What the hell answer?) Simply put, numpy will apply for continuous memory. If the size is frequently changed, it will frequently apply for new memory. If you know pointers in C language, you can easily think that it is not a list format but an array format.

If you don't know how to C language, it doesn't matter. No impact. Just remember,Once the numpy array changes in size, it will be like moving in large and small packages with all your data and bring home the home to a new home. Therefore, you need to set the size of the numpy array from the beginning.

This means that you can't start with empty and just pile up data a little bit. But you canAssignmentah.

For example:

sum = (shape=(2284,1200))
for i in range(2284):
  pic_lab = mini_lab[i,:,:]
  pic_flatten = (pic_lab,(1,1200))
  sum[i] = pic_flatten

Generally, we don’t have any scores at all. If it’s really not scored,It's better to use python's list first and then use ndarray = (list) to convert.

The above detailed explanation of the numpy declaration empty array is all the content I share with you. I hope you can give you a reference and I hope you support me more.