#Coding=utf-8Importh5pyImportNumPy as NPImportCaffe#1. Import Datafilename ='Testdata.h5'F= H5py. File (filename,'R') N1= F.get ('Data') N1=Np.array (N1)Printn1[0]n2=f.get ('label_1d') N2=Np.array (n2) f.close ()#2. Importing models and Networksdeploy='Gesture_deploy.prototxt' #Deploy fileCaffe_model='Iter_iter_1000.caffemodel' #well-trained CaffemodelNET =caffe.net (Deploy,caffe_model,caffe. TEST) Count=0#statistics The number of predicted values and labels equalt=1000#T: Number of samples forIinchRange (t):#Data Processingtempdata=n1[i,0:63] TempData= Np.reshape ([[TempData]], (1,1,63)) TempData=Tempdata.astype (np.float32) net.blobs['Data'].data[0] =TempData#Forecastout =net.forward () output= out['outputs'] Result= Np.where (output==Np.max (output)) Predi=result[1][0]#determine if the Predi and label are equal and CountLabel =n2[i, 0]ifpredi==(label): Count=count+1KK=[Predi,label]PrintKKPrintCount
[Caffe (ii)] Python Loads the training Caffe model and tests 2