Skip to content

Instantly share code, notes, and snippets.

@ptonner
Created March 17, 2016 19:39
Show Gist options
  • Select an option

  • Save ptonner/780ed4edc4ef905e50bc to your computer and use it in GitHub Desktop.

Select an option

Save ptonner/780ed4edc4ef905e50bc to your computer and use it in GitHub Desktop.
import gc
import numpy as np
import GPy
from sklearn.svm import SVR
import sys, getopt
import memory_profiler as mprof
opts,args = getopt.getopt(sys.argv[1:],'gh')
hier = False
collect = False
for opt,arg in opts:
if opt == '-h':
hier =True
elif opt == '-g':
collect = True
feats = np.full((3,3), 666)
labels = np.full((3, 1), 42)
def f():
for i in xrange(its):
if hier:
m = GPy.models.GPRegression(feats, labels,GPy.kern.Hierarchical(kernels=[GPy.kern.RBF(2), GPy.kern.RBF(2)]))
else:
m = GPy.models.GPRegression(feats, labels)
if collect:
gc.collect(2)
its = 500
mem_usage = mprof.memory_usage(f, timeout=10, interval=0.2)
print mem_usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment