您的位置:首页 > 其它

TensorFlow 分布式集群 Local Server

2017-10-18 09:01 148 查看
在 TensorFlow 中提供了一个简单分布式的服务(Local Server)功能,利用 Local Server 服务,可以运行一个简单的分布式程序。Local Server 实现了与和分布式服务一样的接口,因此对于开发测试还是比较方便的。

下面是最简单的例子

import tensorflow as tf
server = tf.train.Server.create_local_server()
with tf.Session(server.target) as session:
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = session.run(product)
print result


其中,tf.train.Server.create_local_server() 方法创建了一个单一的进程集群。

此外,运行这个程序,实际上是 server 和 client 启动在了同一个进程了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  TensorFlow