def calculate_hidden_size(self): samples_in_training_data = 116100 scaling_factor = 5 input_neurons = self.input_size output_neurons = self.output_size size = int(samples_in_training_data / (scaling_factor * (input_neurons + output_neurons))) LoggerHelper.info('Calculated hidden size is ' + str(size)) if size == 0: LoggerHelper.error('Calculated hidden size is changed to 2') return 2 else: return size
def get_news_type(dnn_type): dnn_type = dnn_type.strip() if dnn_type == "CNN": return NewsCnnMain() elif dnn_type == "RNN": return NewsDnnGeneralMain() elif dnn_type == "TA": return TaMain() elif dnn_type == "PriceRNN": return PriceRnnMain() elif dnn_type == "CATE": return NewsCateMain() else: # Default RNN LoggerHelper.error("DNN type (" + dnn_type + ") is not found. Default RNN (NewsDnnGeneralMain) is used.") return NewsDnnGeneralMain()
async def __random_news_handler(self, request): request = await request.json() print(request) default = self.get_news_data(self.db, self.defaultCollection, request['object_id']) if default is None: res = {'isError': True, 'Message': "Object Is Not Found."} res = JSONEncoder().encode(res) return web.json_response(res) else: try: self.toCollection.insert({ "_id": default["_id"], "title": default["title"], "summery": default["summery"], "article": default['authors'], "url": default["url"], "category": request["categories"], "price_after_minute": default["price_after_minute"], "price_after_hour": default["price_after_hour"], "price_after_day": default["price_after_day"], "price_before": default["price_before"], "wiki_relatedness": default["wiki_relatedness"], "tweet_count": default["tweet_count"], "tweet_percentage": default["tweet_percentage"], "wiki_relatedness_nor": default["wiki_relatedness_nor"], "tweet_count_nor": default["tweet_count_nor"], "date": default["date"], "authors": default["authors"], "comment": request['comment'], "price_effect": request['effect'] }) default['is_controlled'] = True default['is_incorrect'] = False self.record_one_field(self.defaultCollection, default) # price_effect effect res = {'isError': False, 'Message': "Success"} except Exception as exception: res = { 'isError': True, 'Message': "Insert Error. Please inform the Admin" } LoggerHelper.error(type(exception).__name__) LoggerHelper.error("Ex: " + str(exception)) LoggerHelper.error(traceback.format_exc()) res = JSONEncoder().encode(res) return web.json_response(res)
LoggerHelper.info("News Stock Prediction is ended.") # WordEmbedding(path=Config.word_embedding.path) # news_dnn = NewsDnnMain(epochs=int(Config.training.epochs), # batch_size=int(Config.training.batch_size), # seq_length=int(Config.training.sequence_length), # lr=float(Config.training.lr))3 if args.statistics: LoggerHelper.info("Starting Statistic Collection Mode...") Statistics().collect() LoggerHelper.info("Statistic Collection is ended...") if args.test: LoggerHelper.info("Starting Test Mode...") TransformersTest.sentiment_analysis_test() LoggerHelper.info("Test Mode is ended...") if args.webservice: web_manager = WebManager() web_manager.add_static_files() web_manager.add_news_root() web_manager.run() if __name__ == "__main__": try: main() except Exception as exception: LoggerHelper.error("Ex: " + str(exception)) LoggerHelper.error(traceback.format_exc()) exit()