We proceed with the recipe as follows:
- 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 flagstf.app.flags.DEFINE_string("job_name", "", "Either 'ps' or 'worker'")tf.app.flags.DEFINE_integer("task_index", 0, "Index of task within the job")FLAGS = tf.app.flags.FLAGS# start a server for a specific taskserver = tf.train.Server( cluster, job_name=FLAGS.job_name, task_index=FLAGS.task_index)
- Read MNIST data and define ...