Don't Print NumPy Arrays! Use Lovely-NumPy Instead.
We often print raw numpy arrays during debugging. But this approach is not very useful. This is because printing does not convey much information about the data it holds, especially when the array is large.
Instead, use 𝐥𝐨𝐯𝐞𝐥𝐲-𝐧𝐮𝐦𝐩𝐲. Rather than viewing raw arrays, it prints a summary of the array. This includes its shape, distribution, mean, standard deviation, etc.
It also shows if the numpy array has NaNs and Inf values, whether it is filled with zeros, and many more.
P.S. If you work with tensors, then you can use 𝐥𝐨𝐯𝐞𝐥𝐲-𝐭𝐞𝐧𝐬𝐨𝐫𝐬.
Read more: Documentation.
Share this post on LinkedIn: Post Link.
The code snippets for the posts I have shared here are available on GitHub. Check out this repository: GitHub.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.