Пример #1
0
 def __plot(self):
     try:
         self.__bpNN.plot()
     except Exception, ex:
         print ex
         funcUtil.write_log('plot')
         self.__success = False
Пример #2
0
 def record_result(file_name, data):
     try:
         tmp_path = funcUtil.getTmpPath(unique_id, file_name)
         with open(tmp_path, 'w') as f:
             f.write(json.dumps(data))
     except Exception, ex:
         print ex
         funcUtil.write_log('recordSparkResult')
Пример #3
0
    def __predict(self):
        print 'predicting future data ...'
        predict_s_time = time.time()

        try:
            self.__bpNN.predictFuture()
        except Exception, ex:
            print ex
            funcUtil.write_log('predictFuture')
            self.__success = False
Пример #4
0
    def __train(self):
        print 'training neural network ...'
        funcUtil.recordStatus(self.__id, 'training neural network ...')
        train_s_time = time.time()

        try:
            self.__bpNN.train()
        except Exception, ex:
            print ex
            funcUtil.write_log('train')
            self.__success = False
Пример #5
0
    def __preProcess(self):
        print 'pre processing data ...'
        funcUtil.recordStatus(self.__id, 'pre processing data ...')
        process_s_time = time.time()

        try:
            self.__bpNN.preProcess()
        except Exception, ex:
            print ex
            funcUtil.write_log('preProcess')
            self.__success = False
Пример #6
0
    def __load(self):
        print 'loading data ...'
        funcUtil.recordStatus(self.__id, 'loading data ...')
        load_s_time = time.time()

        try:
            o_load = load.Load(self.__dataConfig)  # 加载数据 并 进行数据预处理
            data_training, data_val, data_test, data_last = o_load.run()
            self.__bpNN.loadData(data_training, data_val, data_test, data_last)
        except Exception, ex:
            print ex
            funcUtil.write_log('load')
            self.__success = False
Пример #7
0
    def __init__(self, config):
        try:
            self.__dataConfig = config['data']
            self.__nnConfig = config['network']
            self.__id = config['id']
            self.__record = config['record']

            self.__nnConfig['id'] = self.__id
            self.__bpNN = NN.BPNN(self.__nnConfig)  # 初始化神经网络
            self.__success = True
        except Exception, ex:
            print ex
            funcUtil.write_log('config')
            self.__success = False
Пример #8
0
    def __recordResult(self):
        if not self.__record:
            return

        print 'recording result ...'
        funcUtil.recordStatus(self.__id, 'recording result ...')
        record_s_time = time.time()

        try:
            result = {
                'training_record': self.__bpNN.trainingRecord,
                'test_record': self.__bpNN.testRecord,
                'original_data': self.__bpNN.originalData,
                'pred': self.__bpNN.pred,
            }
            result = json.dumps(result)

            with open(funcUtil.getTmpPath(self.__id, 'result.tmp'), 'w') as f:
                f.write(result)
        except Exception, ex:
            print ex
            funcUtil.write_log('recordResult')