---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
489 as_ref=input_arg.is_ref,
--> 490 preferred_dtype=default_dtype)
491 except TypeError as err:
/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype)
740 if ret is None:
--> 741 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
742
/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _TensorTensorConversionFunction(t, dtype, name, as_ref)
613 "Tensor conversion requested dtype %s for Tensor with dtype %s: %r"
--> 614 % (dtype.name, t.dtype.name, str(t)))
615 return t
ValueError: Tensor conversion requested dtype float32 for Tensor with dtype int32: 'Tensor("Const_1:0", shape=(), dtype=int32)'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-11-b91adb415f76> in <module>()
----> 1 tf.subtract(tf.constant(2.0),tf.constant(1)) # Fails with ValueError: Tensor conversion requested dtype float32 for Tensor with dtype int32:
/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py in subtract(x, y, name)
303
304 def subtract(x, y, name=None):
--> 305 return gen_math_ops._sub(x, y, name)
306
307
/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py in _sub(x, y, name)
2499 A `Tensor`. Has the same type as `x`.
2500 """
-> 2501 result = _op_def_lib.apply_op("Sub", x=x, y=y, name=name)
2502 return result
2503
/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
524 "%s type %s of argument '%s'." %
525 (prefix, dtypes.as_dtype(attrs[input_arg.type_attr]).name,
--> 526 inferred_from[input_arg.type_attr]))
527
528 types = [values.dtype]
TypeError: Input 'y' of 'Sub' Op has type int32 that does not match type float32 of argument 'x'.