def evaluate(original_file, test_file): ori_arr = read_file_test(original_file, 13, ) test_arr = read_file_test(test_file, 13) ori_arr = ori_arr[:,1:13] # take 12 coefficients test_arr = test_arr[:,1:13] subtract = (ori_arr - test_arr) ** 2 rms = sqrt(subtract.sum()) #/(ori_arr.shape[0] * ori_arr.shape[1]) print rms #, ori_arr.shape[0] * ori_arr.shape[1] #subtract = (ori_arr - test_arr) print subtract.max() return rms
def _testing_DNN(self): if self.space: test_dir = '/home/danglab/Phong/TestData/Features_Norm_Space/' else: test_dir = '/home/danglab/Phong/TestData/Features_Norm/' for type_test in sorted(os.listdir(test_dir)): if not type_test.endswith('zip'): type_test_dir = test_dir + type_test + '/' print type_test_dir dnn_predict_dir = '/home/danglab/DNN_Predict/Features_Norm/' + self.hidden_layer +'SQR/' + self.artic + 'test_' + str(self.test_number) + '/' + type_test + '/' if not os.path.exists(dnn_predict_dir): os.makedirs(dnn_predict_dir) print type_test duration = type_test.split('_')[1] # 50ms, 100ms #listtest = sorted(os.listdir(type_test_dir)) #for afile in listtest: for prefix_file in self.missing_filename_list: afile = prefix_file + '_' + duration + '_in.txt' test_arr, factors = read_file_test(type_test_dir + afile, self.n_input_f, "factors") #read a missing_feature find_ = [m.start() for m in re.finditer('_', afile)] energy = test_arr[:,0] #ko cho energy vao DNN test_arr = test_arr[:,1:self.n_input_f] #print factors self._write_predict_2_file(dnn_predict_dir + afile.replace(afile[find_[4]:len(afile)-4],''), energy, self.predict(test_arr), factors) # write result to file