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 = LmTrainer.load(args.load) 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.windows * 2 + 1) nn = LmNetwork(input_size, args.hidden, 1) 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 } trainer = LmTrainer(nn, converter, options) 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 = LmTrainer.load(args.load) 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.windows nn = LmNetwork(input_size, args.hidden, 1) options = { 'learning_rate': args.learning_rate, 'eps': args.eps, 'ro': args.ro, 'verbose': args.verbose, 'left_context': args.window/2, 'right_context': args.window/2, 'ngram_size': args.ngrams } trainer = LmTrainer(nn, converter, options) 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 = LmTrainer.load(args.load) trainer.learning_rate = args.learning_rate else: logger.info('Creating new network...') trainer = LmTrainer(converter, args.learning_rate, args.window / 2, args.window / 2, args.hidden, ngrams=args.ngrams) 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 = LmTrainer.load(args.load) trainer.learning_rate = args.learning_rate else: logger.info('Creating new network...') trainer = LmTrainer(converter, args.learning_rate, args.window/2, args.window/2, args.hidden, ngrams=args.ngrams) trainer.saver = saver(args.output, args.vectors) logger.info("... with the following parameters:") logger.info(trainer.nn.description()) return trainer