<h3 dir="auto">Describe the problem</h3>
<p dir="auto"><code class="notranslate">tf.reduce_min</code> and <code class="notranslate">tf.reduce_max</code> do not propagate nans correctly.  E.g.,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; tf.reduce_min([inf, nan]).eval()
inf"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; tf.reduce_min([inf, nan]).eval()
inf
</code></pre></div>
<p dir="auto">but the correct answer (the one most useful for debugging) is <code class="notranslate">nan</code>.  This is presumably due to a backwards comparison, similar to the old <code class="notranslate">tf.nn.relu(nan) == 0</code> bug that <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/alexalemi/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/alexalemi">@alexalemi</a> found.</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">Here's a colab illustrating the problem with TensorFlow 1.6.0-rc1: <a href="https://drive.google.com/file/d/1nDA0Q48PveBlx_D5Zurchbw8l7eczRSB/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/1nDA0Q48PveBlx_D5Zurchbw8l7eczRSB/view?usp=sharing</a></p>
<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>: yes</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: Linux CentOS 7</li>
<li><strong>TensorFlow installed from (source or binary)</strong>: binary</li>
<li><strong>TensorFlow version (use command below)</strong>: 1.3.0</li>
<li><strong>Python version</strong>: 2.7.13</li>
<li><strong>Bazel version (if compiling from source)</strong>:</li>
<li><strong>CUDA/cuDNN version</strong>: 8.0/6.0</li>
<li><strong>GPU model and memory</strong>: Tesla K40m, 11439MiB</li>
<li><strong>Exact command to reproduce</strong>: python main.py</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto"><code class="notranslate">tf.maximum(a, b)</code> should return <code class="notranslate">nan</code> when <code class="notranslate">a</code> or <code class="notranslate">b</code> contain <code class="notranslate">nan</code>. However, it does not at some cases.</p>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">main.py</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import tensorflow as tf
import numpy as np

a = tf.placeholder(dtype=tf.float32)
max_a = tf.maximum(a, 1.)
with tf.Session():
    print max_a.eval(feed_dict={a: np.nan})"><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">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">placeholder</span>(<span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">tf</span>.<span class="pl-s1">float32</span>)
<span class="pl-s1">max_a</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">maximum</span>(<span class="pl-s1">a</span>, <span class="pl-c1">1.</span>)
<span class="pl-k">with</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>():
    <span class="pl-k">print</span> <span class="pl-s1">max_a</span>.<span class="pl-en">eval</span>(<span class="pl-s1">feed_dict</span><span class="pl-c1">=</span>{<span class="pl-s1">a</span>: <span class="pl-s1">np</span>.<span class="pl-s1">nan</span>})</pre></div>
<p dir="auto">The output is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1.0"><pre class="notranslate"><code class="notranslate">1.0
</code></pre></div>