MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / create_task_spec_def

Function create_task_spec_def

tensorlayer/distributed.py:367–393  ·  view source on GitHub ↗

Returns the a :class:`TaskSpecDef` based on the environment variables for distributed training. References ---------- - `ML-engine trainer considerations `__ - `TensorPort Distributed Computing <https://ww

()

Source from the content-addressed store, hash-verified

365
366@deprecated(date="2018-10-30", instructions="Using the TensorLayer distributed trainer.")
367def create_task_spec_def():
368 """Returns the a :class:`TaskSpecDef` based on the environment variables for distributed training.
369
370 References
371 ----------
372 - `ML-engine trainer considerations <https://cloud.google.com/ml-engine/docs/trainer-considerations#use_tf_config>`__
373 - `TensorPort Distributed Computing <https://www.tensorport.com/documentation/code-details/>`__
374
375 """
376 if 'TF_CONFIG' in os.environ:
377 # TF_CONFIG is used in ML-engine
378 env = json.loads(os.environ.get('TF_CONFIG', '{}'))
379 task_data = env.get('task', None) or {'type': 'master', 'index': 0}
380 cluster_data = env.get('cluster', None) or {'ps': None, 'worker': None, 'master': None}
381 return TaskSpecDef(
382 task_type=task_data['type'], index=task_data['index'],
383 trial=task_data['trial'] if 'trial' in task_data else None, ps_hosts=cluster_data['ps'],
384 worker_hosts=cluster_data['worker'], master=cluster_data['master'] if 'master' in cluster_data else None
385 )
386 elif 'JOB_NAME' in os.environ:
387 # JOB_NAME, TASK_INDEX, PS_HOSTS, WORKER_HOSTS and MASTER_HOST are used in TensorPort
388 return TaskSpecDef(
389 task_type=os.environ['JOB_NAME'], index=os.environ['TASK_INDEX'], ps_hosts=os.environ.get('PS_HOSTS', None),
390 worker_hosts=os.environ.get('WORKER_HOSTS', None), master=os.environ.get('MASTER_HOST', None)
391 )
392 else:
393 raise Exception('You need to setup TF_CONFIG or JOB_NAME to define the task.')
394
395
396@deprecated(date="2018-10-30", instructions="Using the TensorLayer distributed trainer.")

Callers

nothing calls this directly

Calls 2

TaskSpecDefClass · 0.85
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…