async_adder.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:stuff 作者: yaroslavvb 项目源码 文件源码
def load_config():
  """Returns ClusterConfig object. Config contains task spec and cluster spec in dictionary-like form as below
  # {"task": {"index": 0, "type": "worker"}, "cluster": {"worker": ["localhost:24724"], "ps": ["localhost:15960"]}}
  """
  # old way that doesn't work for sparse format
  # if 'TF_CONFIG' not in os.environ:
  #   # try loading encoded version
  #   if 'TF_CONFIG_BASE16' in os.environ:
  #     tf_config_str = base64.b16decode(os.environ['TF_CONFIG_BASE16'])
  #     tf_config_str = tf_config_str.decode('ascii')
  #     os.environ['TF_CONFIG'] = tf_config_str
  #     del os.environ['TF_CONFIG_BASE16']
  #   else:
  #     assert False, "Must specify TF_CONFIG or TF_CONFIG_BASE16"

#  from tensorflow.contrib.learn.python.learn.estimators.run_config import ClusterConfig

  config = MyClusterConfig()
  config_dict = pickle.loads(base64.b16decode(os.environ["TF_PICKLE_BASE16"]))
  config.task_type = config_dict["task"]["type"]
  config.task_id = config_dict["task"]["index"]
  config.cluster_spec = config_dict["cluster"]
  return config
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号