Table Of Contents
Table Of Contents

Symbol.__neg__

Symbol.__neg__()[source]

x.__neg__() <=> -x

Numerical negative, element-wise.

Example

>>> a = mx.sym.Variable('a')
>>> a
<Symbol a>
>>> -a
<Symbol _mulscalar0>
>>> a_neg = a.__neg__()
>>> c = a_neg*b
>>> ex = c.eval(ctx=mx.cpu(), a=mx.nd.ones([2,3]), b=mx.nd.ones([2,3]))
>>> ex[0].asnumpy()
array([[-1., -1., -1.],
       [-1., -1., -1.]], dtype=float32)