[Numpy-discussion] svd() and eigh()

devnew at gmail.com devnew at gmail.com
Sat Mar 1 08:43:06 EST 2008


hi
i have a set of images of faces which i make into a 2d array using
numpy.ndarray
each row represents a face image
faces=
[[ 173.   87.  ...   88.  165.]
 [ 158.  103.  ..   73.  143.]
 [ 180.   87.  ..   55.  143.]
 [ 155.  117.  ..   93.  155.]]

from which i can get the mean image =>
avgface=average(faces,axis=0)
and calculate the adjustedfaces=faces-avgface

now if i apply svd() i get
 u, s, vt = linalg.svd(adjustedfaces, 0)
# a member posted this
facespace=vt.transpose()

and if i calculate covariance matrix
covmat=matrix(adjustedfaces)* matrix(adjustedfaces).transpose()
eval,evect=eigh(covmat)
evect=sortbyeigenvalue(evect) # sothat largest eval is first
facespace=evect* matrix(adjustedfaces)

what is the difference btw these 2 methods? apparently they yield
different values for the facespace. which should i follow?
is it possible to calculate eigenvectors using svd()?

thanks
D



More information about the NumPy-Discussion mailing list