<hr>
<h3 dir="auto">System information</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@:~/projects/tensorflow &lt;master&gt;$ cat tf_env.txt

== cat /etc/issue ===============================================
Darwin mn-mortutay 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Mac OS X 10.12.4

== are we in docker =============================================
No

== compiler =====================================================
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

== uname -a =====================================================
Darwin mn-mortutay 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

== check pips ===================================================
numpy (1.13.1)
protobuf (3.3.0)
tensorflow (1.2.1)

== check for virtualenv =========================================
False

== tensorflow import ============================================
tf.VERSION = 1.2.1
tf.GIT_VERSION = v1.2.0-5-g435cdfc
tf.COMPILER_VERSION = v1.2.0-5-g435cdfc
Sanity check: array([1], dtype=int32)
Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;tensorflow/__init__.py&quot;, line 24, in &lt;module&gt;
    from tensorflow.python import *
  File &quot;tensorflow/python/__init__.py&quot;, line 49, in &lt;module&gt;
    from tensorflow.python import pywrap_tensorflow
  File &quot;tensorflow/python/pywrap_tensorflow.py&quot;, line 52, in &lt;module&gt;
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File &quot;tensorflow/python/pywrap_tensorflow.py&quot;, line 41, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

== env ==========================================================
LD_LIBRARY_PATH is unset
DYLD_LIBRARY_PATH is unset

== nvidia-smi ===================================================
tf_env_collect.sh: line 105: nvidia-smi: command not found

== cuda libs  ==================================================="><pre class="notranslate"><code class="notranslate">@:~/projects/tensorflow &lt;master&gt;$ cat tf_env.txt

== cat /etc/issue ===============================================
Darwin mn-mortutay 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Mac OS X 10.12.4

== are we in docker =============================================
No

== compiler =====================================================
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

== uname -a =====================================================
Darwin mn-mortutay 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

== check pips ===================================================
numpy (1.13.1)
protobuf (3.3.0)
tensorflow (1.2.1)

== check for virtualenv =========================================
False

== tensorflow import ============================================
tf.VERSION = 1.2.1
tf.GIT_VERSION = v1.2.0-5-g435cdfc
tf.COMPILER_VERSION = v1.2.0-5-g435cdfc
Sanity check: array([1], dtype=int32)
Traceback (most recent call last):
  File "&lt;string&gt;", line 1, in &lt;module&gt;
  File "tensorflow/__init__.py", line 24, in &lt;module&gt;
    from tensorflow.python import *
  File "tensorflow/python/__init__.py", line 49, in &lt;module&gt;
    from tensorflow.python import pywrap_tensorflow
  File "tensorflow/python/pywrap_tensorflow.py", line 52, in &lt;module&gt;
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "tensorflow/python/pywrap_tensorflow.py", line 41, in &lt;module&gt;
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

== env ==========================================================
LD_LIBRARY_PATH is unset
DYLD_LIBRARY_PATH is unset

== nvidia-smi ===================================================
tf_env_collect.sh: line 105: nvidia-smi: command not found

== cuda libs  ===================================================
</code></pre></div>
<p dir="auto">Building from commit:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="* d74f65bac (Yun Peng, 3 hours ago) Make Windows Bazel GPU build work again (#11901)"><pre class="notranslate"><code class="notranslate">* d74f65bac (Yun Peng, 3 hours ago) Make Windows Bazel GPU build work again (#11901)
</code></pre></div>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">I'm following the instructions for Mac source installation (<a href="https://www.tensorflow.org/install/install_sources" rel="nofollow">https://www.tensorflow.org/install/install_sources</a>, "Prepare environment for Mac OS" and then "Build the pip package") but I'm running into issues with BoringSSL.</p>
<p dir="auto">It looks like the <code class="notranslate">-Wunused-but-set-parameter</code> and <code class="notranslate">-Wno-free-nonheap-object</code> flags are causing the compilation to fail, since <code class="notranslate">clang</code> does not support them.</p>
<p dir="auto">Expected behavior: The build system should detect this and handle it correctly, eg. by not using the un-available flags</p>
<p dir="auto">Actual behavior: Error / fails to build</p>
<h3 dir="auto">Source code / logs</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@:~/projects/tensorflow &lt;master&gt;$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
WARNING: /Users/mortutay/projects/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /Users/mortutay/projects/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Found 1 target...
INFO: From Compiling external/protobuf_archive/python/google/protobuf/internal/api_implementation.cc:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/swig/Source/Swig/typemap.c [for host]:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/core/lib/debug/trace.c:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/cpp/codegen/codegen_init.cc:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/core/ext/transport/chttp2/alpn/alpn.c:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
ERROR: /private/var/tmp/_bazel_mortutay/dacb21c644505cd819865fa365d2b69e/external/boringssl/BUILD:116:1: C++ compilation of rule '@boringssl//:crypto' failed (Exit 1).
error: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Werror,-Wunknown-warning-option]
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.829s, Critical Path: 0.91s"><pre class="notranslate"><code class="notranslate">@:~/projects/tensorflow &lt;master&gt;$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
WARNING: /Users/mortutay/projects/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /Users/mortutay/projects/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Found 1 target...
INFO: From Compiling external/protobuf_archive/python/google/protobuf/internal/api_implementation.cc:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/swig/Source/Swig/typemap.c [for host]:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/core/lib/debug/trace.c:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/cpp/codegen/codegen_init.cc:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
INFO: From Compiling external/grpc/src/core/ext/transport/chttp2/alpn/alpn.c:
warning: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Wunknown-warning-option]
2 warnings generated.
ERROR: /private/var/tmp/_bazel_mortutay/dacb21c644505cd819865fa365d2b69e/external/boringssl/BUILD:116:1: C++ compilation of rule '@boringssl//:crypto' failed (Exit 1).
error: unknown warning option '-Wunused-but-set-parameter'; did you mean '-Wunused-parameter'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-free-nonheap-object'; did you mean '-Wno-sequence-point'? [-Werror,-Wunknown-warning-option]
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.829s, Critical Path: 0.91s
</code></pre></div>
<p dir="auto">Tensorflow v2.0a</p>
<p dir="auto">When creating e.g. keras models I would assume, that when I run <code class="notranslate">make_generator_model</code> twice in eager mode that the <code class="notranslate">trainable_variable</code> names are identical.</p>
<p dir="auto"><strong>Why would I assume this?</strong><br>
Because the <code class="notranslate">tf.train.Checkpoint</code> and <code class="notranslate">Checkpointable</code> api makes you believe that variables are coupled with their corresponding object/class and uniquification of variables would be no longer necessary. And indeed, this is the case when creating a variable with the same name twice (as can be seen at the end of the code)</p>
<p dir="auto"><strong>What do I get instead?</strong><br>
In the below example the variables of the second <code class="notranslate">make_generator_model()</code> call will be <code class="notranslate">uniquified</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# First call
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Second
['dense_1/kernel:0', 'batch_normalization_v2_3/gamma:0', 'batch_normalization_v2_3/beta:0', 'conv2d_transpose_3/kernel:0', 'batch_normalization_v2_4/gamma:0', 'batch_normalization_v2_4/beta:0', 'conv2d_transpose_4/kernel:0', 'batch_normalization_v2_5/gamma:0', 'batch_normalization_v2_5/beta:0', 'conv2d_transpose_5/kernel:0']

# Third
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Fourth
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Manual Creation
&lt;tf.Variable 'test:0' shape=() dtype=int32, numpy=1&gt;
&lt;tf.Variable 'test:0' shape=() dtype=int32, numpy=1&gt;"><pre class="notranslate"><code class="notranslate"># First call
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Second
['dense_1/kernel:0', 'batch_normalization_v2_3/gamma:0', 'batch_normalization_v2_3/beta:0', 'conv2d_transpose_3/kernel:0', 'batch_normalization_v2_4/gamma:0', 'batch_normalization_v2_4/beta:0', 'conv2d_transpose_4/kernel:0', 'batch_normalization_v2_5/gamma:0', 'batch_normalization_v2_5/beta:0', 'conv2d_transpose_5/kernel:0']

# Third
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Fourth
['dense/kernel:0', 'batch_normalization_v2/gamma:0', 'batch_normalization_v2/beta:0', 'conv2d_transpose/kernel:0', 'batch_normalization_v2_1/gamma:0', 'batch_normalization_v2_1/beta:0', 'conv2d_transpose_1/kernel:0', 'batch_normalization_v2_2/gamma:0', 'batch_normalization_v2_2/beta:0', 'conv2d_transpose_2/kernel:0']

# Manual Creation
&lt;tf.Variable 'test:0' shape=() dtype=int32, numpy=1&gt;
&lt;tf.Variable 'test:0' shape=() dtype=int32, numpy=1&gt;
</code></pre></div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import tensorflow as tf
from tensorflow.keras import layers

def make_generator_model():
    model = tf.keras.Sequential()
    model.add(layers.Dense(7*7*256, use_bias=False, input_shape=(100,)))
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())

    model.add(layers.Reshape((7, 7, 256)))
    assert model.output_shape == (None, 7, 7, 256) # Note: None is the batch size

    model.add(layers.Conv2DTranspose(128, (5, 5), strides=(1, 1), padding='same', use_bias=False))
    assert model.output_shape == (None, 7, 7, 128)
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())

    model.add(layers.Conv2DTranspose(64, (5, 5), strides=(2, 2), padding='same', use_bias=False))
    assert model.output_shape == (None, 14, 14, 64)
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())

    model.add(layers.Conv2DTranspose(1, (5, 5), strides=(2, 2), padding='same', use_bias=False, activation='tanh'))
    assert model.output_shape == (None, 28, 28, 1)

    return model


m1 = make_generator_model()
noise = tf.random.normal([1, 100])
generated_image = m1(noise, training=False)
print([v.name for v in m1.trainable_variables])

m2 = make_generator_model()
noise = tf.random.normal([1, 100])
generated_image = m2(noise, training=False)
print([v.name for v in m2.trainable_variables])

with tf.Graph().as_default():
    m1 = make_generator_model()
    noise = tf.random.normal([1, 100])
    generated_image = m1(noise, training=False)
    print([v.name for v in m1.trainable_variables])

with tf.Graph().as_default():
    m2 = make_generator_model()
    noise = tf.random.normal([1, 100])
    generated_image = m2(noise, training=False)
    print([v.name for v in m2.trainable_variables])

a = tf.Variable(1, name='test')
b = tf.Variable(1, name='test')
print(a)
print(b)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>
<span class="pl-k">from</span> <span class="pl-s1">tensorflow</span>.<span class="pl-s1">keras</span> <span class="pl-k">import</span> <span class="pl-s1">layers</span>

<span class="pl-k">def</span> <span class="pl-en">make_generator_model</span>():
    <span class="pl-s1">model</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">keras</span>.<span class="pl-v">Sequential</span>()
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">Dense</span>(<span class="pl-c1">7</span><span class="pl-c1">*</span><span class="pl-c1">7</span><span class="pl-c1">*</span><span class="pl-c1">256</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">input_shape</span><span class="pl-c1">=</span>(<span class="pl-c1">100</span>,)))
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>())
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">LeakyReLU</span>())

    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">Reshape</span>((<span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">256</span>)))
    <span class="pl-k">assert</span> <span class="pl-s1">model</span>.<span class="pl-s1">output_shape</span> <span class="pl-c1">==</span> (<span class="pl-c1">None</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">256</span>) <span class="pl-c"># Note: None is the batch size</span>

    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">Conv2DTranspose</span>(<span class="pl-c1">128</span>, (<span class="pl-c1">5</span>, <span class="pl-c1">5</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">'same'</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>))
    <span class="pl-k">assert</span> <span class="pl-s1">model</span>.<span class="pl-s1">output_shape</span> <span class="pl-c1">==</span> (<span class="pl-c1">None</span>, <span class="pl-c1">7</span>, <span class="pl-c1">7</span>, <span class="pl-c1">128</span>)
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>())
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">LeakyReLU</span>())

    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">Conv2DTranspose</span>(<span class="pl-c1">64</span>, (<span class="pl-c1">5</span>, <span class="pl-c1">5</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span>(<span class="pl-c1">2</span>, <span class="pl-c1">2</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">'same'</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>))
    <span class="pl-k">assert</span> <span class="pl-s1">model</span>.<span class="pl-s1">output_shape</span> <span class="pl-c1">==</span> (<span class="pl-c1">None</span>, <span class="pl-c1">14</span>, <span class="pl-c1">14</span>, <span class="pl-c1">64</span>)
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">BatchNormalization</span>())
    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">LeakyReLU</span>())

    <span class="pl-s1">model</span>.<span class="pl-en">add</span>(<span class="pl-s1">layers</span>.<span class="pl-v">Conv2DTranspose</span>(<span class="pl-c1">1</span>, (<span class="pl-c1">5</span>, <span class="pl-c1">5</span>), <span class="pl-s1">strides</span><span class="pl-c1">=</span>(<span class="pl-c1">2</span>, <span class="pl-c1">2</span>), <span class="pl-s1">padding</span><span class="pl-c1">=</span><span class="pl-s">'same'</span>, <span class="pl-s1">use_bias</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">activation</span><span class="pl-c1">=</span><span class="pl-s">'tanh'</span>))
    <span class="pl-k">assert</span> <span class="pl-s1">model</span>.<span class="pl-s1">output_shape</span> <span class="pl-c1">==</span> (<span class="pl-c1">None</span>, <span class="pl-c1">28</span>, <span class="pl-c1">28</span>, <span class="pl-c1">1</span>)

    <span class="pl-k">return</span> <span class="pl-s1">model</span>


<span class="pl-s1">m1</span> <span class="pl-c1">=</span> <span class="pl-en">make_generator_model</span>()
<span class="pl-s1">noise</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>([<span class="pl-c1">1</span>, <span class="pl-c1">100</span>])
<span class="pl-s1">generated_image</span> <span class="pl-c1">=</span> <span class="pl-en">m1</span>(<span class="pl-s1">noise</span>, <span class="pl-s1">training</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-en">print</span>([<span class="pl-s1">v</span>.<span class="pl-s1">name</span> <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">m1</span>.<span class="pl-s1">trainable_variables</span>])

<span class="pl-s1">m2</span> <span class="pl-c1">=</span> <span class="pl-en">make_generator_model</span>()
<span class="pl-s1">noise</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>([<span class="pl-c1">1</span>, <span class="pl-c1">100</span>])
<span class="pl-s1">generated_image</span> <span class="pl-c1">=</span> <span class="pl-en">m2</span>(<span class="pl-s1">noise</span>, <span class="pl-s1">training</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-en">print</span>([<span class="pl-s1">v</span>.<span class="pl-s1">name</span> <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">m2</span>.<span class="pl-s1">trainable_variables</span>])

<span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-v">Graph</span>().<span class="pl-en">as_default</span>():
    <span class="pl-s1">m1</span> <span class="pl-c1">=</span> <span class="pl-en">make_generator_model</span>()
    <span class="pl-s1">noise</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>([<span class="pl-c1">1</span>, <span class="pl-c1">100</span>])
    <span class="pl-s1">generated_image</span> <span class="pl-c1">=</span> <span class="pl-en">m1</span>(<span class="pl-s1">noise</span>, <span class="pl-s1">training</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
    <span class="pl-en">print</span>([<span class="pl-s1">v</span>.<span class="pl-s1">name</span> <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">m1</span>.<span class="pl-s1">trainable_variables</span>])

<span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-v">Graph</span>().<span class="pl-en">as_default</span>():
    <span class="pl-s1">m2</span> <span class="pl-c1">=</span> <span class="pl-en">make_generator_model</span>()
    <span class="pl-s1">noise</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">random</span>.<span class="pl-en">normal</span>([<span class="pl-c1">1</span>, <span class="pl-c1">100</span>])
    <span class="pl-s1">generated_image</span> <span class="pl-c1">=</span> <span class="pl-en">m2</span>(<span class="pl-s1">noise</span>, <span class="pl-s1">training</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
    <span class="pl-en">print</span>([<span class="pl-s1">v</span>.<span class="pl-s1">name</span> <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">m2</span>.<span class="pl-s1">trainable_variables</span>])

<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">Variable</span>(<span class="pl-c1">1</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'test'</span>)
<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">Variable</span>(<span class="pl-c1">1</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">'test'</span>)
<span class="pl-en">print</span>(<span class="pl-s1">a</span>)
<span class="pl-en">print</span>(<span class="pl-s1">b</span>)</pre></div>