How to do it...

We proceed with the recipe as follows:

  1. Import a few standard modules and define the TensorFlow cluster where the computation is run. Then start a server for a specific task
import tensorflow as tfimport sysimport time# cluster specificationparameter_servers = ["pc-01:2222"]workers = [ "pc-02:2222","pc-03:2222","pc-04:2222"]cluster = tf.train.ClusterSpec({"ps":parameter_servers, "worker":workers})# input"job_name", "", "Either 'ps' or 'worker'")"task_index", 0, "Index of task within the job")FLAGS = start a server for a specific taskserver = tf.train.Server(  cluster,  job_name=FLAGS.job_name,  task_index=FLAGS.task_index)
  1. Read MNIST data and define ...

Get TensorFlow 1.x Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.