def main(_): pp.pprint(flags.FLAGS.__flags) if not os.path.exists(FLAGS.checkpoint_dir): print(" [*] Creating checkpoint directory...") os.makedirs(FLAGS.checkpoint_dir) if FLAGS.game_name == "home": game = HomeGame(game_dir=FLAGS.game_dir, seq_length=FLAGS.seq_length) else: raise Exception(" [!] %s not implemented yet" % self.game_name) with tf.device('/cpu:0'): model = LSTMDQN(game, checkpoint_dir=FLAGS.checkpoint_dir, seq_length=FLAGS.seq_length, embed_dim=FLAGS.embed_dim, layer_depth=FLAGS.layer_depth, batch_size=FLAGS.batch_size, start_epsilon=FLAGS.start_epsilon, forward_only=FLAGS.forward_only, max_episode_length=FLAGS.max_episode_length) if not FLAGS.forward_only: model.train() else: test_loss = model.test(2) print(" [*] Test loss: %2.6f, perplexity: %2.6f" % (test_loss, np.exp(test_loss)))