def create_trainer(args, converter): """ Creates or loads a neural network according to the specified args. """ logger = logging.getLogger("Logger") if args.load: logger.info("Loading provided network...") trainer = SentimentTrainer.load(args.load) # change learning rate trainer.learning_rate = args.learning_rate else: logger.info('Creating new network...') # sum the number of features in all extractors' tables input_size = converter.size() * (args.window * 2 + 1) nn = Network(input_size, args.hidden, 2) options = { 'learning_rate': args.learning_rate, 'eps': args.eps, 'ro': args.ro, 'verbose': args.verbose, 'left_context': args.window, 'right_context': args.window, 'ngram_size': args.ngrams, 'alpha': args.alpha } trainer = SentimentTrainer(nn, converter, options) trainer.saver = saver(args.model, args.vectors) logger.info("... with the following parameters:") logger.info(trainer.nn.description()) return trainer
def create_trainer(args, converter): """ Creates or loads a neural network according to the specified args. """ logger = logging.getLogger("Logger") if args.load: logger.info("Loading provided network...") trainer = SentimentTrainer.load(args.load) trainer.learning_rate = args.learning_rate else: logger.info('Creating new network...') trainer = SentimentTrainer(converter, args.learning_rate, args.window/2, args.window/2, args.hidden, args.ngrams, args.alpha) trainer.saver = saver(args.output, args.vectors) logger.info("... with the following parameters:") logger.info(trainer.nn.description()) return trainer
def create_trainer(args, converter): """ Creates or loads a neural network according to the specified args. """ logger = logging.getLogger("Logger") if args.load: logger.info("Loading provided network...") trainer = SentimentTrainer.load(args.load) trainer.learning_rate = args.learning_rate else: logger.info('Creating new network...') trainer = SentimentTrainer(converter, args.learning_rate, args.window / 2, args.window / 2, args.hidden, args.ngrams, args.alpha) trainer.saver = saver(args.output, args.vectors) logger.info("... with the following parameters:") logger.info(trainer.nn.description()) return trainer