Make "Neg" op hidden from Python.
While this technically changes the API. This was in the TensorFlow 1.0 NumPy design, so this is a bug fix to that plan, rather than a new API change. Change: 144898546
This commit is contained in:
parent
91a6f2f4d6
commit
08f6070054
@ -237,6 +237,7 @@ Max
|
|||||||
Mean
|
Mean
|
||||||
Min
|
Min
|
||||||
Mul
|
Mul
|
||||||
|
Neg
|
||||||
Pow
|
Pow
|
||||||
Prod
|
Prod
|
||||||
Range
|
Range
|
||||||
|
@ -403,11 +403,11 @@ def negative(x, name=None):
|
|||||||
"""
|
"""
|
||||||
with ops.name_scope(name, "Neg", [x]) as name:
|
with ops.name_scope(name, "Neg", [x]) as name:
|
||||||
if isinstance(x, sparse_tensor.SparseTensor):
|
if isinstance(x, sparse_tensor.SparseTensor):
|
||||||
x_neg = gen_math_ops.neg(x.values, name=name)
|
x_neg = gen_math_ops._neg(x.values, name=name)
|
||||||
return sparse_tensor.SparseTensor(
|
return sparse_tensor.SparseTensor(
|
||||||
indices=x.indices, values=x_neg, dense_shape=x.dense_shape)
|
indices=x.indices, values=x_neg, dense_shape=x.dense_shape)
|
||||||
else:
|
else:
|
||||||
return gen_math_ops.neg(x, name=name)
|
return gen_math_ops._neg(x, name=name)
|
||||||
# pylint: enable=g-docstring-has-escape
|
# pylint: enable=g-docstring-has-escape
|
||||||
|
|
||||||
|
|
||||||
@ -861,7 +861,7 @@ def to_bfloat16(x, name="ToBFloat16"):
|
|||||||
return cast(x, dtypes.bfloat16, name=name)
|
return cast(x, dtypes.bfloat16, name=name)
|
||||||
|
|
||||||
|
|
||||||
ops.Tensor._override_operator("__neg__", gen_math_ops.neg)
|
ops.Tensor._override_operator("__neg__", gen_math_ops._neg)
|
||||||
ops.Tensor._override_operator("__abs__", abs)
|
ops.Tensor._override_operator("__abs__", abs)
|
||||||
# __invert__ corresponds to the ~ operator. Here we follow the numpy convention
|
# __invert__ corresponds to the ~ operator. Here we follow the numpy convention
|
||||||
# ~ marks an elementwise bit-wise inverse. This is only implemented for boolean
|
# ~ marks an elementwise bit-wise inverse. This is only implemented for boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user