samedi 25 janvier 2020

NUMPY: What does np.empty(()) do in 2D arrays?

What does np.empty(()) actually do?

For instance, if I want to make an empty array of 5 rows and 5 cols, I would use np.empty((5,5)). This gives a random output like:

[[0.57061489 0.57883359 0.5746548  0.57756612 0.57587218]
 [0.62539185 0.62139618 0.62313292 0.62097162 0.62221129]
 [0.70896235 0.57620393 0.73345734 0.53891594 0.75331689]
 [0.72820808 0.56994986 0.78769608 0.47609684 0.8334235 ]
 [0.62921645 0.70930812 0.6068869  0.74827839 0.55498477]]

1. Why does it give a random output between 0-1 instead of generating values from the memory -like 7.6662e-301, 5.3767e-301..... etc?

If I run the code np.empty((5,5)) again in a new file, I get the same output as above. Why is that?




Aucun commentaire:

Enregistrer un commentaire