Tensorflow variable_scope 中的 partitioner 参数有什么用?
What is partitioner parameter in Tensorflow variable_scope used for?
tf.variable_scope
有一个 partitioner
参数,如 documentation 中所述。
据我了解,它用于分布式训练。谁能更详细地解释一下它的正确用法是什么?
巨大的 tensorflow 变量可以跨多台机器进行分片(参见 this discussion)。 Partitioner 是一种机制,tensorflow 通过它分配和组装张量,以便程序的其余部分不知道这些实现细节并以通常的方式使用张量。
您可以通过 tf.get_variable
:
为每个变量指定分区程序
If a partitioner is provided, a PartitionedVariable is returned. Accessing this object as a Tensor returns the shards concatenated along the partition axis.
或者您通过 tf.variable_scope
为整个范围定义默认分区程序,这将影响其中定义的所有变量。
在 this page. The simplest one is tf.fixed_size_partitioner
, which shards the tensor along the specified axis. Here's an example usage (from this question 上查看 tensorflow 1.3 中的可用分区器列表):
w = tf.get_variable("weights",
weights_shape,
partitioner=tf.fixed_size_partitioner(num_shards, axis=0),
initializer=tf.truncated_normal_initializer(stddev=0.1))
tf.variable_scope
有一个 partitioner
参数,如 documentation 中所述。
据我了解,它用于分布式训练。谁能更详细地解释一下它的正确用法是什么?
巨大的 tensorflow 变量可以跨多台机器进行分片(参见 this discussion)。 Partitioner 是一种机制,tensorflow 通过它分配和组装张量,以便程序的其余部分不知道这些实现细节并以通常的方式使用张量。
您可以通过 tf.get_variable
:
If a partitioner is provided, a PartitionedVariable is returned. Accessing this object as a Tensor returns the shards concatenated along the partition axis.
或者您通过 tf.variable_scope
为整个范围定义默认分区程序,这将影响其中定义的所有变量。
在 this page. The simplest one is tf.fixed_size_partitioner
, which shards the tensor along the specified axis. Here's an example usage (from this question 上查看 tensorflow 1.3 中的可用分区器列表):
w = tf.get_variable("weights",
weights_shape,
partitioner=tf.fixed_size_partitioner(num_shards, axis=0),
initializer=tf.truncated_normal_initializer(stddev=0.1))