tensorflow: tf.maximum does not return nan when inputs contain nan
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux CentOS 7
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 1.3.0
- Python version: 2.7.13
- Bazel version (if compiling from source):
- CUDA/cuDNN version: 8.0/6.0
- GPU model and memory: Tesla K40m, 11439MiB
- Exact command to reproduce: python main.py
Describe the problem
tf.maximum(a, b)
should return nan
when a
or b
contain nan
. However, it does not at some cases.
Source code / logs
main.py
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})
The output is:
1.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 35 (27 by maintainers)
As I’ve stated previously, it’s not so much an issue with Eigen as it is a lack of direction or choice from TensorFlow as to what TensorFlow’s preferred behavior is for the min and max operations when it comes to NaNs. Once that is known, it is relatively simple to change the code to be consistent in Eigen.