首页 > 解决方案 > 变量范围附加一个数字

问题描述

在某些情况下,我会在变量范围内附加一个数字(即使我设置了reuse=True

假设我做了类似的事情:

import tensorflow as tf

with tf.Session() as session:
    graph = tf.Graph()
    with graph.as_default():
        with tf.variable_scope("Foo", reuse=True):
            tf.placeholder(dtype=tf.float64, name="A")

        # Do something else here.. 

        with tf.variable_scope("Foo", reuse=True):
            tf.placeholder(dtype=tf.float64, name="B")

        writer = tf.summary.FileWriter('/tmp/tf', graph=graph)
        writer.flush()

为什么我看到(张量板)两个分组(Foo,Foo_1):

在此处输入图像描述

我希望将 A 和 B 放在同一组中,但仍将两个with语句分开。

我认为与其他现有问题的一个关键区别是我在问:我该怎么做?

标签: pythontensorflowmachine-learning

解决方案


推荐阅读