def __init__(self, data): # normalize self._normalization = normalization.Normalization(data) normalized_data = self._normalization.normalized_dataset() # normalized_data = data # find covariance matrix data_matrix = sp.matrix(normalized_data) m = data_matrix.shape[0] covariance_matrix = data_matrix.transpose() * data_matrix covariance_matrix /= m # find principal components eig_decomp = linalg.eigh( covariance_matrix ) # sorted by eig. values (ascending - we want descending) self._n = len(eig_decomp[0]) self._pcas = sp.zeros( (self._n, self._n) ) # one row will be one princ. comp. (starting from most important PC) for i in range(self._n): self._pcas[i, :] = eig_decomp[1][:, self._n - i - 1] self._eig_vals = list(eig_decomp[0]) self._eig_vals.reverse()
def __init__(self, owner): self.owner = owner self.data_concatenation = concatenation.Concatenation(self) self.data_imputation = imputation.Imputation(self) self.data_normalization = normalization.Normalization(self) self.configure_parameter_set()
def startNormalize(self): try: self.normalizer = normalization.Normalization( inputAudioFileName, targetLUFS) self.normalizer.normalize(inputAudioFileName, targetLUFS) self.printBarChar(self.histgrammPlotBefore, self.normalizer.histogramm) self.printBarChar(self.histgrammPlotAfter, self.normalizer.histogramm2) self.printChar(self.graphicsView_3, self.normalizer.plotSamplesArray1, self.normalizer.yArray1) self.printChar(self.waveFormPlotAfter, self.normalizer.plotSamplesArray2, self.normalizer.yArray2) except Exception as e: widgetMB = QtWidgets.QWidget() QtWidgets.QMessageBox.about( widgetMB, "Ошибка", "Не удалось нормализовать файл! Ошибка: " + str(e))
# test[i] = indices[-nb_val:] # # whole_indices = [] # train_indices = [] # test_indices = [] # for i in range(m): # # whole_indices += labels_loc[i] # train_indices += train[i] # test_indices += test[i] # np.random.shuffle(train_indices) # np.random.shuffle(test_indices) # return train_indices, test_indices data = data_UP.reshape(np.prod(data_UP.shape[:2]), np.prod(data_UP.shape[2:])) gt = gt_UP.reshape(np.prod(gt_UP.shape[:2]), ) data = normalization.Normalization(data) data_ = data.reshape(data_UP.shape[0], data_UP.shape[1], data_UP.shape[2]) # data_trans = data.transpose() # whole_pca = doPCA.dimension_PCA(data_trans, data_UP, INPUT_DIMENSION) whole_pca = data_ #raw data print(whole_pca.shape) padded_data = zeroPadding.zeroPadding_3D(whole_pca, PATCH_LENGTH) ITER = 10 #ITER = 10 CATEGORY = 9 OA = [] AA = [] TRAINING_TIME = []
import normalization as normtool import permutation as permtool import sqlconnection as conntool sqlcon = conntool.SQLConnection("db/sentiment.db") your_api_key = "" norm = normtool.Normalization() perm = permtool.Permutation(api_key=your_api_key, max_meanings=3, use_local_meanings=True) counter_save_local_meanings = 0 while True: progress = sqlcon.getNumberOfSamplesToExpand() print(progress) samplesToExpand = sqlcon.getSamplesToExpand() if len(samplesToExpand) == 0: break for sample in samplesToExpand: sampleId, message, status = sample text = norm.transform(message) disambiguation_set = perm.getDisambiguation(text) meanings = perm.getMeanings(disambiguation_set) new_samples = perm.transform(text,
t0 = t000 = float(time.clock()) data = cPickle.load(open('cifar_2class_py2.p', 'rb')) t1 = float(time.clock()) print('Loading time is %.4f s. \n' % (t1 - t0)) newdir = './result/result_%s' % (t1) if not os.path.exists(newdir): os.makedirs(newdir) newdir += '/' f = open(newdir + '/runtime.txt', 'w') #plt.figure() #plt.plot([1,2,3,4,3,5],'-r') #plt.show() x, test_x = nor.Normalization(data['train_data'], data['test_data']) train_y = data['train_labels'] test_y = data['test_labels'] num_epochs = 30 num_batches = 1000 #batch_list = [100] # tune batch_list = [100, 500, 1000, 2000] # tune hidden_units = 100 # fix learning when tuning other #hiddenU_list = [100,1000] # tune hiddenU_list = [10, 100, 1000] # tune lr = 0.001 # fix learning when tuning other #lr_list = [0.001] # tune learning_rate lr_list = [0.005, 0.001, 0.0005, 0.0001] # tune learning_rate mu = 0.8 # fix momentum to 0.8
ojo_dcho = detector_cara.calculate_centroide(puntos, detector_cara.RIGHT_EYE_POINTS) ojo_izdo = detector_cara.calculate_centroide(puntos, detector_cara.LEFT_EYE_POINTS) p1x = faces[0][0] p1y = faces[0][1] - 20 p2x = faces[0][2] p2y = faces[0][3] w = p2x - p1x h = p2y - p1y oix = ojo_izdo[0] - p1x oiy = ojo_izdo[1] - p1y odx = ojo_dcho[0] - p1x ody = ojo_dcho[1] - p1y roi_img = img[p1y:p1y + h, p1x:p1x + w] roi_gray = cv2.cvtColor(roi_img, cv2.COLOR_BGR2GRAY) normalizator = normalization.Normalization() normalizator.normalize_gray_img(roi_gray, odx, ody, oix, oiy, normalization.Kind_wraping.HS) img_final = cv2.resize(normalizator.norm_image, (227, 227)) cv2.imwrite('normaHS.jpeg', img_final) img2 = cv2.imread('normaHS.jpeg') female, male = GenderHSNet.image_gender_classifier("normaHS.jpeg") print(os.path.join(base, file)) if male * 100 > 50: # meter en man os.rename(os.path.join(base, file), os.path.join(manDir, file)) print(os.path.join(manDir, file)) print('probabilidad de ser hombre', male * 100) else: # meter en woman