def EvalSHD(data,model):
dataNum,dataDim=data.shape
distToAnchors=cdist(model["anchorData"], data,'euclidean')
sigmaRBF=model["sigmaRBF"]
phi=npy.exp(-npy.square(distToAnchors)/sigmaRBF/sigmaRBF/2)
matP=model["matProj"]
projData=npy.dot(matP.T,phi)
code=npy.ones(projData.shape,dtype=npy.int32)
code[projData<0]=-1
if 0==code.shape[0]%8:
codeByteNum=code.shape[0]/8
else:
codeByteNum=1+code.shape[0]/8
compactCode=npy.zeros((code.shape[1],codeByteNum),dtype=npy.uint8)
for kk in range(code.shape[0]):
idxByte=kk/8
idxBit=kk%8
compactCode[code[kk,:]==1,idxByte]+=(1<<idxBit)
return compactCode
评论列表
文章目录