Last active
March 14, 2021 14:25
-
-
Save kiurtis/b3c569a681efeeca0ef0877724310a04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Get all the numpy array and their size #### | |
# From https://stackoverflow.com/questions/11784329/python-memory-usage-of-numpy-arrays | |
import sys | |
import numpy | |
from humanize import naturalsize | |
for size, name in sorted( | |
(value.nbytes, name) | |
for name, value in locals().items() | |
if isinstance(value, np.ndarray)): | |
print("{:>30}: {:>8}".format(name, naturalsize(size))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment