Tensorflow.js tf.neg() Function
Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .neg() function is used to calculate -1 * x i.e. input tensor and is done element wise.
- x: It is the tensor input, and it can be of type tf.Tensor, or TypedArray, or Array.
Return Value: It returns the tf.Tensor object.
Tensor [[-6], [0 ], [9 ], [1 ]]
Example 2: In this example, the parameter is passed directly to the neg function.
Tensor [[-1.4, -0.98, 9.8999996], [1.5 , -2 , -6.5 ]]