- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我读过 Distributed TensorFlow Doc和 this question on StackOverflow但我仍然对可以使用 TensorFlow 及其参数服务器架构完成的分布式训练背后的动力持怀疑态度。这是分布式 TensorFlow 文档中的一段代码:
if FLAGS.job_name == "ps":
server.join()
elif FLAGS.job_name == "worker":
# Assigns ops to the local worker by default.
with tf.device(tf.train.replica_device_setter(
worker_device="/job:worker/task:%d" % FLAGS.task_index,
cluster=cluster)):
# Build model...
loss = ...
global_step = tf.contrib.framework.get_or_create_global_step()
train_op = tf.train.AdagradOptimizer(0.01).minimize(
loss, global_step=global_step)
这里是我读到的 StackOverflow 问题的部分答案:
The worker reads all of the shared model parameters in parallel fromthe PS task(s), and copies them to the worker task. These reads areuncoordinated with any concurrent writes, and no locks are acquired:in particular the worker may see partial updates from one or moreother workers (e.g. a subset of the updates from another worker mayhave been applied, or a subset of the elements in a variable may havebeen updated).
The worker computes gradients locally, based on a batchof input data and the parameter values that it read in step 1.
Theworker sends the gradients for each variable to the appropriate PStask, and applies the gradients to their respective variable, using anupdate rule that is determined by the optimization algorithm (e.g.SGD, SGD with Momentum, Adagrad, Adam, etc.). The update rulestypically use (approximately) commutative operations, so they may beapplied independently on the updates from each worker, and the stateof each variable will be a running aggregate of the sequence ofupdates received.
我必须在另一个环境中重现这种参数服务器架构,我需要深入了解 worker 和 PS 任务在 TensorFlow 框架内是如何交互的。我的问题是,PS 任务是在从工作人员那里收到值后进行某种合并或更新操作,还是只存储最新值?只存储最新的值可以是合理的吗?查看 TensorFlow 文档中的代码,我看到 PS 任务只是执行一个 join(),我想知道这个方法调用背后是 PS 任务的完整行为。
还有一个问题,计算梯度和应用梯度有什么区别?
最佳答案
让我们倒过来从你的最后一个问题开始:计算梯度和应用梯度有什么区别?
计算梯度意味着在计算损失后在网络上运行反向传播。对于梯度下降,这意味着估计下面公式中的 gradients
值(注意:这是计算梯度实际需要的巨大简化,查看更多关于反向传播和梯度的信息下降以正确解释其工作原理)。 应用梯度意味着根据您刚刚计算的梯度更新参数。对于梯度下降,这(大致)意味着执行以下操作:
weights = weights - (learning_step * gradients)
请注意,根据 learning_step
的值,weights
的新值取决于先前的值和计算的权重。
记住这一点,就更容易理解 PS/worker 架构了。让我们做一个简单的假设,只有一个 PS(我们稍后会看到如何扩展到多 PS)
PS(参数服务器)在内存中保存权重
(即参数)并接收梯度
,运行我写的更新步骤在上面的代码中。每次从工作人员那里收到梯度时,它都会这样做。
另一方面,工作人员在 PS 中查找 weights
的当前值是多少,在本地制作一个副本,向前和向后运行在一批数据上传递网络并获得新的梯度
,然后将其发送回 PS。
注意对“当前”的强调:worker 和 PS 之间没有锁定或进程间同步。如果工作人员在更新过程中读取 weights
(例如,一半已经有了新值,另一半仍在更新),这就是他将在下一次迭代中使用的权重。这使事情变得快速。
如果有更多 PS 怎么办? 没问题!网络的参数在 PS 之间分区,工作人员只需联系所有这些参数以获得每个参数 block 的新值,并仅发回与每个特定 PS 相关的梯度。
关于python - 分布式 TensorFlow [异步,图间复制] : which are the exactly interaction between workers and servers regarding Variables update,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49150587/
本周我将在 Windows Server 2008 上设置一个专用的 SQL Server 2005 机器,并希望将其精简为尽可能简单,同时仍能发挥全部功能。 为此,“服务器核心”选项听起来很有吸引力
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 8 年前。 Improve
我获取了 2014 版本数据库的备份,并尝试在另一台服务器中将其恢复到具有相同名称和登录名的数据库中。此 SQL Server 版本是 2016。 恢复备份文件时,出现此错误: TITLE: Micr
我获取了 2014 版本数据库的备份,并尝试在另一台服务器中将其恢复到具有相同名称和登录名的数据库中。此 SQL Server 版本是 2016。 恢复备份文件时,出现此错误: TITLE: Micr
TFS 是否提供任何增强的方法来存储对 sql server 数据库所做的更改,而不是使用它来对在数据库上执行的 sql 语句的文本文件进行版本控制? 或者我正在寻找的功能是否仅在第 3 方工具(如
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我即将将我的 SQL Server 2012 实例升级到 SQL Server 2014。 我已经克隆了主机 Windows VM 并将其重命名为 foo-2012至 foo-2014 . 重新启动时
我想为 SQL Server 登录授予对数据库的访问权限。我知道 sp_grantdbaccess,但它已被弃用。我可以改用什么以及如何检查登录名是否还没有访问数据库的权限? 场景:UserA 创建数
客户别无选择,只能在接下来的几天内从 sql server 2000 迁移到 2008。测试显示 2005 年的重要功能出现了 Not Acceptable 性能下降,但 2008 年却没有。好消息是
我有一个测试数据库,我需要将其导出到我们客户的测试环境中。 这将是一次性的工作。 我正在使用 SQL Server 2005(我的测试数据库是 SQL Server 2005 Express) 执行此
我需要将一个 CSV 文件导入到 mongoDB 不幸的是我遇到了以下错误: error connecting to host: could not connect to server: se
我以为 R2 是一个补丁/服务包。我一直在寻找下载,但没有看到。因此,我假设 R2 是一个新版本,并且我需要 sqlserver 2008 r2 的安装介质来进行升级? 另外,我需要为新许可证付费吗?
我无法使用 SQL Server Management Studio 连接到 SQL Server。 我有一个连接字符串: 我尝试通过在服务器名中输入 myIP、在登录名中输入 MyID、在密码中
我们希望使用 SQL Server 加密来加密数据库中的几个列。我们还需要在生产和测试环境之间传输数据。看来最好的解决方案是在生产和测试服务器上使用相同的主 key 、证书和对称 key ,以便我可以
有没有可以分析 SQL Server 数据库潜在问题的工具? 例如: a foreign key column that is not indexed 没有 FILL FACTOR 的 uniquei
我正在尝试从我的 SQL 2012 BI 版本建立复制,但我收到一条奇怪的错误消息! "You cannot create a publication from server 'X' because
如果您使用 SQL Server 身份验证 (2005),登录详细信息是否以明文形式通过网络发送? 最佳答案 如您所愿,安全无忧... 您可以相当轻松地配置 SSL,如果您没有受信任的证书,如果您强制
我想将数据从一个表复制到不同服务器之间的另一个表。 如果是在同一服务器和不同的数据库中,我使用了以下 SELECT * INTO DB1..TBL1 FROM DB2..TBL1 (to copy w
我希望得到一些帮助,因为我在这个问题上已经被困了 2 天了! 场景:我可以从我的开发计算机(和其他同事)连接到 SERVER\INSTANCE,但无法从另一个 SQL Server 连接。我得到的错误
我正在尝试从我的 SQL 2012 BI 版本建立复制,但我收到一条奇怪的错误消息! "You cannot create a publication from server 'X' because
我是一名优秀的程序员,十分优秀!