diff options
author | Ali Yahya <alive@google.com> | 2017-08-11 18:16:54 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-08-11 18:20:12 -0700 |
commit | f4f7b71a558ccb2d047f6e12021b79518830113e (patch) | |
tree | 68d848b8d09acbe7e0c5a21daeef7e77e3f7605c | |
parent | f01a3191a81c0e60bf08167dc3c736b43581da3a (diff) |
Correctly handles infs and nans as attr default values.
PiperOrigin-RevId: 165049398
-rw-r--r-- | tensorflow/python/framework/python_op_gen.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tensorflow/python/framework/python_op_gen.cc b/tensorflow/python/framework/python_op_gen.cc index 08aaf01cf7..e7b779663c 100644 --- a/tensorflow/python/framework/python_op_gen.cc +++ b/tensorflow/python/framework/python_op_gen.cc @@ -402,7 +402,11 @@ string AttrValueToPython(const string& type, const AttrValue& value, } else if (type == "int") { return strings::StrCat(value.i()); } else if (type == "float") { - return strings::StrCat(value.f()); + if (std::isnan(value.f()) || std::isinf(value.f())) { + return strings::StrCat("float('", value.f(), "')"); + } else { + return strings::StrCat(value.f()); + } } else if (type == "bool") { return value.b() ? "True" : "False"; } else if (type == "type") { |