Skip to content
Snippets Groups Projects
Commit c336365d authored by Luc Giffon's avatar Luc Giffon
Browse files

add memory usage function

parent 3a2a8c66
No related branches found
No related tags found
No related merge requests found
......@@ -214,6 +214,26 @@ def replace_nan(tensor):
return np.where(np.isnan(tensor), np.zeros_like(tensor), tensor)
def memory_usage():
"""
Copy pasted from https://airbrake.io/blog/python-exception-handling/memoryerror
Prints current memory usage stats.
See: https://stackoverflow.com/a/15495136
:return: None
"""
PROCESS = psutil.Process(os.getpid())
GIGA = 10 ** 9
# MEGA_STR = ' ' * MEGA
mem = psutil.virtual_memory()
total, available, used, free = mem.total / GIGA, mem.available / GIGA, mem.used / GIGA, mem.free / GIGA
proc = PROCESS.memory_info()[1] / GIGA
return 'process = %s total = %s available = %s used = %s free = %s' \
% (proc, total, available, used, free)
def compute_euristic_sigma_chi2(dataset_full, slice_size=100):
"""
Given a dataset, return the gamma that should be used (euristically) when using a rbf kernel on this dataset.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment