Just see if I can store the whole RBF kernel


In [1]:
import datetime
import sys

sys.path.append('../code/')

In [2]:
from rbf_kernel import RBFKernel
from scipy.spatial.distance import squareform

In [3]:
from mnist_helpers import mnist_training, mnist_testing

In [4]:
X_train, y_train = mnist_training()

In [5]:
k = RBFKernel(X_train)


determine RBF kernel bandwidth using 6000 points.
median distance for 6000 samples from N: 2598.866676072476

In [6]:
now = datetime.datetime.now()
print("Current date and time using strftime:")
print(now.strftime("%Y-%m-%d %H:%M:%S"))


Current date and time using strftime:
2016-11-12 15:23:19

In [7]:
X = k.transform(X_train)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-7-725ca8ef1bf0> in <module>()
----> 1 X = k.transform(X_train)

/home/jmatsen/Machine_Learning_CSE_546/HW3/code/rbf_kernel.py in transform(self, X)
     51         """
     52         # TODO: could apply only to the first 1/2 of point (I think)
---> 53         return np.apply_along_axis(func1d=self.transform_vector, axis=1, arr=X)

/home/jmatsen/miniconda2/envs/mlpy3/lib/python3.5/site-packages/numpy/lib/shape_base.py in apply_along_axis(func1d, axis, arr, *args, **kwargs)
    126                 n -= 1
    127             i.put(indlist, ind)
--> 128             res = func1d(arr[tuple(i.tolist())], *args, **kwargs)
    129             outarr[tuple(i.tolist())] = res
    130             k += 1

/home/jmatsen/Machine_Learning_CSE_546/HW3/code/rbf_kernel.py in transform_vector(self, xi)
     42         transforms a single point
     43         """
---> 44         dist = np.linalg.norm(self.X - xi, axis=1)
     45         dist_squared = np.multiply(dist, dist)
     46         return np.exp(dist_squared/(-2.)/self.sigma**2)

/home/jmatsen/miniconda2/envs/mlpy3/lib/python3.5/site-packages/numpy/linalg/linalg.py in norm(x, ord, axis, keepdims)
   2157         elif ord is None or ord == 2:
   2158             # special case for speedup
-> 2159             s = (x.conj() * x).real
   2160             return sqrt(add.reduce(s, axis=axis, keepdims=keepdims))
   2161         else:

KeyboardInterrupt: 

In [8]:
now = datetime.datetime.now()
print("Current date and time using strftime:")
print(now.strftime("%Y-%m-%d %H:%M:%S"))


Current date and time using strftime:
2016-11-12 15:23:57

In [9]:
x = np.array()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-9-84aabb32ee17> in <module>()
----> 1 x = np.array()

NameError: name 'np' is not defined

In [ ]: