代码之家  ›  专栏  ›  技术社区  ›  Matěj Račinský

Tensorflow高效循环根历史池

  •  0
  • Matěj Račinský  · 技术社区  · 6 年前

    CycleGAN paper 这里提到了鉴别器的历史池。因此,我们从发生器中保留最后的样本,例如50个样本,并将它们输入鉴别器。没有历史,这很简单,我们可以利用 tf.data.Dataset 和迭代器将数据插入网络。但是在历史池中,我不知道如何使用 应用程序编程接口。 训练循环中的代码类似于

    fx, fy = sess.run(model_ops['fakes'], feed_dict={
        self.cur_x: cur_x,
        self.cur_y: cur_y,
    })
    
    cur_x, cur_y = sess.run([self.X_feed.feed(), self.Y_feed.feed()])
    feeder_dict = {
        self.cur_x: cur_x,
        self.cur_y: cur_y,
        self.prev_fake_x: x_pool.query(fx, step),
        self.prev_fake_y: y_pool.query(fy, step),
    }
    # self.cur_x, self.cur_y, self.prev_fake_x, self.prev_fake_y are just placeholders
    # x_pool and y_pool are simple wrappers for random sampling from the history pool and saving new images to the pool
    for _ in range(dis_train):
        sess.run(model_ops['train']['dis'], feed_dict=feeder_dict)
    for _ in range(gen_train):
        sess.run(model_ops['train']['gen'], feed_dict=feeder_dict)
    

    让我烦恼的是代码效率低下,例如,在培训期间不可能像以前一样预加载下一批代码 tf.data API的预取,但我看不到任何使用 tf.data 同样,当鉴别器train op和生成器train op之间有一定的比率时,也会出现类似的问题。 tf.data

    有没有办法正确有效地实施这一点?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Matěj Račinský    6 年前

    因此,我发现在中已经实现了历史记录池 TFGAN