小编nab*_*ost的帖子

在张量流分布式训练中如何进行评估和推理?

我了解tensorflow分布式培训,并且实现了自己的脚本。

我现在想要做的是整合为某些工作人员分配异步评估模型任务的可能性。

假设我们有6个工作人员,我要做的是使用其中4个工作人员进行异步培训,一个工作人员定期评估模型,另一个工作人员定期进行模型推断。

我的直觉是实现以下目标:

....
elif FLAGS.job_name == "worker":

    if FLAGS.task_index <= (len(cluster_dict["worker"][:-2]) - 1):
         logging.info("Training worker started")
         ...
        with tf.device(tf.train.replica_device_setter(
                worker_device="/job:worker/task:%d" % FLAGS.task_index,
                cluster=cluster,
                ps_tasks=len(cluster_dict["ps"])
            )):
                train_model = Model(
                    mode=tf.contrib.learn.ModeKeys.TRAIN
                )
               with tf.train.MonitoredTrainingSession(
                    is_chief=(FLAGS.task_index == 0),
                    master=server.target,
                    checkpoint_dir=ckpt_dir,
                    config=config_proto,
                    hooks=hooks
                ) as mon_sess:
                    while not mon_sess.should_stop():
                        res = train_model.train(...)
                        ...

   elif FLAGS.task_index == (len(cluster_dict["worker"][-2]) - 1):
         logging.info("Evaluation worker started")
         ...
         with tf.device(tf.train.replica_device_setter(
              worker_device="/job:worker/task:%d" % FLAGS.task_index,
              cluster=cluster,
              ps_tasks=len(cluster_dict["ps"])
          )):
              eval_model = Model(
                 mode=tf.contrib.learn.ModeKeys.EVAL
              )
              ...

   elif FLAGS.task_index == (len(cluster_dict["worker"][-1]) - …
Run Code Online (Sandbox Code Playgroud)

python distributed distributed-computing tensorflow

5
推荐指数
0
解决办法
523
查看次数