<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow):</strong><br>
Yes</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04):</strong><br>
Debian Buster (Debian 10)</li>
<li><strong>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:</strong><br>
N/A</li>
<li><strong>TensorFlow installed from (source or binary):</strong><br>
N/A</li>
<li><strong>TensorFlow version (use command below):</strong><br>
1.8.0</li>
<li><strong>Python version:</strong><br>
2.7.14</li>
<li><strong>Bazel version (if compiling from source):</strong><br>
N/A</li>
<li><strong>GCC/Compiler version (if compiling from source):</strong><br>
7.3.0</li>
<li><strong>CUDA/cuDNN version:</strong><br>
N/A</li>
<li><strong>GPU model and memory:</strong><br>
N/A</li>
<li><strong>Exact command to reproduce:</strong><br>
N/A</li>
</ul>
<p dir="auto">Here's the code to test. Inserting a placeholder changes the sequence of <code class="notranslate">a</code> and <code class="notranslate">b</code>.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="tf.set_random_seed(1234)
#c = tf.placeholder(dtype=tf.float32, shape=[10,10])
a = tf.random_uniform([1])
b = tf.random_normal([1])

print(&quot;Session 1&quot;)
with tf.Session() as sess1:
  print(sess1.run(a))  # generates 'A1'
  print(sess1.run(a))  # generates 'A2'
  print(sess1.run(b))  # generates 'B1'
  print(sess1.run(b))  # generates 'B2'

print(&quot;Session 2&quot;)
with tf.Session() as sess2:
  print(sess2.run(a))  # generates 'A1'
  print(sess2.run(a))  # generates 'A2'
  print(sess2.run(b))  # generates 'B1'
  print(sess2.run(b))  # generates 'B2'"><pre class="notranslate"><span class="pl-s1">tf</span>.<span class="pl-en">set_random_seed</span>(<span class="pl-c1">1234</span>)
<span class="pl-c">#c = tf.placeholder(dtype=tf.float32, shape=[10,10])</span>
<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">random_uniform</span>([<span class="pl-c1">1</span>])
<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">random_normal</span>([<span class="pl-c1">1</span>])

<span class="pl-en">print</span>(<span class="pl-s">"Session 1"</span>)
<span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>() <span class="pl-k">as</span> <span class="pl-s1">sess1</span>:
  <span class="pl-en">print</span>(<span class="pl-s1">sess1</span>.<span class="pl-en">run</span>(<span class="pl-s1">a</span>))  <span class="pl-c"># generates 'A1'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess1</span>.<span class="pl-en">run</span>(<span class="pl-s1">a</span>))  <span class="pl-c"># generates 'A2'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess1</span>.<span class="pl-en">run</span>(<span class="pl-s1">b</span>))  <span class="pl-c"># generates 'B1'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess1</span>.<span class="pl-en">run</span>(<span class="pl-s1">b</span>))  <span class="pl-c"># generates 'B2'</span>

<span class="pl-en">print</span>(<span class="pl-s">"Session 2"</span>)
<span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>() <span class="pl-k">as</span> <span class="pl-s1">sess2</span>:
  <span class="pl-en">print</span>(<span class="pl-s1">sess2</span>.<span class="pl-en">run</span>(<span class="pl-s1">a</span>))  <span class="pl-c"># generates 'A1'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess2</span>.<span class="pl-en">run</span>(<span class="pl-s1">a</span>))  <span class="pl-c"># generates 'A2'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess2</span>.<span class="pl-en">run</span>(<span class="pl-s1">b</span>))  <span class="pl-c"># generates 'B1'</span>
  <span class="pl-en">print</span>(<span class="pl-s1">sess2</span>.<span class="pl-en">run</span>(<span class="pl-s1">b</span>))  <span class="pl-c"># generates 'B2'</span></pre></div>
<p dir="auto">Few Observations -</p>
<ol dir="auto">
<li>I tried adding the line <code class="notranslate">c = tf.placeholder(dtype=tf.float32, shape=[10,10])</code> before and after <code class="notranslate">tf.set_random_seed(1234)</code>. The issue persists.</li>
<li>Insertion of placeholder does not affect the outcome when op level seed is set.</li>
</ol>
<p dir="auto">Does the placeholder affect the sequence in which random numbers are generated by graph level seed?</p>
<p dir="auto">Please go to Stack Overflow for help and support:</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/tagged/tensorflow" rel="nofollow">https://stackoverflow.com/questions/tagged/tensorflow</a></p>
<p dir="auto">If you open a GitHub issue, here is our policy:</p>
<ol dir="auto">
<li>It must be a bug or a feature request.</li>
<li>The form below must be filled out.</li>
<li>It shouldn't be a TensorBoard issue. Those go <a href="https://github.com/tensorflow/tensorboard/issues">here</a>.</li>
</ol>
<p dir="auto"><strong>Here's why we have that policy</strong>: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.</p>
<hr>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>:</li>
<li><strong>TensorFlow installed from (source or binary)</strong>:</li>
<li><strong>TensorFlow version (use command below)</strong>:</li>
<li><strong>Python version</strong>:</li>
<li><strong>Bazel version (if compiling from source)</strong>:</li>
<li><strong>CUDA/cuDNN version</strong>:</li>
<li><strong>GPU model and memory</strong>:</li>
<li><strong>Exact command to reproduce</strong>:</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture script:</p>
<p dir="auto"><a href="https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh">https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh</a></p>
<p dir="auto">You can obtain the TensorFlow version with</p>
<p dir="auto">python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</p>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.</p>