def confirmParameters(self):
        errorMessage = ''
        if not self.isNumber(self.setLossRateEdit.text()):
            errorMessage = errorMessage + '缺失率无效输入\n'
        elif float(self.setLossRateEdit.text()) > 1. or float(
                self.setLossRateEdit.text()) < 0.:
            errorMessage = errorMessage + '缺失率输入范围错误\n'

        if not self.isNumber(self.setLossValueEdit.text()):
            errorMessage = errorMessage + '缺失标示值无效输入\n'

        if errorMessage != '':
            errorMessage = errorMessage + '请重新输入参数'
            reply = QMessageBox.information(self, '输入错误', errorMessage,
                                            QMessageBox.Yes, QMessageBox.Yes)

            self.setLossRateEdit.setText(
                str(self.parentW.dataLossRate[self.senderName]))
            self.setLossValueEdit.setText(
                str(self.parentW.dataSetLossValue[self.senderName]))
            return

        else:
            self.parentW.dataLossRate[self.senderName] = float(
                self.setLossRateEdit.text())
            self.parentW.dataSetLossValue[self.senderName] = float(
                self.setLossValueEdit.text())
            if self.parentW.fname[self.senderName] is not None:
                try:
                    self.parentW.dataFor[
                        self.senderName] = myLoadData.loadData(
                            self.parentW.fname[self.senderName],
                            self.parentW.dataLossRate[self.senderName],
                            self.parentW.dataSetLossValue[self.senderName])

                except FileNotFoundError as e:
                    reply = QMessageBox.information(
                        self, 'Message',
                        "Data file doesn't exist, parameters' saved",
                        QMessageBox.Yes, QMessageBox.Yes)
                    # print(self.parentW.dataFor[self.senderName].DataTrainX)
                    self.close()
                    return

            # if self.parentW.dataFor['New'] is not None:
            #     print(self.parentW.dataFor['New'].DataTrainX, '\n', self.parentW.dataFor['New'].DataTrainY)
            # else:
            #     print(self.parentW.dataFor['New'])
            #
            # if self.parentW.dataFor['Tra'] is not None:
            #     print(self.parentW.dataFor['Tra'].DataTrainX, '\n', self.parentW.dataFor['Tra'].DataTrainY)
            # else:
            #     print(self.parentW.dataFor['Tra'])

            reply = QMessageBox.information(self, 'Message',
                                            "Parameters' saved successfully",
                                            QMessageBox.Yes, QMessageBox.Yes)
            self.close()
            return
Exemple #2
0
    def loadData(self):
        if self.sender() is self.dataFileChooseButton:
            try:
                self.dataFor['New'] = myLoadData.loadData(self.fname['New'], self.dataLossRate['New'], self.dataSetLossValue['New'])
                # print(self.dataFor['New'].DataTrainX, '\n', self.dataFor['New'].DataTrainY)

            except FileNotFoundError as e:
                reply = QMessageBox.information(self, 'Message', "Data file not exist",
                                             QMessageBox.Yes, QMessageBox.Yes)
                return

            except Exception:
                reply = QMessageBox.information(self, 'Message', "Data file format error",
                                             QMessageBox.Yes, QMessageBox.Yes)
                return

            dataname = self.fname['New'].split('/')[-1].split('.')[0]
            # print(dataname)
            self.presentDataName.setText(dataname)
            self.presentDataName.resize(self.presentDataName.sizeHint())

        elif self.sender() is self.dataFileChooseButtonT:
            try:
                self.dataFor['Tra'] = myLoadData.loadData(self.fname['Tra'], self.dataLossRate['Tra'], self.dataSetLossValue['Tra'])
                # print(self.dataFor['Tra'].DataTrainX, '\n', self.dataFor['Tra'].DataTrainY)

            except FileNotFoundError as e:
                reply = QMessageBox.information(self, 'Message', "Data file not exist",
                                             QMessageBox.Yes, QMessageBox.Yes)
                return

            except Exception:
                reply = QMessageBox.information(self, 'Message', "Data file format error",
                                             QMessageBox.Yes, QMessageBox.Yes)
                return

            dataname = self.fname['Tra'].split('/')[-1].split('.')[0]
            # print(dataname)
            self.presentDataNameT.setText(dataname)
            self.presentDataNameT.resize(self.presentDataNameT.sizeHint())

        return
Exemple #3
0
            fp.close()

        except Exception:
            return False

        self.inputLayer = fullConnect.fullConnectInputLayer(
            model['fullConnect']['inputLayer']['inputDataShape'], 0.2)
        self.inputLayer.setWeight(model['fullConnect']['inputLayer']['weight'])

        self.midLayer = fullConnect.fullConnectMidLayer(
            model['fullConnect']['midLayer']['midInputDataShape'],
            model['fullConnect']['midLayer']['yclassNum'], 0.2)
        self.midLayer.setWeight(model['fullConnect']['midLayer']['weight'])

        # self.forwardPropagation(self.data.DataTestX)
        # print(self.predictResult)
        # print(costFunc.costCal(self.predictResult, self.data.DataTestY))
        # print(self.data.DataTestY)
        # print(accuracyEvaluate.classifyAccuracyRate(self.predictResult, self.data.DataTestY))
        return True


if __name__ == '__main__':
    # irisDATA = myLoadData.loadData('iris.txt')
    # traNN = traditionalNN(irisDATA)

    wineData = myLoadData.loadData('wine.txt', 0.3, -1)
    wineData.MeanPreProcess()
    wineData.minmax_scale()
    traNN = traditionalNN(wineData)
    traNN.train(6000, 0.9, 2)
Exemple #4
0
    def setModel(self, fname):
        try:
            fp = open(fname, 'r')
            model = json.load(fp)
            fp.close()

        except FileNotFoundError:
            return False

        self.inputLayer = fullConnect.fullConnectInputLayer(
            model['fullConnect']['inputLayer']['inputDataShape'], 0.2)
        self.inputLayer.setWeight(model['fullConnect']['inputLayer']['weight'])

        self.midLayer = fullConnect.fullConnectMidLayer(
            model['fullConnect']['midLayer']['midInputDataShape'],
            model['fullConnect']['midLayer']['yclassNum'], 0.2)
        self.midLayer.setWeight(model['fullConnect']['midLayer']['weight'])

        # self.forwardPropagation(self.data.DataTestX)
        # print(self.predictResult)
        # print(costFunc.costCal(self.predictResult, self.data.DataTestY))
        # print(self.data.DataTestY)
        # print(accuracyEvaluate.classifyAccuracyRate(self.predictResult, self.data.DataTestY))
        return True


if __name__ == '__main__':
    irisDATA = myLoadData.loadData('..\\iris.txt')
    traNN = traditionalNN(irisDATA)
    traNN.train(500, 0.9, 2, [True], threading.Lock())
Exemple #5
0
                raise myException.DataValidFormatException

            if self.data.DataX.shape[1] != self.combConvLayer1.getFeatureNum():
                raise myException.DataModelMatchException

        if setChoose == 'Train':
            self.forwardPropagation()

        elif setChoose == 'Test':
            self.forwardPropagation(self.data.DataTestX)

        elif setChoose == 'Validation':
            self.forwardPropagation(self.data.DataValX)


if __name__ == '__main__':
    # irisDATA = myLoadData.loadIris(0.3, -1)
    # mcnn = myCombineCNN(irisDATA, 2, 5, 4)
    # mcnn.trainCNN(1600,0.2, [True])

    irisDATA = myLoadData.loadData('..\\iris.txt', 0.3, -1)
    mcnn = myCombineCNN(irisDATA, 2, 5, 4)
    mcnn.trainCNN(1600, 0.2, [True], threading.Lock())

# self.data = None
# if dataName == 'Iris':
#     self.data = myLoadData.loadIris()
# else:
#     print('No such data file, Waiting for new data set\n')
#     exit(1) # todo throw error or set new data