def load_mat(self): filename = QFileDialog.getOpenFileName(self, 'Open file', '~', "mat files (*.mat)") if filename[0] != "": try: self.holder.parse_mat(filename[0]) self.partener.histogram() except Error as e: print_error_message(e.what())
def save(self): if not self.model.set(): print_error_message("Please train the model") return path = QFileDialog.getSaveFileName( self, "Save file", "", ".mat" )[0] savemat(path, self.model.getWeightDic())
def load_imgs(self): files = QFileDialog.getOpenFileNames(self, 'Open file', '~', "Image files (*.jpg *.jpeg *.png)") filenames = files[0] if len(filenames) != 0: try: self.holder.parse_images(filenames) self.partener.imshow(num=min(10, len(filenames))) except Error as e: print_error_message(e.what())
def plotEigenValues(self): if not self.model.isFitted(): print_error_message("Please fit the model first") return idx = self.getSelectedEigenValues() self.model.getEigenvectors() vecs = self.model.getEigenvectors()[idx] self.plotWidget.renderHolder().give(vecs) self.plotWidget.imshow()
def chooseFirstKEigenValues(self): k = self.firstKField.text() if k == "": print_error_message("K is required") return k = int(k) if not self.model.isFitted(): print_error_message("Please fit the model first") return for i in range(k): self.checkboxes[i].setChecked(True)
def fit(self): self.checkboxes = [] self.clearPlot() if not self.holder.loaded(): print_error_message("Please load data first") return X = self.holder.fetchAll() self.model.setup(X) self.model.fit() evs = self.model.getEigenvalues() self.showEigenValues(evs)
def fit(self): self.historyField.setText("") if not self.holder.loaded(): print_error_message("Please load data first") return try: self.reg = float(self.regField.text()) print("reg: ", self.reg) except: print_error_message("Invalid regularization, must be a real number") return try: self.order = int(self.orderField.text()) print("order: ", self.order) except: print_error_message("Invalid order, must be a integer") return try: self.learning_rate = float(self.learningrateField.text()) print("learning rate: ", self.learning_rate) except: print_error_message("Invalid learning rate, must be a real number") try: self.maxiter = int(self.maxiterField.text()) print("max iter: ", self.maxiter) except: print_error_message("Invalid max iter, must be a real number") self.optimizer = self.optimizerField.currentText() print("optimizer: ", self.optimizer) X, y, title = self.holder.fetch_ordered(self.order) self.model.setup(X, y, regularization=self.reg) def callback(iter, loss): self.historyField.append("iter: %d, loss: %.2f"%(iter, loss)) self.model.fit_gradient_descent(self.learning_rate, self.maxiter, self.optimizer, callback=callback) if len(self.holder.shape()) == 1: self.plot()
def createNewWindow(self, classname:str): try: self.newwindow = render_window(classname) self.newwindow.show() except Error as e: print_error_message(e.what())