ac2*_*051 6 python tensorflow tensorflow-datasets
我需要随机生成合成的内存数据(以pandas DataFrames的形式),并将其提供给分布在多个参数服务器和工作器上的TensorFlow Estimator.我怎样才能做到这一点?哪个服务器应该负责生成数据,如何将它们传递给其他服务器?沿着这些方向会有什么作用吗?
def main(_):
ps_hosts = FLAGS.ps_hosts.split(",")
worker_hosts = FLAGS.worker_hosts.split(",")
#Create a cluster from the parameter server and worker hosts.
cluster = tf.train.ClusterSpec({"ps": ps_hosts, "worker": worker_hosts})
#Create and start a server for the local task.
server = tf.train.Server(cluster, job_name=FLAGS.job_name, task_index=FLAGS.task_index)
if FLAGS.job_name == "ps":
server.join()
elif FLAGS.job_name == "worker":
if FLAGS.task_index==0:
train_data, train_labels = generate_synthetic_data()
eval_data, eval_labels = generate_synthetic_data()
test_data, test_labels = generate_synthetic_data()
with tf.device(tf.train.replica_device_setter( worker_device="/job:worker/task:%d" % FLAGS.task_index, cluster=cluster)):
# Run training
train_and_evaluate()
if __name__ == "__main__":
tf.app.run(main=main, argv=[sys.argv[0]])
Run Code Online (Sandbox Code Playgroud)
或者,类似地,在 https://www.tensorflow.org/tutorials/estimators/linear#overview中,他们创建两个pandas数据帧,然后将其提供给Estimator.该代码将如何并行化?